11:26 AM
@PelleLundkvist More ant species still evolving, yeah! If you could put CQ On Dope somewhere other people can retrieve it from, I'll be happy to give it some exercise.
@PelleLundkvist re Windmill's CCW: Simple example first, consider the gardener standing next to the queen. The ant function scans the surroundings and finds a friendly queen on a corner neighbor cell. It wants to consider this as nbr cell number 0, numbering further nbr cells 1, 2,..., 7 in counterclockwise order. And it wants to think of the queen as being SW of it. This isn't how the controlled presents the view, though.
If the queen is on view[6], that's already SW. We set compass to 0, and CCW[0] is 6, so CCW[compass+0] is the controller's subscript in the view leading to the queen's cell. And CCW[compass+1] is 7, the S cell in the view, and so on around the clock, until CCW[compass+7] = 3, the W cell.
If the queen is on another corner cell, compass is again set so that CCW[compass+0] is the controller's subscript into the view for the queen's cell. And the next cell counterclockwise from the queen's cell, as seen by the gardener, is again CCW[compass+1], and so on. The CCW array is long enough (repeating with period 8) that we can do all this subscripting without having to worry about reducing the sums mod 8.
It gets more complicated when we're pattern matching and set the compass to reflect a good match we found... basically the engine tries the four possibilities, bails out when the match is too bad, and sets the compass according to the current attempt when it is good enough.
On the rails, the compass is set so the queen is south, outward is north, and homeward is south. In the shafts, down (where we're drilling) is considered south, up/homeward is north. (Arbitrarily, just to fit the "mine shaft" metaphor.)
Once the compass is set, if (say) I see an enemy at CCW[compass+3] and what to do something with the next cell to the left of that (from my point of view), that cell is CCW[compass+4]. The next cell on the right is CCW[compass+3-1]. But when doing this in terms of CCW[compass+i], where compass might be 0 and i might be 0, I can't safely subtract 1, so I add 7 instead: Next cell to the right is CCW[compass+i+7] (and CCW is long enough for this to work in all cases).
(...and want to do... silly autocorrection plus thick fingers, sorry 'bout that. :) )