tinycodinglm / chess /chess-0092.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 12)
3c88a0f verified
|
Raw History Blame Contribute Delete
1.73 kB
opencode trace
System You are an expert chess programmer.

You are an expert chess programmer.

User

Explain chess search algorithms

Assistant

Minimax: evaluate all positions to depth d, maximize for white, minimize for black. O(b^d) where b = branching factor (~35 in chess).

Alpha-beta: prune branches that cannot affect the result. Alpha = best guaranteed for maximizer, beta = best for minimizer. If alpha >= beta, prune. With perfect move ordering: O(b^{d/2}).

Negamax: equivalent to minimax but both players maximize. Score = -negamax(opponent). Simpler implementation.

PVS (Principal Variation Search): search first move with full window, subsequent moves with null window (beta = alpha+1). Re-search if null window fails high. O(b^{d/2}) with good move ordering.

MTD(f): bidirectional search using null-window tests. Repeatedly call negamax with zero window, adjusting bounds. Converges to exact value. Very efficient but needs good guess.

Transposition table: hash positions, store evaluated score and best move. Avoids re-evaluating transpositions (different move orders reaching same position). Zobrist hashing: XOR random values for each piece on each square.

Iterative deepening: search depth 1, then 2, etc. Provides best-so-far move for time control. Also improves move ordering (previous iteration's best move first).

Quiescence search: at leaf nodes, continue searching captures until position is quiet. Prevents horizon effect (evaluating during a capture sequence).