Sorting and the cache
A radar answers not «who is there» but «who is best». And it does not answer afresh every time
Four radars, all with the same filters — only the measure and the order differ. The dagger is closer and healthier, the flare further away and weaker.
What to measure by
Section titled “What to measure by”| Measure | What it compares |
|---|---|
distance |
the distance to the block |
health |
current health |
maxHealth |
maximum health |
shield |
shield |
armor |
armour |
The order: the sixth field
Section titled “The order: the sixth field”Zero and one flip the choice:
| Measure and order | Who it finds |
|---|---|
distance 1 |
the nearest |
distance 0 |
the furthest |
health 1 |
the toughest |
health 0 |
the weakest |
An easier way to remember it: one means “the best by the measure”, zero “the worst”. For distance, “best” means nearest, because that is usually who you are after.
The answer refreshes once every 30 ticks
Section titled “The answer refreshes once every 30 ticks”A radar does not search afresh every iteration. A block’s result is recomputed once every 30 ticks — half a second — and between recomputations the previous answer is handed back. This is done for speed: a dozen radars in a program would otherwise eat a frame.
Press “run” and watch dead. The turret finishes the flare off, and for a while aim still
points at it — only now with @dead equal to one.
Unofficial fan project, not affiliated with Anuke. Mindustry sprites, fonts and translations © Anuke, used under GPL-3.0; Fira Code under OFL-1.1. Site code is GPL-3.0.