At 9/28/12 12:38 AM, PrettyMuchBryce wrote:
I agree. I read Tyler's post about his version of A* and it is very cool. I would love to know exactly how it works, though. How do you assign initial values to the nodes? It seems that every time the player makes a move then each node. 1: Decreases it's 'scent' value. 2: Sets the node at the players current position to 100% scent. Am I missing anything else ?
The way I did that demo was not quite scent based, but it was based on the idea. That one had 4 maps, a "distance from wall" map, a "distance from targets" map, a "number of zombies on each grid space" map, and then the final combined pathfinding map, every frame it would generate the number of zombies per grid space map, then run flood fill out the pathfinding map using the others as weights for how much effort was required to pass through a tile (to keep them away from walls and tiles with lots of zombies). I dunno I did it in 2010.
The way to do real scent-pathfinding (I did this before too but don't have a sample of it)
You have your pathfinding grid, each grid space is just a float of how much "scent" it has
To emit scent into the map, just add scent to the grid space the emitter is on. For targets you want to avoid, you add negative scent to the map.
Now to diffuse the map, its just a blur operation pretty much. Don't do it "in-place", you diffuse onto a NEW map then swap the new one in place of the old one. For grid space (x, y) in the new map, you just sum up the values from (x, y),(x-1, y),(x+1,y),(x,y-1),(x,y+1) from the old map, and divide by 5. If one of those spots is a wall, its value is 0, and the divisor decreases by 1 (not entirely necessary, you can also treat walls as just emitters that set their current value to 0 always, instead of adding or subtracting a flat amount). You're gonna want to multiply the value of each tile by .99 or something every tick too to prevent stuff from spiraling to infinity. Also you're gonna want to use sufficiently large values for emitters, otherwise tiles far away will have extremely small scent values (denormalized floats) which are REALLY slow to compute
Play around with it its fun. I curious about it for a while. Seems really like, suited for zombie games.