-
Notifications
You must be signed in to change notification settings - Fork 10
Map Analysis
Map analysis is needed for path finding, foundation placement and scouting. This is the basis for services like attack maps. This page uses the Arcadia 02 map as example and refers to 0 A.D. Alpha 16. Maps in 0 A.D. are always squares and range from tiny (128x128) to giant (512x512). Maps could be circular with corners as forbidden areas, regular maps forbid only the out most few cells. The cell size maps from grid x/y to entity x/y and is always 4.
The passability map is the corner stone of map analysis. It appears on several places in the API, but it is given to the API via .init and .onUpdate in file shared.js. The API does not support passability for saved games. AIEngineAPI
m.SharedScript.prototype.init = function(state) {
this.passabilityClasses = state.passabilityClasses;
this.passabilityMap = state.passabilityMap;The passability map is a 16bit array where the lower 8 bit have the meanings below. The purpose of the upper 8 bit is not clear as of writing. The bits are provided via passabilityClasses. The API states the value for pathfinderObstruction may change during a game.
pathfinderObstruction: 1, // map border
foundationObstruction: 2, // trees, mines
building-land: 4, //
building-shore: 8, //
default: 16, //
ship: 32, //
unrestricted: 64 //
There are three types of regions for path finding: Water, land and forbidden. Water and land may overlap and indicate shallow water accessible by land and water units. Code below transforms into Hannibal's internal coding.
t = (
(s & 1) ? 0 : // dark red : pathfinder obstruction forbidden
(s & 32) && (s & 64) ? 64 : // red : land too steep
(s & 32) && !(s & 64) ? 32 : // dark blue : deep water
!(s & 16) && (s & 64) ? 16 : // light blue : shallow water
(s & 16) ? 8 : // green : land only
255 // the gaps (probably shallow water)
);Arcadia contains 2 water and 3 land regions. The 2 water regions are not connected and only one land region is accessible. Regions carry the information whether a change of transport (aka ships) is needed going from point x to point y. Hannibal uses a flood fill algorithm to determine regions during start-up.

