zone detection

What do you want to see in Armagetron soon? Any new feature ideas? Let's ponder these ground breaking ideas...
Post Reply
User avatar
Galaxip
Average Program
Posts: 88
Joined: Wed Aug 24, 2016 10:49 pm

zone detection

Post by Galaxip »

i was looking at the bike-zone detection it looks strange and seems to be splitting a zone into 42 segments then checking if bike intersects one of these segments

maybe this was done for speed ? im not sure

im not great at math but i think something like this should work

distance=sqrt(sqr(abs(bikeX - zoneX)) + sqr(abs(bikeY - zoneY))) - zoneRadius

distance will be > 0 if youre outside the zone and <= 0 if youre inside the zone
Image Image Image

User avatar
Galaxip
Average Program
Posts: 88
Joined: Wed Aug 24, 2016 10:49 pm

Re: zone detection

Post by Galaxip »

just thinking you could remove the square root and square the radius should execute faster

distance=sqr(abs(bikeX - zoneX)) + sqr(abs(bikeY - zoneY)) - sqr(zoneRadius)
Image Image Image

User avatar
aP|Nelg
Match Winner
Posts: 581
Joined: Wed Oct 22, 2014 10:22 pm
Contact:

Re: zone detection

Post by aP|Nelg »

Er, are you referring to the CYCLE_ZONES_AVOID code ?
Screenshot from 2020-09-15 11-52-03.png
This is a hack for detecting if the AIs are heading towards a zone, NOT for detecting whether every player is in the zone. It indeed isn't the best but an improvement over simply checking if an AI is near a zone before attempting to turn away. This will only happen if you have AIs in the game and if the AIs are close enough to the zone anyway; it shouldn't be massively detrimental to performance. (basically, most likely only active in single player)

The actual bit detecting if a player is inside a zone or not is available within InteractWith:
Screenshot from 2020-09-15 11-54-46.png
Which, thinking about it, I'm not quite sure why it'd trigger OnEnter every time. Maybe because there's no OnInside callback here? Meh.

User avatar
Z-Man
God & Project Admin
Posts: 11354
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: zone detection

Post by Z-Man »

aP|Nelg wrote:
Tue Sep 15, 2020 4:55 pm
Which, thinking about it, I'm not quite sure why it'd trigger OnEnter every time. Maybe because there's no OnInside callback here? Meh.
That would be the reason. Development started with just Win and Death zones, where the effect would only trigger once no matter what, that's why the function was called OnEnter and not OnInside. Renaming virtual functions is always a bit of a pain, that's probably why the name then stuck.

User avatar
Galaxip
Average Program
Posts: 88
Joined: Wed Aug 24, 2016 10:49 pm

Re: zone detection

Post by Galaxip »

wouldnt this work to detect if approaching zone perimeter ?

distance=sqr(abs(bikeX - zoneX)) + sqr(abs(bikeY - zoneY)) - sqr(zoneRadius)
zoneDetectRange=sqr(metres)

to avoid zones from outside

if distance < zoneDetectRange then turn


to stay inside zones from inside

if -distance < zoneDetectRange then turn


to both avoid zones if outside and stay inside if already inside

if abs(distance) < zoneDetectRange then turn
Image Image Image

User avatar
aP|Nelg
Match Winner
Posts: 581
Joined: Wed Oct 22, 2014 10:22 pm
Contact:

Re: zone detection

Post by aP|Nelg »

Probably, but it would not detect if the cycle is actually facing the (edge of the) zone, only distance.

User avatar
Galaxip
Average Program
Posts: 88
Joined: Wed Aug 24, 2016 10:49 pm

Re: zone detection

Post by Galaxip »

yeah thats true nelg
Image Image Image

Post Reply