Answers.Body: <p>I think this issue stems from the fact you aren't taking position into account. I would think this because as the game progresses, the number of moves that will result in a piece being taken becomes less and less, especially when there's only a few pieces left and quite a bit of "chasing" must occur before a piece is taken, likely more chasing then a depth of 14 allows. </p>
  
  <p>To remedy this, you could, towards the end of the game, add to the value of a state the inverse of the total distance each friendly piece has from other pieces, that way the agent will try to move towards other pieces and minimise this distance. If you find the right scale for this heuristic, the agent will prioritise moving towards enemy pieces only when it cant find any moves that result in taking a piece, helping it break out of this loop.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-06T03:29:06.537Z
Answers.LastActivityDate: 2019-12-06T03:29:06.537Z
Answers.UserDisplayName: Recessive
Body: <p>I have implemented minimax with alpha-beta pruning to play checkers. As my value heuristic, I am using only the summation of material value on the board regardless of the position.</p>
  <p>My main issue lays in actually finishing games. A search with depth 14 draws against depth 3, since the algorithm becomes stuck in a loop of moving kings back and forth in a corner. The depth 14 player has a significant material advantage with four kings and a piece against a single king, however, it moves only one piece.</p>
  <p>I have randomly selected a move from the list of equally valued moves and this leads to more interesting games (thus preventing the loop). However, whichever player used this random tactic ended up far worse off.</p>
  <p>I am not quite sure how to solve this problem. <em>Should I do a deeper search of the best moves with the same value? Or is the heuristic at fault? If so, what changes would you suggest?</em></p>
  <p>So far I have tried a simple genetically generated algorithm that optimizes a linear scoring function (that accounts for the position). However as the algorithm optimized, it led to only draws and the same king loop.</p>
  <p>Any suggestions for how to stop this king loop are very welcome!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-05T05:21:32.477Z
Comments.Text: It may be that you don't have a good condition for "tie-breakers" in your terminal states(try boundary value analysis, fiddle with your if-statement conditions), so it keeps undoing its own progress. What are the evaluation- and utility functions in your implementation?
Comments.UserDisplayName: Jack Of Blades
Tags: <game-ai><search><minimax><alpha-beta-pruning><checkers>
Title: To deal with infinite loops, should I do a deeper search of the best moves with the same value, in alpha-beta pruning?
UserDisplayName: TurbulentWinds
ThreadText: # To deal with infinite loops, should I do a deeper search of the best moves with the same value, in alpha-beta pruning?
  
  (Asked by: username_0 on 2019-12-06)
  
  I have implemented minimax with alpha-beta pruning to play checkers. As my value heuristic, I am using only the summation of material value on the board regardless of the position.
  
  My main issue lays in actually finishing games. A search with depth 14 draws against depth 3, since the algorithm becomes stuck in a loop of moving kings back and forth in a corner. The depth 14 player has a significant material advantage with four kings and a piece against a single king, however, it moves only one piece.
  
  I have randomly selected a move from the list of equally valued moves and this leads to more interesting games (thus preventing the loop). However, whichever player used this random tactic ended up far worse off.
  
  I am not quite sure how to solve this problem. *Should I do a deeper search of the best moves with the same value? Or is the heuristic at fault? If so, what changes would you suggest?*
  
  So far I have tried a simple genetically generated algorithm that optimizes a linear scoring function (that accounts for the position). However as the algorithm optimized, it led to only draws and the same king loop.
  
  Any suggestions for how to stop this king loop are very welcome!
  
  **Tags:** game-ai, search, minimax, alpha-beta-pruning, checkers
  
  > **Comments:**
  > **username_1**: It may be that you don't have a good condition for "tie-breakers" in your terminal states(try boundary value analysis, fiddle with your if-statement conditions), so it keeps undoing its own progress. What are the evaluation- and utility functions in your implementation?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-12-06. Score: 1
  
  I think this issue stems from the fact you aren't taking position into account. I would think this because as the game progresses, the number of moves that will result in a piece being taken becomes less and less, especially when there's only a few pieces left and quite a bit of "chasing" must occur before a piece is taken, likely more chasing then a depth of 14 allows.
  
  To remedy this, you could, towards the end of the game, add to the value of a state the inverse of the total distance each friendly piece has from other pieces, that way the agent will try to move towards other pieces and minimise this distance. If you find the right scale for this heuristic, the agent will prioritise moving towards enemy pieces only when it cant find any moves that result in taking a piece, helping it break out of this loop.
  
  
  ---
  
  