Quote:Original post by Emergent
[...]But why a grid? Just choose some reasonable function that you can evaluate analytically and move down its gradient;[...]
Because it's easier to iterate over projectiles and draw lines from them than try to figure out an equivalent formula, and I'm not sure you could create an equivalent formula that didn't involve the same calculations as a grid. The influence of a projectile is conditional upon its eventual collision with a point, so you're still going to have to project them all forward in time to test for collision, then, if it would collide with a given position, calculate some value based on the distance into the future when it would collide combined with its damage.
The grid acts a very simple cache that allows evaluating each projectile only a single time regardless of the number of movement choices (or agents that need to make choices). You could use something more complicated (a fancy partitioning tree or graph) to cache collision information but I don't think it buys enough to be worth the extra work.
For example, if your movement choices are stay, right 1-10 units, or left 1-10 units, you'll need to know collisions for 21 possible locations. If you make a grid and fill it, you'll calculate each projectile's path once over a 21-square grid (since you only need to know the info for the places you can move) or, if you calculate each choice's weight independently, you might end up examining each projectile 21 times.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk