Liqwiid Wars/Algorithm

From WiiBrew
< Liqwiid Wars
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Algorithm

For those wondering the algorithm I am using to get the gradient can be defined as such...

new_grid[x, y] = abs(position[0] - x) + abs(position[1] - y);

4 3 2 3 4 5

3 2 1 2 w 4

2 1 X 1 w 3

3 2 1 2 w 4

4 3 2 3 4 5

However if a wall exists, any fighters on the right of the wall cant "escape" due to them ALWAYS going to an area of equal or lower potential.

Using...

new_grid[x, y] = max(abs(position[0] - x), abs(position[1] - y));

would give

2 2 2 2 2 3

2 1 1 1 w 3

2 1 X 1 w 3

2 1 1 1 w 3

2 2 2 2 2 3

With the wall in the same position the problem no longer arises. However "max" gives additional overheads, and the second option will give rise to this situation

2 2 2 w 2 3

2 1 1 1 w 3

2 1 X 1 2 w

2 1 1 1 2 3

2 2 2 2 2 3

where any army trapped in the "2" space above the wall is trapped there, until the cursor moves.

Either I am worrying about it too much, as the cursor wont stay in the same position for an amount of time (especially given the fact the IR will shake) added to the fact this will not affect a huge amount of fighters

-or-

I need to program some disobedience into the fighters such that very occasionally they will disregard orders and go in the wrong direction