This sets up the initial stack with the children with higher g-values pushed on it. Therefore, this function's speed very much depends on the initial children count. This function is not complicated, but the calculations involved can take an extremely long time for large maps. Another thing to note is that the kid's cost is reassessed here and added to the parents g-value. Simply call SetRows, SetValid, SetCost, and SetData, then GeneratePath with the start and destination values.
All spaces are valid, as long as they're within the board.
Cost is 1 per space. Applications in Gaming .