Edit- here are the rules of the game, if you are not familiar: https://en.wikipedia.org/wiki/Reversi#Rules
Let's assume black was the first to move on a standard 8x8 board with 2 tiles for each player placed in the center of the board in the traditional starting configuration for a Reversi game. We also know that both players have moved the same number of moves, (so black is the next to move)
Is it possible to find a set of valid moves that would result in the given board state? (It is understood that there are multiple moves that could result in a given state. As long as the moves are valid, I don't care)
By "board state", I mean the arrangement of tiles on the board.
I'm familiar with minmax algo (with alpha pruning) but I'm not sure if it can be used in this case.
This is what I came up with in my head:
- White was last to move, so search for a continous line of white tiles
- Flip all tiles in that line except for the first and last ones. (the ends)
- Remove one end tile and keep track of its position on the board. This is a potential move. Leave the other end as-is.
- Check if the board is in a valid state.
If you repeat these steps for black, then white, then black, and so on, you will either:
A. End up in the starting position. The result is a set of valid moves that satisfy the orignal board state. (The moves you kept track of in step 3)
B. If the board is valid but the next player doesn't have a move, it's possible that there was no valid move at that time. Record 0 for that move and keep going with the previous player.
C. Invalid board state. Delete the previously remembered move and restore the board state. Using the same player, start the process over again, looking for a continuous line of tiles. If no other lines exist, undo the next recorded move, and start again with the other player. Rinse. Repeat, until you arrive at A.
Depending on how far the game has advanced, this could take a. really. long. time. I might be overlooking some aspect of gameplay that would make it even more challenging.
This seems a lot more difficult than finding the best move using minmax, etc.
Has anyone successfully been able to do this programmatically? Is it even possible mid-to-late game?
I have not tried to do this yet in code. I'm trying to wrap my head around it first.