Suppose I am making a game with locations, and some sort of pathfinding might become one way or other necessary.
what comes to my mind first is that each location would have subtable called "neighbors".
as example:
Code: Select all
locations = {
["Finland"] = [ neighbors = { "sweden", "norway", "russia", "estonia"} },
["Sweden"] = [ neighbors = { "Finland", "Norway", "denmark"} },
...
}
Idea would be that each name in that list, would do so that they would check through all their neighbors and in some certain cases, neighbors could be added to the locationstocheck list:
Code: Select all
foreach(t_locationstocheck, Function (cell, data)
foreach(cell.neighbors, Function (index, value)
if index.friendly=true then insertitem(t_locationstocheck, value)
EndFunction)
EndFunction)
Hence how does Hollywood work with this?
1. It only executes table in its original form.
2. It also executes everything added to the end of the list during the process.
And if number 2, then how does index 0 work out? Since if i understood right, index 0 is executed last, but what if that index 0 has some neighbors that are added to the t_locationstocheck, does it then happen, that these ones are not executed at all, or will these new ones be executed as well, and if they are as well executed, then will index 0 be executed again?
And as last question regarding this; Are there some other things that I should take into consideration if I am planning to use this method?