The safe and short path in multi-player game is calculated based on the "cost" of the cell. the robot chooses the path which has the lowest total of the cell costs. The cost of each cell is calculated as follows:
The cell's static cost is calculated as a sum of the following:
#.# _@_ ___("#"
: wall or water"."
: a open cell)
("_"
: don't care"@"
: the current location)
__# _@. _#_
__# _@_ #__
_#_ _@_ _#_
_._ _@_ _~_
Examples:
### .@. ###cost = 3.0 (entrance, narrow, diagonal, knight)~.~ .@~ ~~~cost = 8.2 (entrance, diagonal, knight, double water)
If the blocked cell is near the current location, the path going through that cell is strongly discouraged. If it is far away, however, the blocking robot may move to another location before the robot reaches there. So we added the quadratic decay to the equation above.
When the Dijkstra's algorithm traverses the field, 1.01 is multiplied to the dynamic cost if two successive steps are in the same direction. This penalty is relatively small, but it makes the robot's move more zigzag-like rather than "L"-shaped. We added this small hack expecting to avoid taking the same congested path as the paths of other robots.