I’m going to try to explain this in simple terms, because it’s probably shorter than if I were to post code. I made part of a recursive solution which has to complete a game by picking the correct “move order”, and if it runs into an impasse, then it must backtrack. My current system works by setting an identifier on any move that hasn’t worked so that it cannot be used again while backtracking, until a new path/move order is found.
However I ran into a problem; the game can reach a state where there are only two moves left and neither of them will solve the game. My current system will basically make these two moves continually swap one another because the solution attempts to play a move, sees that it doesn’t work, and then tries to next one. I believe my problem is that I reset my identifier which tells the solution not to use a move, every time a move is made, but I’m not sure how else I would set it up.
Let me know if you need any further information or have any insight. Thanks!
I am not sure about the nature of the game you are describing and some more information could help in determining a better method for you to follow. I saw your comment in the Topic where you say that this index resets after a new move has been found. This does not sound very good. I believe you would have to fix this because as you just saw from your example there are cases where it will fail and we can’t have an algorithm that works only conditionally.
The problem you describe sounds like a game tree? Correct? If so why not change your description of the problem to a game tree and utilize one of the proved game tree search algorithms such as Alpha-Beta Pruning assuming the game is adversarial?