Minimax should handle draws and repetition explicitly in your terminal detection and scoring, because ignoring them can produce unstable or exploitable behavior. If your game has draw outcomes (stalemate, threefold repetition, move-limit rules, perpetual checks), you need to encode them in the game state and terminate search accordingly. Otherwise the search might incorrectly assume the game continues indefinitely, or it may choose moves that loop forever because the evaluation function doesn’t penalize repetition. The simplest baseline is to assign a draw utility (often 0) and treat draw states as terminal.
Implementation details depend on the rules. For repetition-based draws, you usually need a history mechanism: store a hash of each visited position (including side to move and relevant state) and count occurrences. In a make/unmake move engine, you can maintain a repetition table or stack of hashes and increment/decrement counts on move/unmove. When a repetition condition triggers, return the draw score. For “no progress” counters (like a 50-move rule), include the counter in the state hash and update it on moves that reset progress. For stalemate or “no legal moves,” detect it during move generation: if there are no legal moves and the player is not in check (or the game’s equivalent), it’s a draw; if they are in check, it’s a loss.
A practical example: if your evaluation function strongly prefers being up material, your engine might pick a line that repeats positions instead of converting, because repetition preserves material advantage and avoids risk. If you want the engine to avoid draws when winning, you can keep the draw score at 0 but add a “contempt” factor (a small penalty to draws when you’re ahead) in the evaluation. Be careful: contempt can make play unrealistic or cause the engine to take unsafe risks, so it should be tuned and often disabled in certain situations. In retrieval-driven decision trees, “repetition” can show up as cycling between the same evidence and the same action without progress. If your system uses Milvus or Zilliz Cloud, tracking recently used document IDs (or embedding IDs) and penalizing repeated selections can prevent loops and encourage exploration—analogous to how repetition handling prevents infinite cycles in Minimax.