PED - path engine data | |
Hlavní datovou strukturou je PED (path engine data). Tato struktura obsahuje všechna data potřebná pro běh jedné insatance hledacího enginu. Ukazatel na tuto strukturu je předáván každé volané funkci. | |
// Path engine object typedef struct _PathEngineData { // engine states peTime Time; // engine time int State; // engine state // map int MapSX, MapSY; // map dimensions MapNode* Map; // map tiles array // walkers int MaxWalkers; // max walkers engine can handle Walker* Walkers; // array Walker* FirstWalker; // linked list of walkers Walker* LastWalker; // end of linked list // paths int MaxSteps; // not used // requests int MPCPT; // maximum paths counted per tick Request* RequestsTop; // requests ring top boundary Request* RequestsBottom; // requests ring bottom boundary Request* FirstRequest; // requests ring start Request* LastRequest; // requests ring end // heuristics peHeuristic* Heuristic; // heuristic function // A-star heap int HeapSize; // heap size Heap* Open; // heap of open nodes int LastSID; // SID = Search ID // engine settings int MAXTC; // maximal terrain cost int StandingBlockerCost; // additional cost of blocked node by walker int WalkingBlockerCost; // additional cost of temoprary blocked node int FootStepCost; // additional cost of node with step int BaseCost; // cost of clear node (for heuristics) int HorizontalCost; // cost of horizontal/vertical clear move int DiagonalCost; // cost of diagonal clear move int NearDestination; // near destination int BadFinalRatio; // how much times (than heuristics) is final way expensive int BadFinalShift; // bad shift for final way cutting peTime WaitingTimeout; // waiting timeout to replann way } PED; |
|
Reprezentace mapy: Map odkazuje na pole MapNodů o rozměrech MapSX x MapSY. | |
Chodící objekty na mapě (Walkers) jsou repreznetovány polem struktur Walker. Aktivní Walkeři jsou propojeni do dvojsměrného spojového seznamu (FirstWalker až LastWalker). | |
Požadavky od Walkerů na nalezení cesty jsou ukládány do pole (hranice RequestTop a RequestBottom). Způsob ukládání je do kruhu (FirstRequest až LastRequest - s přechodem přes Top). MPCPT určuje maximální počet cest, které se mohou spočítat v jednom tiku. | |
Heuristic určuje heuristickou funkci pro odhadování zbývající vzdálenosti do cíle. | |
Je zde uložena halda otevřených uzlů pro hledací algoritmus (Heap). | |
Nastavení parametrů enginu. |