Chess
Prompt
# Challenge: Build a Complete Chess Engine in One Python Script Implement a fully playable chess engine in a single `chess.py` file using only Python's standard library. Requirements: - Implement all legal chess moves, including castling, en passant, pawn promotion, check, checkmate, and stalemate. - Correctly handle pinned pieces, discovered checks, double checks, and king safety. - Implement Forsyth–Edwards Notation (FEN) parsing and generation. - Implement Portable Game Notation (PGN) import and export, including comments and move numbers. - Implement threefold repetition detection, the fifty-move rule, insufficient material, and draw claims. - Build an efficient legal-move generator and position evaluator. - Implement iterative-deepening minimax with alpha-beta pruning, quiescence search, move ordering, transposition tables, and Zobrist hashing. - Support configurable search depth, time limits, and cancellation. - Provide a command-line interface where a human can play against the engine, enter moves in standard algebraic notation, undo moves, load positions, and save games. - Include perft testing for move-generation correctness, with known test positions and expected node counts. - Add automated tests for special moves, check detection, draw conditions, hashing consistency, and search correctness. - Handle malformed input gracefully without corrupting the game state. Everything must be implemented in **one self-contained Python file**. No external libraries, no `eval()`, no placeholders, and no fake test results. Include usage instructions and explain the key algorithms. Prioritize legal move generation and correctness over playing strength.
Response not available
Response not available