Advertisement

Does such algorithm exists? Puzzle game IA problem

Started by December 07, 2010 06:54 AM
9 comments, last by Kethis 13 years, 11 months ago
Quote: Original post by Kevin Dill
From here, you should be able to swap rows without losing the horizontal and vertical correctness, right? Can you follow the above algorithm by looking for row swaps that will fix the diagonals?


Yep.

Sorry if Im being rude, but whats the problem here? The solution is pretty darn straightforward. Row/column swaps will only ever effect the diagonals and never the rows/columns themselves.

Initialize it in the form:

0123456789
1234567890
2345678901
3456789012
4567890123
5678901234
6789012345
7890123456
8901234567
9012345678

then perform a large number of random row and column swaps.

After that, you check to see if the diagonal has any problems. Identify rows/column pairs with these problems. Randomly switch the first one have a problem with. Repeat until all conflicts are resolved.

Since you have such reasonable size square, and this is presumably not needed to be done constantly during game play, it'll work fine.

This topic is closed to new replies.

Advertisement