// phmap1.c MR May 2001 // // Pheromone Map, for quick determining of distance to // nearest pheromone-emitting entity on/in a chessboard world. // // This version uses "city-block distance". // // User declares array int phmap[ XSIZE * YSIZE ], where // X/YSIZE are the width/height of the chessboard. // User makes func calls in this order: // 1. phmap_init() (This sets all squares to -1.) // 2. Call phmap_enteremitter() once for each pheromone-emitting // entity. // 3. Call phmap_calc() to calculate the spreading of the pheromone // over the map. // 4. To retrieve the results from the previous step, call // phmap_getdist() as many times as you like to ask the // distance of a square to the nearest pheromone-emitting entity. // NOTE: phmap_getdist() returns -1 if there is NO pheromone // emitter anywhere on the map. #include #include #include "bool.h" #define ELACCESS( pmap, xsize, ix, iy ) \ ( (pmap)[ (xsize) * (iy) + (ix) ] ) _bool inMap( int xsize, int ysize, int ix, int iy ) { return ( 0