├── chess └── py.typed ├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── setup-ubuntu-latest.sh │ ├── setup-windows-latest.sh │ └── test.yml ├── docs ├── changelog.rst ├── images │ ├── maia.png │ ├── jcchess.png │ ├── syzygy.png │ ├── cli-chess.png │ ├── crazyara.png │ ├── pettingzoo.png │ └── clente-chess.png ├── requirements.txt ├── index.rst ├── svg.rst ├── wR.svg ├── polyglot.rst ├── syzygy.rst ├── gaviota.rst ├── conf.py ├── pgn.rst ├── core.rst ├── variant.rst ├── Makefile ├── make.bat └── engine.rst ├── fuzz ├── corpus │ ├── fen │ │ ├── empty │ │ ├── endgame │ │ ├── initial │ │ ├── scid-zh │ │ ├── horde │ │ ├── scid-3check │ │ ├── winboard-3check │ │ └── winboard-zh │ ├── engine │ │ ├── uciok-readyok │ │ ├── stockfish-10 │ │ └── stockfish-mv-11 │ ├── epd │ │ ├── giveaway-puzzles.epd │ │ ├── string-escaping.epd │ │ ├── bratko-kopec.epd │ │ └── pv.epd │ └── pgn │ │ ├── molinari-bordais-1979.pgn │ │ ├── anastasian-lewis.pgn │ │ ├── antichess-programfox.pgn │ │ ├── saturs-jannlee-zh-lichess.pgn │ │ ├── knightvuillaume-jannlee-zh-lichess.pgn │ │ ├── stockfish-learning.pgn │ │ ├── kasparov-deep-blue-1997.pgn │ │ └── cutechess-fischerrandom.pgn ├── fen.py ├── epd.py ├── pgn.py └── engine.py ├── MANIFEST.in ├── data ├── polyglot │ ├── SOURCE.txt │ ├── lasker-trap.bin │ └── performance.bin ├── gaviota │ ├── kbk.gtb.cp4 │ ├── knk.gtb.cp4 │ ├── kpk.gtb.cp4 │ ├── kqk.gtb.cp4 │ ├── krk.gtb.cp4 │ ├── TEST-SOURCE.txt │ ├── MD5SUMS.txt │ └── SOURCE.txt ├── syzygy │ └── regular │ │ ├── KBBvK.rtbw │ │ ├── KBBvK.rtbz │ │ ├── KBNvK.rtbw │ │ ├── KBNvK.rtbz │ │ ├── KBPvK.rtbw │ │ ├── KBPvK.rtbz │ │ ├── KBvK.rtbw │ │ ├── KBvK.rtbz │ │ ├── KBvKB.rtbw │ │ ├── KBvKB.rtbz │ │ ├── KBvKN.rtbw │ │ ├── KBvKN.rtbz │ │ ├── KBvKP.rtbw │ │ ├── KBvKP.rtbz │ │ ├── KNNvK.rtbw │ │ ├── KNNvK.rtbz │ │ ├── KNPvK.rtbw │ │ ├── KNPvK.rtbz │ │ ├── KNvK.rtbw │ │ ├── KNvK.rtbz │ │ ├── KNvKN.rtbw │ │ ├── KNvKN.rtbz │ │ ├── KNvKP.rtbw │ │ ├── KNvKP.rtbz │ │ ├── KPPvK.rtbw │ │ ├── KPPvK.rtbz │ │ ├── KPvK.rtbw │ │ ├── KPvK.rtbz │ │ ├── KPvKP.rtbw │ │ ├── KPvKP.rtbz │ │ ├── KQBvK.rtbw │ │ ├── KQBvK.rtbz │ │ ├── KQNvK.rtbw │ │ ├── KQNvK.rtbz │ │ ├── KQPvK.rtbw │ │ ├── KQPvK.rtbz │ │ ├── KQQvK.rtbw │ │ ├── KQQvK.rtbz │ │ ├── KQRvK.rtbw │ │ ├── KQRvK.rtbz │ │ ├── KQvK.rtbw │ │ ├── KQvK.rtbz │ │ ├── KQvKB.rtbw │ │ ├── KQvKB.rtbz │ │ ├── KQvKN.rtbw │ │ ├── KQvKN.rtbz │ │ ├── KQvKP.rtbw │ │ ├── KQvKP.rtbz │ │ ├── KQvKQ.rtbw │ │ ├── KQvKQ.rtbz │ │ ├── KQvKR.rtbw │ │ ├── KQvKR.rtbz │ │ ├── KRBvK.rtbw │ │ ├── KRBvK.rtbz │ │ ├── KRNvK.rtbw │ │ ├── KRNvK.rtbz │ │ ├── KRPvK.rtbw │ │ ├── KRPvK.rtbz │ │ ├── KRRvK.rtbw │ │ ├── KRRvK.rtbz │ │ ├── KRvK.rtbw │ │ ├── KRvK.rtbz │ │ ├── KRvKB.rtbw │ │ ├── KRvKB.rtbz │ │ ├── KRvKN.rtbw │ │ ├── KRvKN.rtbz │ │ ├── KRvKP.rtbw │ │ ├── KRvKP.rtbz │ │ ├── KRvKR.rtbw │ │ ├── KRvKR.rtbz │ │ └── SOURCE.txt ├── pgn │ ├── molinari-bordais-1979.pgn │ ├── utf8-bom.pgn │ ├── uci-moves.pgn │ ├── anastasian-lewis.pgn │ ├── antichess-programfox.pgn │ ├── nepomniachtchi-liren-game1.pgn │ ├── saturs-jannlee-zh-lichess.pgn │ ├── chessbase-empty-line.pgn │ ├── knightvuillaume-jannlee-zh-lichess.pgn │ ├── stockfish-learning.pgn │ ├── kasparov-deep-blue-1997.pgn │ └── cutechess-fischerrandom.pgn ├── suicide-dtz.epd ├── endgame-dm-5.epd ├── suicide-dtm.epd ├── endgame-dm-4.epd └── endgame.epd ├── .editorconfig ├── .readthedocs.yml ├── python-chess-stub ├── README.rst └── setup.py ├── examples ├── perft │ ├── 3check.perft │ ├── racingkings.perft │ ├── horde.perft │ ├── giveaway.perft │ ├── crazyhouse.perft │ ├── atomic.perft │ ├── tricky.perft │ └── perft.py ├── chess960_pos_list.py ├── polyglot_tree.py ├── bratko_kopec │ ├── bratko-kopec.epd │ ├── giveaway-puzzles.epd │ └── bratko_kopec.py ├── xray_attacks.py └── push_san.py ├── .gitignore ├── tox.ini ├── setup.py └── release.py /chess/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: niklasf 2 | -------------------------------------------------------------------------------- /docs/changelog.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CHANGELOG.rst 2 | -------------------------------------------------------------------------------- /fuzz/corpus/fen/empty: -------------------------------------------------------------------------------- 1 | 8/8/8/8/8/8/8/8 w - - 0 1 2 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include CHANGELOG.rst 2 | include LICENSE.txt 3 | -------------------------------------------------------------------------------- /fuzz/corpus/fen/endgame: -------------------------------------------------------------------------------- 1 | 1Q6/p3R3/6rp/P1K2k2/8/8/6pP/8 w - - 0 46 2 | -------------------------------------------------------------------------------- /fuzz/corpus/engine/uciok-readyok: -------------------------------------------------------------------------------- 1 | Fake engine 2 | uciok 3 | ! 4 | readyok 5 | ! 6 | -------------------------------------------------------------------------------- /fuzz/corpus/epd/giveaway-puzzles.epd: -------------------------------------------------------------------------------- 1 | 2b5/K1p1pk2/6pb/8/8/8/8/8 b - - bm Bb7; 2 | -------------------------------------------------------------------------------- /fuzz/corpus/fen/initial: -------------------------------------------------------------------------------- 1 | rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 2 | -------------------------------------------------------------------------------- /data/polyglot/SOURCE.txt: -------------------------------------------------------------------------------- 1 | performance.bin: http://wbec-ridderkerk.nl/html/download.htm 2 | -------------------------------------------------------------------------------- /docs/images/maia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/docs/images/maia.png -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | Sphinx==8.1.2 2 | sphinxcontrib-jquery==4.1 3 | sphinx-rtd-theme==3.0.1 4 | -------------------------------------------------------------------------------- /fuzz/corpus/epd/string-escaping.epd: -------------------------------------------------------------------------------- 1 | 4k3/8/8/8/8/8/8/4K3 w - - a "foo\"bar";; ; b "foo\\\\"; 2 | -------------------------------------------------------------------------------- /fuzz/corpus/fen/scid-zh: -------------------------------------------------------------------------------- 1 | 1r3rkQ/pPp2p1p/1pp2Bp1/8/3P4/4P3/PP3PPP/R2Q1RK1/BPNBnbnn b - - 39 20 2 | -------------------------------------------------------------------------------- /docs/images/jcchess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/docs/images/jcchess.png -------------------------------------------------------------------------------- /docs/images/syzygy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/docs/images/syzygy.png -------------------------------------------------------------------------------- /fuzz/corpus/fen/horde: -------------------------------------------------------------------------------- 1 | rnbqkb1r/p1p1nppp/2Pp4/3P1PP1/PPPPPP1P/PPP1PPPP/PPPPPPPP/PPPPPPPP w kq - 1 6 2 | -------------------------------------------------------------------------------- /fuzz/corpus/fen/scid-3check: -------------------------------------------------------------------------------- 1 | r1b2rk1/ppp2p1p/4p1p1/4Bn2/1b2N3/3B4/PPP3PP/R2Q1R1K b - - 0 15 +0+0 2 | -------------------------------------------------------------------------------- /fuzz/corpus/fen/winboard-3check: -------------------------------------------------------------------------------- 1 | r1b2rk1/ppp2p1p/4p1p1/4Bn2/1b2N3/3B4/PPP3PP/R2Q1R1K b - - 3+3 0 15 2 | -------------------------------------------------------------------------------- /fuzz/corpus/fen/winboard-zh: -------------------------------------------------------------------------------- 1 | r4rk1/p2bppbp/6p1/2qpP3/5P2/2NBPQPp/PPP4P/R1B3K1[NNNrp] b - - 39 20 2 | -------------------------------------------------------------------------------- /data/gaviota/kbk.gtb.cp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/gaviota/kbk.gtb.cp4 -------------------------------------------------------------------------------- /data/gaviota/knk.gtb.cp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/gaviota/knk.gtb.cp4 -------------------------------------------------------------------------------- /data/gaviota/kpk.gtb.cp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/gaviota/kpk.gtb.cp4 -------------------------------------------------------------------------------- /data/gaviota/kqk.gtb.cp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/gaviota/kqk.gtb.cp4 -------------------------------------------------------------------------------- /data/gaviota/krk.gtb.cp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/gaviota/krk.gtb.cp4 -------------------------------------------------------------------------------- /docs/images/cli-chess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/docs/images/cli-chess.png -------------------------------------------------------------------------------- /docs/images/crazyara.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/docs/images/crazyara.png -------------------------------------------------------------------------------- /docs/images/pettingzoo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/docs/images/pettingzoo.png -------------------------------------------------------------------------------- /fuzz/corpus/epd/bratko-kopec.epd: -------------------------------------------------------------------------------- 1 | 1k1r4/pp1b1R2/3q2pp/4p3/2B5/4Q3/PPP2B2/2K5 b - - bm Qd1+; id "BK.01"; 2 | -------------------------------------------------------------------------------- /docs/images/clente-chess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/docs/images/clente-chess.png -------------------------------------------------------------------------------- /data/polyglot/lasker-trap.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/polyglot/lasker-trap.bin -------------------------------------------------------------------------------- /data/polyglot/performance.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/polyglot/performance.bin -------------------------------------------------------------------------------- /data/syzygy/regular/KBBvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBBvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KBBvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBBvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KBNvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBNvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KBNvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBNvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KBPvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBPvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KBPvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBPvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KBvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KBvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KBvKB.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBvKB.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KBvKB.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBvKB.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KBvKN.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBvKN.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KBvKN.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBvKN.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KBvKP.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBvKP.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KBvKP.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KBvKP.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KNNvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KNNvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KNNvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KNNvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KNPvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KNPvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KNPvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KNPvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KNvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KNvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KNvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KNvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KNvKN.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KNvKN.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KNvKN.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KNvKN.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KNvKP.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KNvKP.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KNvKP.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KNvKP.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KPPvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KPPvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KPPvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KPPvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KPvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KPvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KPvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KPvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KPvKP.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KPvKP.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KPvKP.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KPvKP.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQBvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQBvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQBvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQBvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQNvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQNvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQNvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQNvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQPvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQPvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQPvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQPvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQQvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQQvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQQvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQQvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQRvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQRvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQRvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQRvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQvKB.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvKB.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQvKB.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvKB.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQvKN.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvKN.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQvKN.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvKN.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQvKP.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvKP.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQvKP.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvKP.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQvKQ.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvKQ.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQvKQ.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvKQ.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KQvKR.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvKR.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KQvKR.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KQvKR.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KRBvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRBvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KRBvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRBvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KRNvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRNvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KRNvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRNvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KRPvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRPvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KRPvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRPvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KRRvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRRvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KRRvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRRvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KRvK.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRvK.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KRvK.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRvK.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KRvKB.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRvKB.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KRvKB.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRvKB.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KRvKN.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRvKN.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KRvKN.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRvKN.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KRvKP.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRvKP.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KRvKP.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRvKP.rtbz -------------------------------------------------------------------------------- /data/syzygy/regular/KRvKR.rtbw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRvKR.rtbw -------------------------------------------------------------------------------- /data/syzygy/regular/KRvKR.rtbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niklasf/python-chess/HEAD/data/syzygy/regular/KRvKR.rtbz -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: '/' 5 | schedule: 6 | interval: monthly 7 | -------------------------------------------------------------------------------- /fuzz/corpus/epd/pv.epd: -------------------------------------------------------------------------------- 1 | rq2r1k1/5pp1/p7/4bNP1/1p2P2P/5Q2/PP4K1/5R1R w - - bm Nxg7; id "BT-2630.1"; ce 182; acs 0; acn 106652; pv Nxg7 Kxg7 Qxf7+ Kh8 Qh7+ Kxh7 Rf7+ Kg6 Rf6+ Bxf6 h5+ Kxg5; c0 8 2 | -------------------------------------------------------------------------------- /data/syzygy/regular/SOURCE.txt: -------------------------------------------------------------------------------- 1 | HTTP: http://tablebase.sesse.net/syzygy/ 2 | BitTorrent: http://oics.olympuschess.com/tracker/index.php 3 | eMule: http://kirill-kryukov.com/chess/tablebases-online/ 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://editorconfig.org/ 2 | 3 | root = true 4 | 5 | [*] 6 | end_of_line = lf 7 | insert_final_newline = true 8 | 9 | [*.py] 10 | charset = utf-8 11 | ident_style = space 12 | ident_size = 4 13 | 14 | [Makefile] 15 | ident_style = tab 16 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | build: 4 | os: ubuntu-22.04 5 | tools: 6 | python: "3.10" 7 | 8 | sphinx: 9 | configuration: docs/conf.py 10 | 11 | python: 12 | install: 13 | - method: pip 14 | path: . 15 | - requirements: docs/requirements.txt 16 | -------------------------------------------------------------------------------- /python-chess-stub/README.rst: -------------------------------------------------------------------------------- 1 | python-chess 2 | ============ 3 | 4 | Package moved 5 | ------------- 6 | 7 | This package has been moved to https://pypi.org/project/chess/. 8 | 9 | Thanks to `Kristian Glass `_ for making 10 | the package name available. 11 | -------------------------------------------------------------------------------- /examples/perft/3check.perft: -------------------------------------------------------------------------------- 1 | id 3check-kiwipete 2 | epd r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 1+1 3 | perft 1 48 4 | perft 2 2039 5 | perft 3 97848 6 | 7 | id 3check-castling 8 | epd r3k2r/8/8/8/8/8/8/R3K2R w KQkq - 1+1 9 | perft 1 26 10 | perft 2 562 11 | perft 3 13410 12 | -------------------------------------------------------------------------------- /data/pgn/molinari-bordais-1979.pgn: -------------------------------------------------------------------------------- 1 | [Event "cr"] 2 | [Site "cr"] 3 | [Date "1979.??.??"] 4 | [EventDate "?"] 5 | [Round "?"] 6 | [Result "0-1"] 7 | [White "Molinari"] 8 | [Black "Bordais"] 9 | [ECO "B20"] 10 | [WhiteElo "?"] 11 | [BlackElo "?"] 12 | [PlyCount "10"] 13 | 14 | 1. e4 c5 2. c4 Nc6 3. Ne2 Nf6 4. Nbc3 Nb4 5. g3 Nd3# 0-1 15 | -------------------------------------------------------------------------------- /examples/perft/racingkings.perft: -------------------------------------------------------------------------------- 1 | id racingkings-start 2 | epd 8/8/8/8/8/8/krbnNBRK/qrbnNBRQ w - - 3 | perft 1 21 4 | perft 2 421 5 | perft 3 11264 6 | perft 4 296242 7 | 8 | id occupied-goal 9 | epd 4brn1/2K2k2/8/8/8/8/8/8 w - - 10 | perft 1 6 11 | perft 2 33 12 | perft 3 178 13 | perft 4 3151 14 | perft 5 12981 15 | perft 6 265932 16 | -------------------------------------------------------------------------------- /fuzz/corpus/pgn/molinari-bordais-1979.pgn: -------------------------------------------------------------------------------- 1 | [Event "cr"] 2 | [Site "cr"] 3 | [Date "1979.??.??"] 4 | [EventDate "?"] 5 | [Round "?"] 6 | [Result "0-1"] 7 | [White "Molinari"] 8 | [Black "Bordais"] 9 | [ECO "B20"] 10 | [WhiteElo "?"] 11 | [BlackElo "?"] 12 | [PlyCount "10"] 13 | 14 | 1. e4 c5 2. c4 Nc6 3. Ne2 Nf6 4. Nbc3 Nb4 5. g3 Nd3# 0-1 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | venv/ 2 | *.swp 3 | *.py[cod] 4 | *~ 5 | .coverage 6 | .coveralls.yml 7 | nosetests.xml 8 | .tox 9 | .mypy_cache 10 | 11 | dist/ 12 | build/ 13 | *.egg-info/ 14 | docs/_build/ 15 | 16 | data/gaviota/*.gtb.cp4 17 | data/syzygy/regular/*.rtb[wz] 18 | data/syzygy/suicide/*.stb[wz] 19 | data/syzygy/atomic/*.atb[wz] 20 | data/syzygy/giveaway/*.[gs]tb[wz] 21 | 22 | fuzz/corpus 23 | 24 | release-v*.txt 25 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | 3 | Contents 4 | -------- 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | core 10 | pgn 11 | polyglot 12 | gaviota 13 | syzygy 14 | engine 15 | svg 16 | variant 17 | 18 | .. toctree:: 19 | :maxdepth: 1 20 | 21 | changelog 22 | 23 | Indices and tables 24 | ------------------ 25 | 26 | * :ref:`genindex` 27 | * :ref:`search` 28 | -------------------------------------------------------------------------------- /.github/workflows/setup-ubuntu-latest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | # Stockfish 4 | sudo apt-get install -y stockfish 5 | 6 | # Crafty 7 | sudo apt-get install -y crafty 8 | 9 | # Fairy-stockfish 10 | sudo apt-get install -y fairy-stockfish 11 | 12 | # Gaviota libgtb 13 | git clone https://github.com/michiguel/Gaviota-Tablebases.git --depth 1 14 | cd Gaviota-Tablebases 15 | make 16 | echo "LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}" >> $GITHUB_ENV 17 | cd .. 18 | -------------------------------------------------------------------------------- /docs/svg.rst: -------------------------------------------------------------------------------- 1 | SVG rendering 2 | ============= 3 | 4 | The :mod:`chess.svg` module renders SVG Tiny 1.2 images 5 | (mostly for IPython/Jupyter Notebook integration). 6 | The piece images by 7 | `Colin M.L. Burnett `_ are triple 8 | licensed under the GFDL, BSD and GPL. 9 | 10 | .. autofunction:: chess.svg.piece 11 | 12 | .. autofunction:: chess.svg.board 13 | 14 | .. autoclass:: chess.svg.Arrow 15 | :members: 16 | -------------------------------------------------------------------------------- /data/suicide-dtz.epd: -------------------------------------------------------------------------------- 1 | 8/8/8/8/3b4/8/8/8 w - - wdl 2; dtz 1 2 | 8/8/7p/7P/3b4/8/8/8 w - - wdl 2; dtz 1 3 | 8/8/8/8/8/6N1/7B/b7 b - - wdl 2; dtz 3 4 | 8/8/8/8/5N2/6B1/7B/b7 b - - wdl 2; dtz 3 5 | 8/8/8/8/8/8/8/b5NN b - - wdl 2; dtz 3 6 | 8/8/8/8/8/8/8/bb4NN b - - wdl 2; dtz 3 7 | 5b2/8/8/8/8/2b5/8/1N6 w - - wdl -2; dtz -1 8 | 3q4/8/3b4/8/8/8/3N4/1K1Q4 b - - wdl 2; dtz 3 9 | 3q4/8/3b4/8/8/8/3N4/2KQ4 w - - wdl -2; dtz -4 10 | 1k6/8/8/8/8/B7/3PK3/6k1 w - - wdl -2; dtz -54 11 | -------------------------------------------------------------------------------- /data/pgn/utf8-bom.pgn: -------------------------------------------------------------------------------- 1 | [Event "A"] 2 | [Site "?"] 3 | [Date "2024.04.25"] 4 | [Round "?"] 5 | [White "White vs 1...c5"] 6 | [Black "?"] 7 | [Result "*"] 8 | [ECO "A00"] 9 | [PlyCount "0"] 10 | [SourceVersionDate "2024.04.25"] 11 | 12 | * 13 | 14 | [Event "B"] 15 | [Site "?"] 16 | [Date "2024.04.25"] 17 | [Round "?"] 18 | [White "White vs 1...c5"] 19 | [Black "?"] 20 | [Result "*"] 21 | [ECO "A00"] 22 | [PlyCount "0"] 23 | [SourceVersionDate "2024.04.25"] 24 | 25 | * 26 | 27 | -------------------------------------------------------------------------------- /examples/perft/horde.perft: -------------------------------------------------------------------------------- 1 | id horde-start 2 | epd rnbqkbnr/pppppppp/8/1PP2PP1/PPPPPPPP/PPPPPPPP/PPPPPPPP/PPPPPPPP w kq - 3 | perft 1 8 4 | perft 2 128 5 | perft 3 1274 6 | perft 4 23310 7 | 8 | id horde-open-flank 9 | epd 4k3/pp4q1/3P2p1/8/P3PP2/PPP2r2/PPP5/PPPP4 b - - 10 | perft 1 30 11 | perft 2 241 12 | perft 3 6633 13 | perft 4 56539 14 | 15 | id horde-en-passant 16 | epd k7/5p2/4p2P/3p2P1/2p2P2/1p2P2P/p2P2P1/2P2P2 w - - 17 | perft 1 13 18 | perft 2 172 19 | perft 3 2205 20 | perft 4 33781 21 | -------------------------------------------------------------------------------- /docs/wR.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/polyglot.rst: -------------------------------------------------------------------------------- 1 | Polyglot opening book reading 2 | ============================= 3 | 4 | .. autofunction:: chess.polyglot.open_reader 5 | 6 | .. autoclass:: chess.polyglot.Entry 7 | :members: 8 | 9 | 10 | .. autoclass:: chess.polyglot.MemoryMappedReader 11 | :members: 12 | 13 | .. py:data:: chess.polyglot.POLYGLOT_RANDOM_ARRAY 14 | :value: [0x9D39247E33776D41, ..., 0xF8D626AAAF278509] 15 | 16 | Array of 781 polyglot compatible pseudo random values for Zobrist hashing. 17 | 18 | .. autofunction:: chess.polyglot.zobrist_hash 19 | -------------------------------------------------------------------------------- /examples/perft/giveaway.perft: -------------------------------------------------------------------------------- 1 | id antichess-start 2 | epd rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w - - 3 | perft 1 20 4 | perft 2 400 5 | perft 3 8067 6 | perft 4 153299 7 | 8 | id a-pawn-vs-b-pawn 9 | epd 8/1p6/8/8/8/8/P7/8 w - - 10 | perft 1 2 11 | perft 2 4 12 | perft 3 4 13 | perft 4 3 14 | perft 5 1 15 | perft 6 0 16 | 17 | id a-pawn-vs-c-pawn 18 | epd 8/2p5/8/8/8/8/P7/8 w - - 19 | perft 1 2 20 | perft 2 4 21 | perft 3 4 22 | perft 4 4 23 | perft 5 4 24 | perft 6 4 25 | perft 7 4 26 | perft 8 4 27 | perft 9 12 28 | perft 10 36 29 | perft 11 312 30 | perft 12 2557 31 | perft 13 30873 32 | -------------------------------------------------------------------------------- /docs/syzygy.rst: -------------------------------------------------------------------------------- 1 | Syzygy endgame tablebase probing 2 | ================================ 3 | 4 | Syzygy tablebases provide WDL\ :sub:`50` (win/draw/loss under the 50-move rule) and 5 | DTZ\ :sub:`50`'' (distance to zeroing) information with rounding for all endgame 6 | positions with up to 7 pieces. Positions with castling rights are not included. 7 | 8 | .. warning:: 9 | Ensure tablebase files match the known checksums. Maliciously crafted 10 | tablebase files may cause denial of service. 11 | 12 | .. autofunction:: chess.syzygy.open_tablebase 13 | 14 | .. autoclass:: chess.syzygy.Tablebase 15 | :members: 16 | -------------------------------------------------------------------------------- /fuzz/fen.py: -------------------------------------------------------------------------------- 1 | import chess 2 | 3 | from pythonfuzz.main import PythonFuzz 4 | 5 | 6 | @PythonFuzz 7 | def fuzz(buf): 8 | try: 9 | fen = buf.decode("utf-8") 10 | except UnicodeDecodeError: 11 | pass 12 | else: 13 | try: 14 | board = chess.Board(fen) 15 | except ValueError: 16 | pass 17 | else: 18 | sanitized_fen = board.fen() 19 | board.status() 20 | list(board.legal_moves) 21 | sanitized_board = chess.Board(sanitized_fen) 22 | assert sanitized_board.fen() == sanitized_fen 23 | 24 | 25 | if __name__ == "__main__": 26 | fuzz() 27 | -------------------------------------------------------------------------------- /.github/workflows/setup-windows-latest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | echo Download stockfish ... 4 | choco install wget 5 | wget https://github.com/official-stockfish/Stockfish/releases/download/sf_16/stockfish-windows-x86-64-avx2.zip 6 | 7 | echo Unzip .. 8 | 7z e stockfish-windows-x86-64-avx2.zip stockfish/stockfish-windows-x86-64-avx2.exe 9 | 10 | echo Setup path ... 11 | mv stockfish-windows-x86-64-avx2.exe stockfish.exe 12 | pwd >> $GITHUB_PATH 13 | 14 | echo Download fairy-stockfish ... 15 | wget https://github.com/fairy-stockfish/Fairy-Stockfish/releases/latest/download/fairy-stockfish-largeboard_x86-64.exe 16 | mv fairy-stockfish-largeboard_x86-64.exe fairy-stockfish.exe 17 | -------------------------------------------------------------------------------- /fuzz/epd.py: -------------------------------------------------------------------------------- 1 | import chess 2 | 3 | from pythonfuzz.main import PythonFuzz 4 | 5 | 6 | @PythonFuzz 7 | def fuzz(buf): 8 | try: 9 | epd = buf.decode("utf-8") 10 | except UnicodeDecodeError: 11 | pass 12 | else: 13 | try: 14 | board, ops = chess.Board.from_epd(epd) 15 | except ValueError as err: 16 | pass 17 | else: 18 | sanitized_epd = board.epd(**ops) 19 | sanitized_board, sanitized_ops = chess.Board.from_epd(sanitized_epd) 20 | assert board == sanitized_board 21 | assert ops == sanitized_ops, (ops, sanitized_ops) 22 | 23 | 24 | if __name__ == "__main__": 25 | fuzz() 26 | -------------------------------------------------------------------------------- /fuzz/pgn.py: -------------------------------------------------------------------------------- 1 | import io 2 | import logging 3 | 4 | import chess.pgn 5 | 6 | from pythonfuzz.main import PythonFuzz 7 | 8 | 9 | # The default parser logs errors for syntax errors. 10 | logging.getLogger("chess.pgn").setLevel(logging.CRITICAL) 11 | 12 | 13 | @PythonFuzz 14 | def fuzz(buf): 15 | try: 16 | pgn = io.StringIO(buf.decode("utf-8")) 17 | except UnicodeDecodeError: 18 | pass 19 | else: 20 | while True: 21 | game = chess.pgn.read_game(pgn) 22 | if game is None: 23 | break 24 | 25 | repr(game) 26 | if not game.errors: 27 | str(game) 28 | 29 | 30 | if __name__ == "__main__": 31 | fuzz() 32 | -------------------------------------------------------------------------------- /examples/chess960_pos_list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """List all Chess960 starting positions.""" 4 | 5 | import sys 6 | import timeit 7 | import chess 8 | 9 | 10 | def main(bench_only: bool = False) -> None: 11 | board = chess.Board.empty(chess960=True) 12 | 13 | for scharnagl in range(0, 960): 14 | board.set_chess960_pos(scharnagl) 15 | 16 | if not bench_only: 17 | print(str(scharnagl).rjust(3), board.fen()) 18 | 19 | 20 | if __name__ == "__main__": 21 | if "bench" in sys.argv: 22 | print(timeit.timeit( 23 | stmt="main(bench_only=True)", 24 | setup="from __main__ import main", 25 | number=10)) 26 | else: 27 | main() 28 | -------------------------------------------------------------------------------- /examples/perft/crazyhouse.perft: -------------------------------------------------------------------------------- 1 | id zh-all-drop-types 2 | epd 2k5/8/8/8/8/8/8/4K3[QRBNPqrbnp] w - - 3 | perft 1 301 4 | perft 2 75353 5 | 6 | id zh-drops 7 | epd 2k5/8/8/8/8/8/8/4K3[Qn] w - - 8 | perft 1 67 9 | perft 2 3083 10 | perft 3 88634 11 | perft 4 932554 12 | 13 | id zh-middlegame 14 | epd r1bqk2r/pppp1ppp/2n1p3/4P3/1b1Pn3/2NB1N2/PPP2PPP/R1BQK2R[] b KQkq - 15 | perft 1 42 16 | perft 2 1347 17 | perft 3 58057 18 | perft 4 2083382 19 | 20 | id zh-promoted 21 | epd 4k3/1Q~6/8/8/4b3/8/Kpp5/8/ b - - 22 | perft 1 20 23 | perft 2 360 24 | perft 3 5445 25 | perft 4 132758 26 | 27 | id zh-midgame 28 | epd 2rn1b1r/1pp2n1p/B1PBk1pP/5p1P/P5p1/2P2RP1/RP1QNP2/1NBK4[QPp] w - - 29 | perft 1 99 30 | perft 2 3932 31 | perft 3 314782 32 | perft 4 10118606 33 | -------------------------------------------------------------------------------- /data/pgn/uci-moves.pgn: -------------------------------------------------------------------------------- 1 | [Event "CCRL 40/4"] 2 | [Site "CCRL"] 3 | [Date "2006.05.24"] 4 | [Round "1"] 5 | [White "Aristarch 4.50"] 6 | [Black "Chess Tiger 15"] 7 | [Result "1/2-1/2"] 8 | 9 | g1f3 c7c5 e2e4 d7d6 d2d4 c5d4 f3d4 g8f6 b1c3 e7e6 c1e3 a7a6 g2g4 h7h6 d1f3 b8d7 f1e2 d8c7 f3h3 d6d5 e4d5 f8b4 e3d2 c7b6 d5e6 b6d4 e6d7 c8d7 e1c1 d4b6 d2e3 b4c5 h3g3 c5e3 f2e3 e8g8 g4g5 h6g5 g3g5 f8e8 d1d3 f6h7 c3d5 h7g5 d5b6 d7c6 h1g1 g5h3 g1g3 h3f2 b6a8 f2d3 c2d3 e8a8 g3g5 g7g6 g5c5 g8g7 h2h4 a8h8 h4h5 f7f5 d3d4 g6h5 d4d5 c6e8 c5c7 e8f7 d5d6 g7f6 d6d7 h8d8 c7b7 f6e7 e2a6 f7d5 b7b6 d8d7 a6e2 d7c7 c1d2 d5a2 b6h6 c7d7 d2e1 a2b3 h6h7 e7e6 h7d7 e6d7 e2h5 d7e6 h5d1 b3a2 e1f2 e6e5 f2f3 a2f7 d1c2 f7d5 f3g3 d5c4 c2b1 c4d5 b1d3 d5b3 d3b5 e5e4 g3f2 f5f4 b5c6 e4e5 e3e4 1/2-1/2 10 | -------------------------------------------------------------------------------- /data/pgn/anastasian-lewis.pgn: -------------------------------------------------------------------------------- 1 | [Event "World Senior Teams +50"] 2 | [Site "Radebeul GER"] 3 | [Date "2016.07.03"] 4 | [Round "8.2"] 5 | [White "Anastasian, A."] 6 | [Black "Lewis, An"] 7 | [Result "1-0"] 8 | [ECO "E90"] 9 | [WhiteElo "2532"] 10 | [BlackElo "2269"] 11 | [PlyCount "84"] 12 | [EventDate "2016.06.26"] 13 | 14 | 1. d4 Nf6 2. c4 g6 3. Nc3 Bg7 4. e4 d6 5. Nf3 O-O 6. h3 e5 7. d5 Na6 8. Be3 Nh5 15 | 9. Nh2 Qe8 10. Be2 Nf4 11. Bf3 f5 12. a3 Nc5 13. Bxc5 dxc5 14. O-O Qe7 15. Re1 16 | a6 16. Ne2 Qd6 17. Nf1 Bd7 18. Rb1 b6 19. Nd2 Bh6 20. Nxf4 Bxf4 21. b4 Rae8 22. 17 | Qc2 Rf6 23. Qc3 Qf8 24. Nb3 cxb4 25. axb4 Bg5 26. Rb2 Rf7 27. Nc1 Qh6 28. Nd3 18 | fxe4 29. Bxe4 Bxh3 30. gxh3 Qxh3 31. Bg2 Qh4 32. Re4 Qh5 33. Rbe2 Ref8 34. c5 19 | Bf4 35. Nxe5 Qh2+ 36. Kf1 Rf5 37. Nf3 Qh5 38. Re7 Bh6 39. R2e5 bxc5 40. bxc5 20 | Rxf3 41. Bxf3 Z0 42. Ke1 Qh1+ 1-0 21 | -------------------------------------------------------------------------------- /fuzz/corpus/pgn/anastasian-lewis.pgn: -------------------------------------------------------------------------------- 1 | [Event "World Senior Teams +50"] 2 | [Site "Radebeul GER"] 3 | [Date "2016.07.03"] 4 | [Round "8.2"] 5 | [White "Anastasian, A."] 6 | [Black "Lewis, An"] 7 | [Result "1-0"] 8 | [ECO "E90"] 9 | [WhiteElo "2532"] 10 | [BlackElo "2269"] 11 | [PlyCount "84"] 12 | [EventDate "2016.06.26"] 13 | 14 | 1. d4 Nf6 2. c4 g6 3. Nc3 Bg7 4. e4 d6 5. Nf3 O-O 6. h3 e5 7. d5 Na6 8. Be3 Nh5 15 | 9. Nh2 Qe8 10. Be2 Nf4 11. Bf3 f5 12. a3 Nc5 13. Bxc5 dxc5 14. O-O Qe7 15. Re1 16 | a6 16. Ne2 Qd6 17. Nf1 Bd7 18. Rb1 b6 19. Nd2 Bh6 20. Nxf4 Bxf4 21. b4 Rae8 22. 17 | Qc2 Rf6 23. Qc3 Qf8 24. Nb3 cxb4 25. axb4 Bg5 26. Rb2 Rf7 27. Nc1 Qh6 28. Nd3 18 | fxe4 29. Bxe4 Bxh3 30. gxh3 Qxh3 31. Bg2 Qh4 32. Re4 Qh5 33. Rbe2 Ref8 34. c5 19 | Bf4 35. Nxe5 Qh2+ 36. Kf1 Rf5 37. Nf3 Qh5 38. Re7 Bh6 39. R2e5 bxc5 40. bxc5 20 | Rxf3 41. Bxf3 Z0 42. Ke1 Qh1+ 1-0 21 | -------------------------------------------------------------------------------- /data/pgn/antichess-programfox.pgn: -------------------------------------------------------------------------------- 1 | [Variant "Antichess"] 2 | 3 | 1. g3 Nh6 2. g4 Nxg4 3. b3 Nxh2 4. Rxh2 g5 5. Rxh7 Rxh7 6. Bh3 Rxh3 7. Nxh3 Na6 8. Nxg5 Nb4 9. Nxf7 Nxc2 10. Qxc2 Kxf7 11. Qxc7 Qxc7 12. a4 Qxc1 13. Ra3 Qxa3 14. Nxa3 b5 15. Nxb5 Rb8 16. Nxa7 Rxb3 17. Nxc8 Rg3 18. Nxe7 Bxe7 19. fxg3 Bh4 20. gxh4 d5 21. e4 dxe4 22. d3 exd3 23. Kf1 d2 24. Kg1 Kf6 25. a5 Ke6 26. a6 Kd7 27. a7 Kc7 28. h5 d1=B 29. a8=B Bxh5 30. Bf3 Bxf3 31. Kg2 Bxg2# 1-0 4 | 5 | [Variant "Antichess"] 6 | 7 | 1. Nh3 b6 2. Ng5 g6 3. Nxf7 Kxf7 4. g4 h5 5. gxh5 Rxh5 6. Bh3 Rxh3 7. Rg1 Rxh2 8. Rxg6 Rxf2 9. Rxg8 Kxg8 10. Kxf2 Na6 11. b4 Nxb4 12. a3 Nxc2 13. Qxc2 e6 14. Qxc7 Bxa3 15. Rxa3 Qxc7 16. Rxa7 Qxc1 17. Rxd7 Qxd2 18. Nxd2 Bxd7 19. Ne4 e5 20. Nc5 bxc5 21. e4 Bf5 22. exf5 c4 23. f6 Kh7 24. f7 Re8 25. fxe8=K c3 26. Kd7 e4 27. Kc6 e3 28. Kxe3 c2 29. Kc5 c1=K 30. Kd2 Kxd2 31. Kd5 Kg7 32. Kd6 Kd3 1/2-1/2 8 | -------------------------------------------------------------------------------- /fuzz/corpus/pgn/antichess-programfox.pgn: -------------------------------------------------------------------------------- 1 | [Variant "Antichess"] 2 | 3 | 1. g3 Nh6 2. g4 Nxg4 3. b3 Nxh2 4. Rxh2 g5 5. Rxh7 Rxh7 6. Bh3 Rxh3 7. Nxh3 Na6 8. Nxg5 Nb4 9. Nxf7 Nxc2 10. Qxc2 Kxf7 11. Qxc7 Qxc7 12. a4 Qxc1 13. Ra3 Qxa3 14. Nxa3 b5 15. Nxb5 Rb8 16. Nxa7 Rxb3 17. Nxc8 Rg3 18. Nxe7 Bxe7 19. fxg3 Bh4 20. gxh4 d5 21. e4 dxe4 22. d3 exd3 23. Kf1 d2 24. Kg1 Kf6 25. a5 Ke6 26. a6 Kd7 27. a7 Kc7 28. h5 d1=B 29. a8=B Bxh5 30. Bf3 Bxf3 31. Kg2 Bxg2# 1-0 4 | 5 | [Variant "Antichess"] 6 | 7 | 1. Nh3 b6 2. Ng5 g6 3. Nxf7 Kxf7 4. g4 h5 5. gxh5 Rxh5 6. Bh3 Rxh3 7. Rg1 Rxh2 8. Rxg6 Rxf2 9. Rxg8 Kxg8 10. Kxf2 Na6 11. b4 Nxb4 12. a3 Nxc2 13. Qxc2 e6 14. Qxc7 Bxa3 15. Rxa3 Qxc7 16. Rxa7 Qxc1 17. Rxd7 Qxd2 18. Nxd2 Bxd7 19. Ne4 e5 20. Nc5 bxc5 21. e4 Bf5 22. exf5 c4 23. f6 Kh7 24. f7 Re8 25. fxe8=K c3 26. Kd7 e4 27. Kc6 e3 28. Kxe3 c2 29. Kc5 c1=K 30. Kd2 Kxd2 31. Kd5 Kg7 32. Kd6 Kd3 1/2-1/2 8 | -------------------------------------------------------------------------------- /python-chess-stub/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import setuptools 6 | 7 | setuptools.setup( 8 | name="python-chess", 9 | version="1.999", 10 | author="Niklas Fiekas", 11 | author_email="niklas.fiekas@backscattering.de", 12 | description="A chess library with move generation, move validation, and support for common formats.", 13 | long_description=open(os.path.join(os.path.dirname(__file__), "README.rst")).read(), 14 | long_description_content_type="text/x-rst", 15 | license="GPL-3.0+", 16 | keywords="chess fen epd pgn polyglot syzygy gaviota uci xboard", 17 | url="https://github.com/niklasf/python-chess", 18 | packages=[], 19 | install_requires=["chess>=1,<2"], 20 | classifiers=[ 21 | "Development Status :: 7 - Inactive", 22 | ], 23 | project_urls={ 24 | "Documentation": "https://python-chess.readthedocs.io", 25 | }, 26 | ) 27 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py38,py39,py310,py311,py312,py313,py314 3 | 4 | [testenv] 5 | passenv = LD_LIBRARY_PATH 6 | whitelist_externals = 7 | stockfish 8 | crafty 9 | fairy-stockfish 10 | commands = 11 | python test.py --verbose 12 | python -m doctest README.rst --verbose 13 | 14 | [testenv:{py38,py39}] 15 | passenv = LD_LIBRARY_PATH 16 | whitelist_externals = 17 | stockfish 18 | crafty 19 | commands = 20 | python test.py --verbose 21 | 22 | [flake8] 23 | ignore = 24 | # Allow over-indent and unaligned indent 25 | E126 E131 26 | # Allow indenting array elements 27 | E241 28 | # Allow grouping functions 29 | E302 E305 30 | # Allow "ambiguous" variable names 31 | E741 32 | # Allow binary operators before EOL (end of line) 33 | W504 34 | # Allow "def overloaded(): ..." 35 | E704 E301 36 | # Bare except (with or without reraise) 37 | E722 38 | max-line-length = 160 39 | -------------------------------------------------------------------------------- /data/pgn/nepomniachtchi-liren-game1.pgn: -------------------------------------------------------------------------------- 1 | [Event "FIDE World Championship 2023"] 2 | [Site "Astana KAZ"] 3 | [Date "2023.04.09"] 4 | [Round "1"] 5 | [White "Nepomniachtchi, Ian"] 6 | [Black "Liren, Ding"] 7 | [Result "1/2-1/2"] 8 | [TimeControl "40/7200:20/3600:900+30"] 9 | [WhiteFideId "4168119"] 10 | [BlackFideId "8603677"] 11 | [WhiteElo "2795"] 12 | [BlackElo "2788"] 13 | 14 | 1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Bxc6 dxc6 15 | 7. Re1 Nd7 8. d4 exd4 9. Qxd4 O-O 10. Bf4 Nc5 11. Qe3 Bg4 12. Nd4 16 | Qd7 13. Nc3 Rad8 14. Nf5 Ne6 15. Nxe7+ Qxe7 16. Bg3 Bh5 17. f3 f6 17 | 18. h3 h6 19. Kh2 Bf7 20. Rad1 b6 21. a3 a5 22. Ne2 Rxd1 23. Rxd1 18 | Rd8 24. Rd3 c5 25. Qd2 c6 26. Rxd8+ Nxd8 27. Qf4 b5 28. Qb8 Kh7 19 | 29. Bd6 Qd7 30. Ng3 Ne6 31. f4 h5 32. c3 c4 33. h4 Qd8 34. Qb7 20 | Be8 35. Nf5 Qd7 36. Qb8 Qd8 37. Qxd8 Nxd8 38. Nd4 Nb7 39. e5 Kg8 21 | 40. Kg3 Bd7 41. Bc7 Nc5 42. Bxa5 Kf7 43. Bb4 Nd3 44. e6+ Bxe6 22 | 45. Nxc6 Bd7 46. Nd4 Nxb2 47. Kf3 Nd3 48. g3 Nc1 49. Ke3 1/2-1/2 23 | -------------------------------------------------------------------------------- /examples/perft/atomic.perft: -------------------------------------------------------------------------------- 1 | id atomic-start 2 | epd rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 3 | perft 1 20 4 | perft 2 400 5 | perft 3 8902 6 | perft 4 197326 7 | 8 | id programfox-1 9 | epd rn2kb1r/1pp1p2p/p2q1pp1/3P4/2P3b1/4PN2/PP3PPP/R2QKB1R b KQkq - 10 | perft 1 40 11 | perft 2 1238 12 | perft 3 45237 13 | perft 4 1434825 14 | 15 | id programfox-2 16 | epd rn1qkb1r/p5pp/2p5/3p4/N3P3/5P2/PPP4P/R1BQK3 w Qkq - 17 | perft 1 28 18 | perft 2 833 19 | perft 3 23353 20 | perft 4 714499 21 | 22 | id atomic960-castle-1 23 | epd 8/8/8/8/8/8/2k5/rR4KR w KQ - 24 | perft 1 18 25 | perft 2 180 26 | perft 3 4364 27 | perft 4 61401 28 | perft 5 1603055 29 | 30 | id atomic960-castle-2 31 | epd r3k1rR/5K2/8/8/8/8/8/8 b kq - 32 | perft 1 25 33 | perft 2 282 34 | perft 3 6753 35 | perft 4 98729 36 | perft 5 2587730 37 | 38 | id atomic960-castle-3 39 | epd Rr2k1rR/3K4/3p4/8/8/8/7P/8 w kq - 40 | perft 1 21 41 | perft 2 465 42 | perft 3 10631 43 | perft 4 241478 44 | perft 5 5800275 45 | 46 | id shakmaty-bench 47 | epd rn2kb1r/1pp1p2p/p2q1pp1/3P4/2P3b1/4PN2/PP3PPP/R2QKB1R b KQkq - 48 | perft 1 40 49 | perft 2 1238 50 | perft 3 45237 51 | perft 4 1434825 52 | -------------------------------------------------------------------------------- /docs/gaviota.rst: -------------------------------------------------------------------------------- 1 | Gaviota endgame tablebase probing 2 | ================================= 3 | 4 | Gaviota tablebases provide **WDL** (win/draw/loss) and **DTM** (depth to mate) 5 | information for all endgame positions with up to 5 pieces. Positions with 6 | castling rights are not included. 7 | 8 | .. warning:: 9 | Ensure tablebase files match the known checksums. Maliciously crafted 10 | tablebase files may cause denial of service with 11 | :class:`~chess.gaviota.PythonTablebase` and memory unsafety with 12 | :class:`~chess.gaviota.NativeTablebase`. 13 | 14 | .. autofunction:: chess.gaviota.open_tablebase 15 | 16 | .. autoclass:: chess.gaviota.PythonTablebase 17 | :members: 18 | 19 | libgtb 20 | ------ 21 | 22 | For faster access you can build and install 23 | a `shared library `_. 24 | Otherwise the pure Python probing code is used. 25 | 26 | .. code-block:: shell 27 | 28 | git clone https://github.com/michiguel/Gaviota-Tablebases.git 29 | cd Gaviota-Tablebases 30 | make 31 | sudo make install 32 | 33 | 34 | .. autofunction:: chess.gaviota.open_tablebase_native 35 | 36 | .. autoclass:: chess.gaviota.NativeTablebase 37 | :members: 38 | -------------------------------------------------------------------------------- /data/pgn/saturs-jannlee-zh-lichess.pgn: -------------------------------------------------------------------------------- 1 | [Event "Rated game"] 2 | [Site "https://lichess.org/l95HJ3fQ"] 3 | [Date "2016.11.27"] 4 | [White "saturos"] 5 | [Black "JannLee"] 6 | [Result "0-1"] 7 | [WhiteElo "2612"] 8 | [BlackElo "2789"] 9 | [PlyCount "122"] 10 | [Variant "Crazyhouse"] 11 | [TimeControl "60+1"] 12 | [ECO "?"] 13 | [Opening "?"] 14 | [Termination "Normal"] 15 | [Annotator "lichess.org"] 16 | 17 | 1. e4 e5 2. Nc3 Nc6 3. Nf3 Bc5 4. Bc4 Nf6 5. d3 O-O 6. O-O d6 7. Nd5 h6 8. Be3 Bg4 9. c3 Bxe3 10. fxe3 Nxd5 11. Bxd5 B@b6 12. d4 exd4 13. cxd4 P@e6 14. Bb3 Bxf3 15. Qxf3 Nxd4 16. exd4 Bxd4+ 17. Kh1 N@g5 18. Qh5 P@g6 19. Qe2 P@h3 20. gxh3 Nxh3 21. B@g3 P@h4 22. B@g2 hxg3 23. Bxh3 N@f2+ 24. Rxf2 gxf2 25. P@e3 R@g1+ 26. Rxg1 fxg1=Q+ 27. Kxg1 Bxe3+ 28. Qxe3 B@b6 29. P@d4 P@e5 30. P@c3 R@g5+ 31. B@g2 exd4 32. cxd4 e5 33. P@f2 Bxd4 34. Qd3 Qf6 35. R@f1 P@g4 36. N@d5 Qxf2+ 37. Rxf2 Bxf2+ 38. Kxf2 R@f4+ 39. Nxf4 exf4 40. B@d4 P@e5 41. N@e7+ Kh7 42. N@d5 P@f6 43. Bxg4 Rxg4 44. Qe2 B@h4+ 45. Kf1 Rxg2 46. Qxg2 N@g5 47. P@f5 B@h3 48. Qxh3 Nxh3 49. B@f2 Bxf2 50. Bxf2 B@d3+ 51. B@e2 Bxe2+ 52. Kxe2 f3+ 53. Kxf3 Ng5+ 54. Ke2 B@f3+ 55. Kd2 Q@e2+ 56. Kc3 Qxf2 57. Nxg6 Nxe4+ 58. Kd3 Qd2+ 59. Kc4 Qd4+ 60. Kb5 P@a6+ 61. Ka5 B@b6+ { White resigns } 0-1 18 | -------------------------------------------------------------------------------- /fuzz/corpus/pgn/saturs-jannlee-zh-lichess.pgn: -------------------------------------------------------------------------------- 1 | [Event "Rated game"] 2 | [Site "https://lichess.org/l95HJ3fQ"] 3 | [Date "2016.11.27"] 4 | [White "saturos"] 5 | [Black "JannLee"] 6 | [Result "0-1"] 7 | [WhiteElo "2612"] 8 | [BlackElo "2789"] 9 | [PlyCount "122"] 10 | [Variant "Crazyhouse"] 11 | [TimeControl "60+1"] 12 | [ECO "?"] 13 | [Opening "?"] 14 | [Termination "Normal"] 15 | [Annotator "lichess.org"] 16 | 17 | 1. e4 e5 2. Nc3 Nc6 3. Nf3 Bc5 4. Bc4 Nf6 5. d3 O-O 6. O-O d6 7. Nd5 h6 8. Be3 Bg4 9. c3 Bxe3 10. fxe3 Nxd5 11. Bxd5 B@b6 12. d4 exd4 13. cxd4 P@e6 14. Bb3 Bxf3 15. Qxf3 Nxd4 16. exd4 Bxd4+ 17. Kh1 N@g5 18. Qh5 P@g6 19. Qe2 P@h3 20. gxh3 Nxh3 21. B@g3 P@h4 22. B@g2 hxg3 23. Bxh3 N@f2+ 24. Rxf2 gxf2 25. P@e3 R@g1+ 26. Rxg1 fxg1=Q+ 27. Kxg1 Bxe3+ 28. Qxe3 B@b6 29. P@d4 P@e5 30. P@c3 R@g5+ 31. B@g2 exd4 32. cxd4 e5 33. P@f2 Bxd4 34. Qd3 Qf6 35. R@f1 P@g4 36. N@d5 Qxf2+ 37. Rxf2 Bxf2+ 38. Kxf2 R@f4+ 39. Nxf4 exf4 40. B@d4 P@e5 41. N@e7+ Kh7 42. N@d5 P@f6 43. Bxg4 Rxg4 44. Qe2 B@h4+ 45. Kf1 Rxg2 46. Qxg2 N@g5 47. P@f5 B@h3 48. Qxh3 Nxh3 49. B@f2 Bxf2 50. Bxf2 B@d3+ 51. B@e2 Bxe2+ 52. Kxe2 f3+ 53. Kxf3 Ng5+ 54. Ke2 B@f3+ 55. Kd2 Q@e2+ 56. Kc3 Qxf2 57. Nxg6 Nxe4+ 58. Kd3 Qd2+ 59. Kc4 Qd4+ 60. Kb5 P@a6+ 61. Ka5 B@b6+ { White resigns } 0-1 18 | -------------------------------------------------------------------------------- /examples/polyglot_tree.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """Print a Polyglot opening book in tree form.""" 4 | 5 | import argparse 6 | 7 | from typing import Set 8 | 9 | import chess 10 | import chess.polyglot 11 | 12 | 13 | def print_tree(args: argparse.Namespace, visited: Set[int], level: int = 0) -> None: 14 | if level >= args.depth: 15 | return 16 | 17 | zobrist_hash = chess.polyglot.zobrist_hash(args.board) 18 | if zobrist_hash in visited: 19 | return 20 | 21 | visited.add(zobrist_hash) 22 | 23 | for entry in args.book.find_all(zobrist_hash): 24 | print("{}├─ \033[1m{}\033[0m (weight: {}, learn: {})".format( 25 | "| " * level, 26 | args.board.san(entry.move), 27 | entry.weight, 28 | entry.learn)) 29 | 30 | args.board.push(entry.move) 31 | print_tree(args, visited, level + 1) 32 | args.board.pop() 33 | 34 | 35 | if __name__ == "__main__": 36 | parser = argparse.ArgumentParser(description=__doc__) 37 | parser.add_argument("book", type=chess.polyglot.open_reader) 38 | parser.add_argument("--depth", type=int, default=5) 39 | parser.add_argument("--fen", type=chess.Board, default=chess.Board(), dest="board") 40 | args = parser.parse_args() 41 | print_tree(args, visited=set()) 42 | -------------------------------------------------------------------------------- /data/pgn/chessbase-empty-line.pgn: -------------------------------------------------------------------------------- 1 | [Event "AlphaZero vs. Stockfish"] 2 | 3 | [Date "2017.12.04"] 4 | [Round "1"] 5 | [White "Stockfish 8"] 6 | [Black "AlphaZero"] 7 | [Result "0-1"] 8 | [Board "1"] 9 | [WhiteCountry "NOR"] 10 | [WhiteFideId "stockfish"] 11 | [BlackCountry "ENG"] 12 | [BlackFideId "deepmind"] 13 | 14 | 1. e4 e5 2. Nf3 Nc6 3. Bb5 Nf6 4. d3 Bc5 15 | 5. Bxc6 dxc6 6. O-O Nd7 7. Nbd2 O-O 8. 16 | Qe1 f6 9. Nc4 Rf7 10. a4 Bf8 11. Kh1 17 | Nc5 12. a5 Ne6 13. Ncxe5 18 | fxe5 14. Nxe5 Rf6 15. Ng4 Rf7 16. Ne5 19 | Re7 17. a6 c5 18. f4 Qe8 19. axb7 Bxb7 20 | 20. Qa5 Nd4 21. Qc3 Re6 22. Be3 Rb6 23. Nc4 21 | Rb4 24. b3 a5 25. Rxa5 Rxa5 26. Nxa5 Ba6 22 | 27. Bxd4 Rxd4 28. Nc4 Rd8 23 | 29. g3 h6 30. Qa5 Bc8 31. Qxc7 Bh3 32. 24 | Rg1 Rd7 33. Qe5 Qxe5 34. Nxe5 Ra7 35. Nc4 25 | g5 36. Rc1 Bg7 37. Ne5 Ra8 38. Nf3 Bb2 39. 26 | Rb1 Bc3 40. Ng1 Bd7 41. Ne2 Bd2 42. Rd1 27 | Be3 43. Kg2 Bg4 44. Re1 Bd2 45. Rf1 Ra2 46. 28 | h3 Bxe2 47. Rf2 Bxf4 48. Rxe2 Be5 49. Rf2 29 | Kg7 50. g4 Bd4 51. Re2 Kf6 52. e5+ Bxe5 53. 30 | Kf3 Ra1 54. Rf2 Re1 55. Kg2+ Bf4 56. c3 31 | Rc1 57. d4 Rxc3 58. dxc5 32 | Rxc5 59. b4 Rc3 60. h4 Ke5 61. hxg5 33 | hxg5 62. Re2+ Kf6 63. Kf2 34 | Be5 64. Ra2 Rc4 65. Ra6+ Ke7 66. Ra5 35 | Ke6 67. Ra6+ Bd6 0-1 36 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | # Import the chess module. 5 | sys.path.insert(0, os.path.abspath("..")) 6 | import chess 7 | 8 | # Do not resolve these. 9 | autodoc_type_aliases = { 10 | "Square": "chess.Square", 11 | "Color": "chess.Color", 12 | "PieceType": "chess.PieceType", 13 | "Bitboard": "chess.Bitboard", 14 | "IntoSquareSet": "chess.IntoSquareSet", 15 | } 16 | 17 | # Autodoc. 18 | extensions = [ 19 | "sphinx.ext.autodoc", 20 | "sphinx.ext.viewcode", 21 | "sphinx.ext.intersphinx", 22 | "sphinxcontrib.jquery" 23 | ] 24 | autodoc_member_order = "bysource" 25 | intersphinx_mapping = { 26 | "python": ("https://docs.python.org/3", None), 27 | } 28 | 29 | # The suffix of source filenames. 30 | source_suffix = ".rst" 31 | 32 | # The master toctree document. 33 | master_doc = "index" 34 | 35 | # General information about the project. 36 | project = "python-chess" 37 | copyright = "2014–2024, Niklas Fiekas" 38 | 39 | # The version. 40 | version = chess.__version__ 41 | release = chess.__version__ 42 | 43 | # List of patterns, relative to source directory, that match files and 44 | # directories to ignore when looking for source files. 45 | exclude_patterns = ["_build"] 46 | 47 | # The name of the Pygments (syntax highlighting) style to use. 48 | pygments_style = "sphinx" 49 | 50 | # The theme to use for HTML and HTML Help pages. See the documentation for 51 | # a list of built-in themes. 52 | html_theme = "sphinx_rtd_theme" 53 | -------------------------------------------------------------------------------- /fuzz/engine.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import logging 3 | 4 | import chess.engine 5 | 6 | from pythonfuzz.main import PythonFuzz 7 | 8 | 9 | logging.getLogger("chess.engine").setLevel(logging.CRITICAL) 10 | 11 | 12 | @PythonFuzz 13 | def fuzz(buf): 14 | lines = buf.split(b"!") 15 | 16 | class FuzzTransport: 17 | def __init__(self, protocol): 18 | self.protocol = protocol 19 | self.protocol.connection_made(self) 20 | 21 | def get_pipe_transport(self, fd): 22 | assert fd == 0, f"expected 0 for stdin, got {fd}" 23 | return self 24 | 25 | def write(self, data): 26 | if lines: 27 | self.protocol.pipe_data_received(1, lines.pop(0)) 28 | 29 | def get_pid(self) -> int: 30 | return id(self) 31 | 32 | def get_returncode(self): 33 | return 0 34 | 35 | async def main(): 36 | protocol = chess.engine.UciProtocol() 37 | transport = FuzzTransport(protocol) 38 | await asyncio.wait_for(protocol.initialize(), 0.1) 39 | await asyncio.wait_for(protocol.ping(), 0.1) 40 | await asyncio.wait_for(protocol.analysis(chess.Board(), chess.engine.Limit(nodes=1)), 0.1) 41 | 42 | try: 43 | asyncio.run(main()) 44 | except asyncio.TimeoutError: 45 | pass 46 | except UnicodeDecodeError: 47 | pass 48 | except chess.engine.EngineError: 49 | pass 50 | 51 | 52 | if __name__ == "__main__": 53 | fuzz() 54 | -------------------------------------------------------------------------------- /fuzz/corpus/engine/stockfish-10: -------------------------------------------------------------------------------- 1 | Stockfish 10 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott 2 | id name Stockfish 10 64 POPCNT 3 | id author T. Romstad, M. Costalba, J. Kiiski, G. Linscott 4 | 5 | option name Debug Log File type string default 6 | option name Contempt type spin default 24 min -100 max 100 7 | option name Analysis Contempt type combo default Both var Off var White var Black var Both 8 | option name Threads type spin default 1 min 1 max 512 9 | option name Hash type spin default 16 min 1 max 131072 10 | option name Clear Hash type button 11 | option name Ponder type check default false 12 | option name MultiPV type spin default 1 min 1 max 500 13 | option name Skill Level type spin default 20 min 0 max 20 14 | option name Move Overhead type spin default 30 min 0 max 5000 15 | option name Minimum Thinking Time type spin default 20 min 0 max 5000 16 | option name Slow Mover type spin default 84 min 10 max 1000 17 | option name nodestime type spin default 0 min 0 max 10000 18 | option name UCI_Chess960 type check default false 19 | option name UCI_AnalyseMode type check default false 20 | option name SyzygyPath type string default 21 | option name SyzygyProbeDepth type spin default 1 min 1 max 100 22 | option name Syzygy50MoveRule type check default true 23 | option name SyzygyProbeLimit type spin default 7 min 0 max 7 24 | uciok 25 | ! 26 | readyok 27 | ! 28 | ! 29 | ! 30 | info depth 1 seldepth 1 multipv 1 score cp 116 nodes 20 nps 20000 tbhits 0 time 1 pv e2e4 31 | info depth 2 seldepth 1 multipv 1 score cp 116 nodes 21 nps 21000 tbhits 0 time 1 pv e2e4 32 | bestmove e2e4 33 | ! 34 | -------------------------------------------------------------------------------- /data/endgame-dm-5.epd: -------------------------------------------------------------------------------- 1 | # 5 piece endgames for Gaviota tablebase testing. 2 | 3 | # Handpicked. 4 | 5 | 4k3/8/8/6Pp/n2K4/8/8/8 w - h6 dm 0; 6 | 4k3/8/8/6Pp/n2K4/8/8/8 w - - dm -21; 7 | 8 | # Endgames selected from 9 | # http://kirill-kryukov.com/chess/longest-checkmates/longest-checkmates.shtml 10 | # to cover all indexing schemes: 11 | # - kaaak_pctoindex krrrk 12 | # - kaabk_pctoindex krrnk 13 | # - kaakb_pctoindex knnkn 14 | # - kaakp_pctoindex knnkp 15 | # - kaapk_pctoindex krrpk 16 | # - kabbk_pctoindex kqbbk 17 | # - kabck_pctoindex kqrnk 18 | # - kabkc_pctoindex kbnkb 19 | # - kabkp_pctoindex krnkp 20 | # - kabpk_pctoindex krnpk 21 | # - kapkb_pctoindex krpkn 22 | # - kapkp_pctoindex kbpkp 23 | # - kappk_pctoindex knppk 24 | # - kppka_pctoindex kppkq 25 | # - kppkp_pctoindex kppkp 26 | # - kpppk_pctoindex kpppk 27 | 28 | 8/8/5k2/8/7p/8/PP6/1K6 w - - dm -13; 29 | K7/8/8/8/2k3P1/6P1/6P1/8 w - - dm 33; 30 | 7N/K5k1/8/8/8/6P1/6P1/8 w - - dm 32; 31 | 6k1/6NR/7P/8/8/8/8/K7 w - - dm 17; 32 | 8/K7/8/8/5k2/4RPR1/8/8 w - - dm 14; 33 | 8/8/6R1/6Nk/6R1/8/8/K7 w - - dm 10; 34 | 8/8/8/8/4k3/5R2/R7/RK6 w - - dm 5; 35 | 8/8/8/8/8/1B6/Q1B1k3/K7 w - - dm 6; 36 | Q7/N7/8/8/8/8/3k4/K1R5 w - - dm 5; 37 | 8/8/8/8/1p2P3/4P3/1k6/3K4 w - - dm 127; 38 | 8/4P3/7q/8/8/8/k1K1P3/8 w - - dm 124; 39 | 1N6/8/p7/8/8/8/2k1N3/K7 w - - dm 115; 40 | 7n/8/8/8/8/8/2NK4/1kN5 w - - dm 7; 41 | 8/7p/8/8/8/1B6/K6P/2k5 w - - dm 67; 42 | 8/7B/8/4N3/8/8/3k4/K1b5 w - - dm 39; 43 | 8/5n2/8/8/8/7k/7P/3K3R w - - dm 54; 44 | 8/8/8/4R3/8/2k3N1/3p4/K7 w - - dm 29; 45 | 8/8/7P/3K4/5p2/4p3/8/7k w - - dm 43; 46 | 8/8/7P/8/4n3/1k6/8/3K3n w - - dm 74; 47 | 3K4/8/1P6/8/6p1/8/4b3/7k w - - dm 51; 48 | 1n6/1K1P4/8/8/8/8/4r3/1k6 w - - dm 68; 49 | 8/8/8/8/n7/kn6/8/NK6 w - - dm 1; 50 | 8/8/8/8/3N4/p7/3r4/k1K5 w - - dm 8; 51 | 8/8/8/8/2n5/8/b7/k1K1B3 w - - dm 2; 52 | 8/8/8/2K5/5p2/8/1Q2pk2/8 w - - dm 41; 53 | -------------------------------------------------------------------------------- /data/suicide-dtm.epd: -------------------------------------------------------------------------------- 1 | 8/5P2/8/2r5/8/8/8/8 w - - bm f8=B; max_dtm 3; 2 | 8/8/8/8/8/8/8/3K2b1 b - - bm Bd4; max_dtm 3; 3 | 8/8/p7/8/8/8/7P/8 w - - bm h3; max_dtm 16; 4 | 2q5/3k4/8/8/8/5K2/8/8 w - - bm Ke4; max_dtm 4; 5 | 3n4/8/1k6/8/8/8/8/1B6 w - - bm Be4; max_dtm 3; 6 | 7K/8/3k4/5k2/8/8/8/8 b - - bm Kde6; max_dtm 4; 7 | 8/5P2/8/8/8/2n5/p7/8 w - - bm f8=B; max_dtm 10; 8 | 8/8/7P/8/8/8/4p3/5R2 b - - bm exf1=R; max_dtm 4; 9 | 8/8/8/6b1/1NR5/8/8/8 w - - bm Rc1; max_dtm 4; 10 | 8/8/8/8/1p6/7R/p7/8 b - - bm b3; max_dtm 4; 11 | 8/P7/8/8/1np5/8/8/8 w - - bm a8=R; max_dtm 6; 12 | 8/P7/8/8/8/5k2/8/7b w - - bm a8=K; max_dtm 6; 13 | 8/P7/8/k7/P7/8/8/8 w - - bm a8=N; max_dtm 4; 14 | 7r/1K2P3/8/8/8/8/7p/8 b - - bm Rc8; max_dtm 11; 15 | 8/5p2/7p/8/7P/8/5P2/8 w - - bm h5; max_dtm 0; 16 | 8/8/8/3R4/p7/3K4/k7/8 w - - bm Kc4; max_dtm 8; 17 | 8/8/8/4b3/8/1R5R/4P3/8 w - - bm Rb2; max_dtm 0; 18 | 8/8/8/8/5k1k/3k4/8/7K b - - bm Kde3; max_dtm 5; 19 | 8/8/8/KK6/8/6r1/1k6/8 w - - bm Kab4; max_dtm 4; 20 | 8/8/P4P2/8/8/2B5/7p/8 b - - bm h1=Q; max_dtm 6; 21 | 8/8/nk6/8/P7/5Q2/8/8 w - - bm a5; max_dtm 6; 22 | K7/8/4k3/k1k5/8/8/8/8 b - - bm Ked6; max_dtm 5; 23 | R7/8/8/4k3/8/2k2k2/8/8 b - - bm Kg2; max_dtm 7; 24 | 2R5/4P3/8/7n/8/8/pp6/8 b - - bm b1=B; max_dtm 13; 25 | 2r5/8/K3k3/8/4n3/3r4/8/8 b - - bm Rd4; max_dtm 8; 26 | 4k2B/5p1p/8/8/r7/8/8/8 b - - bm Ra1; max_dtm 6; 27 | 5B2/3p1k1p/5N2/8/8/8/8/8 w - - bm Nxh7; max_dtm 10; 28 | 6B1/8/7p/6k1/8/R7/7p/8 w - - bm Bd5; max_dtm 20; 29 | 6n1/n7/8/8/5P2/8/2P5/3R4 b - - bm Nc8; max_dtm 12; 30 | 8/8/5b2/8/1p6/8/2P4N/3R4 w - - bm Ra1; max_dtm 5; 31 | 8/8/7N/4n3/3k4/8/4P2K/8 w - - bm e4; max_dtm 5; 32 | 8/8/8/1r1P1r2/8/8/1P3P2/8 w - - bm d6; max_dtm 6; 33 | 3k4/8/8/8/2NNNN2/1N6/8/8 w - - bm Ng5; max_dtm 12; 34 | 6B1/8/8/8/1P6/3P4/3p1K2/6N1 b - - bm d1=B; max_dtm 5; 35 | 6n1/n7/8/5p2/4P3/8/2P5/4R3 b - - bm fxe4; max_dtm 12; 36 | 6n1/n7/8/5p2/8/4P3/2P5/4R3 w - - bm e4; max_dtm -12; 37 | 8/8/8/K7/8/1P3N2/P1n5/3N4 w - - bm Kb4; max_dtm 6; 38 | -------------------------------------------------------------------------------- /examples/bratko_kopec/bratko-kopec.epd: -------------------------------------------------------------------------------- 1 | 1k1r4/pp1b1R2/3q2pp/4p3/2B5/4Q3/PPP2B2/2K5 b - - bm Qd1+; id "BK.01"; 2 | 3r1k2/4npp1/1ppr3p/p6P/P2PPPP1/1NR5/5K2/2R5 w - - bm d5; id "BK.02"; 3 | 2q1rr1k/3bbnnp/p2p1pp1/2pPp3/PpP1P1P1/1P2BNNP/2BQ1PRK/7R b - - bm f5; id "BK.03"; 4 | rnbqkb1r/p3pppp/1p6/2ppP3/3N4/2P5/PPP1QPPP/R1B1KB1R w KQkq - bm e6; id "BK.04"; 5 | r1b2rk1/2q1b1pp/p2ppn2/1p6/3QP3/1BN1B3/PPP3PP/R4RK1 w - - bm Nd5 a4; id "BK.05"; 6 | 2r3k1/pppR1pp1/4p3/4P1P1/5P2/1P4K1/P1P5/8 w - - bm g6; id "BK.06"; 7 | 1nk1r1r1/pp2n1pp/4p3/q2pPp1N/b1pP1P2/B1P2R2/2P1B1PP/R2Q2K1 w - - bm Nf6; id "BK.07"; 8 | 4b3/p3kp2/6p1/3pP2p/2pP1P2/4K1P1/P3N2P/8 w - - bm f5; id "BK.08"; 9 | 2kr1bnr/pbpq4/2n1pp2/3p3p/3P1P1B/2N2N1Q/PPP3PP/2KR1B1R w - - bm f5; id "BK.09"; 10 | 3rr1k1/pp3pp1/1qn2np1/8/3p4/PP1R1P2/2P1NQPP/R1B3K1 b - - bm Ne5; id "BK.10"; 11 | 2r1nrk1/p2q1ppp/bp1p4/n1pPp3/P1P1P3/2PBB1N1/4QPPP/R4RK1 w - - bm f4; id "BK.11"; 12 | r3r1k1/ppqb1ppp/8/4p1NQ/8/2P5/PP3PPP/R3R1K1 b - - bm Bf5; id "BK.12"; 13 | r2q1rk1/4bppp/p2p4/2pP4/3pP3/3Q4/PP1B1PPP/R3R1K1 w - - bm b4; id "BK.13"; 14 | rnb2r1k/pp2p2p/2pp2p1/q2P1p2/8/1Pb2NP1/PB2PPBP/R2Q1RK1 w - - bm Qd2 Qe1; id "BK.14"; 15 | 2r3k1/1p2q1pp/2b1pr2/p1pp4/6Q1/1P1PP1R1/P1PN2PP/5RK1 w - - bm Qxg7+; id "BK.15"; 16 | r1bqkb1r/4npp1/p1p4p/1p1pP1B1/8/1B6/PPPN1PPP/R2Q1RK1 w kq - bm Ne4; id "BK.16"; 17 | r2q1rk1/1ppnbppp/p2p1nb1/3Pp3/2P1P1P1/2N2N1P/PPB1QP2/R1B2RK1 b - - bm h5; id "BK.17"; 18 | r1bq1rk1/pp2ppbp/2np2p1/2n5/P3PP2/N1P2N2/1PB3PP/R1B1QRK1 b - - bm Nb3; id "BK.18"; 19 | 3rr3/2pq2pk/p2p1pnp/8/2QBPP2/1P6/P5PP/4RRK1 b - - bm Rxe4; id "BK.19"; 20 | r4k2/pb2bp1r/1p1qp2p/3pNp2/3P1P2/2N3P1/PPP1Q2P/2KRR3 w - - bm g4; id "BK.20"; 21 | 3rn2k/ppb2rpp/2ppqp2/5N2/2P1P3/1P5Q/PB3PPP/3RR1K1 w - - bm Nh6; id "BK.21"; 22 | 2r2rk1/1bqnbpp1/1p1ppn1p/pP6/N1P1P3/P2B1N1P/1B2QPP1/R2R2K1 b - - bm Bxe4; id "BK.22"; 23 | r1bqk2r/pp2bppp/2p5/3pP3/P2Q1P2/2N1B3/1PP3PP/R4RK1 b kq - bm f6; id "BK.23"; 24 | r2qnrnk/p2b2b1/1p1p2pp/2pPpp2/1PP1P3/PRNBB3/3QNPPP/5RK1 w - - bm f4; id "BK.24"; 25 | -------------------------------------------------------------------------------- /data/endgame-dm-4.epd: -------------------------------------------------------------------------------- 1 | # 3 and 4 piece endgames for Gaviota tablebase testing. 2 | 3 | # Handpicked. 4 | 5 | 1k1K4/8/8/pP6/8/8/8/8 w - a6 dm 0; 6 | 4k3/8/8/2p5/8/6P1/6K1/8 w - c6 dm 0; 7 | 7K/k7/8/Pp6/8/8/8/8 w - - dm -15; 8 | 7K/k7/8/Pp6/8/8/8/8 w - b6 dm 0; 9 | 8/8/8/8/pP6/8/K7/7k b - - dm -15; 10 | 8/8/8/8/8/1p6/K7/7k w - - dm 0; 11 | 8/8/8/8/pP6/8/K7/7k b - b3 dm 0; 12 | 8/7k/8/8/3p4/1K6/2P5/8 b - - dm -19; 13 | 14 | # Long endgames. 15 | # Source: http://kirill-kryukov.com/chess/longest-checkmates/longest-checkmates.shtml 16 | 17 | 8/8/8/1k6/8/8/K5P1/8 w - - dm 28; 18 | 8/8/8/8/8/2k5/1R6/K7 w - - dm 16; 19 | 8/8/8/5k2/8/8/1Q6/K7 w - - dm 10; 20 | 8/8/8/8/8/2k3P1/6P1/K7 w - - dm 32; 21 | 8/8/8/8/8/4N3/3N4/K1k5 w - - dm 1; 22 | 8/7N/8/8/8/5k2/7P/K7 w - - dm 27; 23 | 8/3P4/KBk5/8/8/8/8/8 w - - dm 31; 24 | 8/8/7N/8/8/8/8/K1k1B3 w - - dm 33; 25 | 8/8/8/8/7B/8/3k4/K2B4 w - - dm 19; 26 | 8/8/1R6/2kP4/8/8/8/K7 w - - dm 16; 27 | 8/8/8/8/3N4/3k4/2R5/K7 w - - dm 16; 28 | 8/8/8/8/3B4/3k4/2R5/K7 w - - dm 16; 29 | 8/8/8/8/8/3k4/2R5/KR6 w - - dm 7; 30 | 8/8/8/3k4/8/4P3/8/K1Q5 w - - dm 10; 31 | 8/8/5k2/8/8/8/8/KN4Q1 w - - dm 9; 32 | 8/5B2/5k2/8/8/8/8/KQ6 w - - dm 8; 33 | 8/8/8/8/3k4/2R5/8/K6Q w - - dm 6; 34 | 1Q6/Q7/8/8/8/5k2/8/K7 w - - dm 4; 35 | 2K5/k7/7p/8/8/8/6P1/8 w - - dm 33; 36 | 8/8/8/k7/8/n7/K5P1/8 w - - dm 29; 37 | 8/8/8/k7/8/b7/K5P1/8 w - - dm 29; 38 | 8/5k2/2PK4/5r2/8/8/8/8 w - - dm 43; 39 | 8/8/8/k7/8/q7/K5P1/8 w - - dm 29; 40 | 8/8/8/8/p7/8/N7/k1K5 w - - dm 7; 41 | 8/8/8/8/8/8/n1K5/k1N5 w - - dm 1; 42 | 8/8/8/8/8/8/b7/k1K1N3 w - - dm 1; 43 | 8/8/8/8/8/8/r2N4/k1K5 w - - dm 1; 44 | 8/8/8/8/8/8/p7/k1K1B3 w - - dm 1; 45 | 8/8/8/8/8/8/n1K5/k1B5 w - - dm 1; 46 | 8/8/8/8/8/8/b7/k1K1B3 w - - dm 1; 47 | 8/8/K7/3p4/8/3k4/4R3/8 w - - dm 26; 48 | 8/2R5/8/8/7k/3K4/8/4n3 w - - dm 40; 49 | 8/8/8/8/8/2R5/8/3K1bk1 w - - dm 29; 50 | 8/8/8/8/8/1R6/6r1/K1k5 w - - dm 19; 51 | 8/8/8/8/8/1R6/6q1/K1k5 w - - dm 19; 52 | 3Q4/3K4/8/8/8/3k4/3p4/8 w - - dm 28; 53 | 8/8/8/8/8/2k5/2n5/KQ6 w - - dm 21; 54 | 8/6Q1/8/4b3/3k4/8/8/K7 w - - dm 17; 55 | 8/8/8/8/2r5/8/2k5/K6Q w - - dm 35; 56 | 8/8/8/8/8/8/8/qk1K2Q1 w - - dm 13; 57 | -------------------------------------------------------------------------------- /examples/xray_attacks.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """Compute X-ray attacks through more valuable pieces.""" 4 | 5 | import chess 6 | 7 | 8 | def xray_rook_attackers(board: chess.Board, color: chess.Color, square: chess.Square) -> chess.SquareSet: 9 | occupied = board.occupied 10 | rank_pieces = chess.BB_RANK_MASKS[square] & occupied 11 | file_pieces = chess.BB_FILE_MASKS[square] & occupied 12 | 13 | # Find the closest piece for each direction. These may block attacks. 14 | blockers = chess.BB_RANK_ATTACKS[square][rank_pieces] | chess.BB_FILE_ATTACKS[square][file_pieces] 15 | 16 | # Only consider blocking pieces of the victim that are more valuable 17 | # than rooks. 18 | blockers &= board.occupied_co[not color] & (board.queens | board.kings) 19 | 20 | # Now just ignore those blocking pieces. 21 | occupied ^= blockers 22 | 23 | # And compute rook attacks. 24 | rank_pieces = chess.BB_RANK_MASKS[square] & occupied 25 | file_pieces = chess.BB_FILE_MASKS[square] & occupied 26 | return chess.SquareSet(board.occupied_co[color] & board.rooks & ( 27 | chess.BB_RANK_ATTACKS[square][rank_pieces] | 28 | chess.BB_FILE_ATTACKS[square][file_pieces])) 29 | 30 | 31 | def xray_bishop_attackers(board: chess.Board, color: chess.Color, square: chess.Square) -> chess.SquareSet: 32 | occupied = board.occupied 33 | diag_pieces = chess.BB_DIAG_MASKS[square] & occupied 34 | 35 | # Find the closest piece for each direction. These may block attacks. 36 | blockers = chess.BB_DIAG_ATTACKS[square][diag_pieces] 37 | 38 | # Only consider blocking pieces of the victim that are more valuable 39 | # than bishops. 40 | blockers &= board.occupied_co[not color] & (board.rooks | board.queens | board.kings) 41 | 42 | # Now just ignore those blocking pieces. 43 | occupied ^= blockers 44 | 45 | # And compute bishop attacks. 46 | diag_pieces = chess.BB_DIAG_MASKS[square] & occupied 47 | return chess.SquareSet(board.occupied_co[color] & board.bishops & chess.BB_DIAG_ATTACKS[square][diag_pieces]) 48 | 49 | 50 | def example() -> None: 51 | board = chess.Board("r3k2r/pp3p2/4p2Q/4q1p1/4P3/P2PK3/6PP/R3R3 w q - 1 2") 52 | print("rook x-ray, black, h3:") 53 | print(xray_rook_attackers(board, chess.BLACK, chess.H3)) 54 | 55 | board = chess.Board("r1b1r1k1/pp1n1pbp/1qp3p1/B2p4/3P4/Q3PN2/PP2BPPP/R4RK1 b - - 0 1") 56 | print("bishop x-ray, white, d8:") 57 | print(xray_bishop_attackers(board, chess.WHITE, chess.D8)) 58 | 59 | 60 | if __name__ == "__main__": 61 | example() 62 | -------------------------------------------------------------------------------- /examples/push_san.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """Play the immortal game using push_san() from chess.Board().""" 4 | 5 | import chess 6 | import timeit 7 | 8 | 9 | def play_immortal_game() -> None: 10 | board = chess.Board() 11 | 12 | # 1. e4 e5 13 | board.push_san("e4") 14 | board.push_san("e5") 15 | 16 | # 2. f4 exf4 17 | board.push_san("f4") 18 | board.push_san("exf4") 19 | 20 | # 3. Bc4 Qh4+ 21 | board.push_san("Bc4") 22 | board.push_san("Qh4+") 23 | 24 | # 4. Kf1 b5?! 25 | board.push_san("Kf1") 26 | board.push_san("b5") 27 | 28 | # 5. Bxb5 Nf6 29 | board.push_san("Bxb5") 30 | board.push_san("Nf6") 31 | 32 | # 6. Nf3 Qh6 33 | board.push_san("Nf3") 34 | board.push_san("Qh6") 35 | 36 | # 7. d3 Nh5 37 | board.push_san("d3") 38 | board.push_san("Nh5") 39 | 40 | # 8. Nh4 Qg5 41 | board.push_san("Nh4") 42 | board.push_san("Qg5") 43 | 44 | # 9. Nf5 c6 45 | board.push_san("Nf5") 46 | board.push_san("c6") 47 | 48 | # 10. g4 Nf6 49 | board.push_san("g4") 50 | board.push_san("Nf6") 51 | 52 | # 11. Rg1! cxb5? 53 | board.push_san("Rg1") 54 | board.push_san("cxb5") 55 | 56 | # 12. h4! Qg6 57 | board.push_san("h4") 58 | board.push_san("Qg6") 59 | 60 | # 13. h5 Qg5 61 | board.push_san("h5") 62 | board.push_san("Qg5") 63 | 64 | # 14. Qf3 Ng8 65 | board.push_san("Qf3") 66 | board.push_san("Ng8") 67 | 68 | # 15. Bxf4 Qf6 69 | board.push_san("Bxf4") 70 | board.push_san("Qf6") 71 | 72 | # 16. Nc3 Bc5 73 | board.push_san("Nc3") 74 | board.push_san("Bc5") 75 | 76 | # 17. Nd5 Qxb2 77 | board.push_san("Nd5") 78 | board.push_san("Qxb2") 79 | 80 | # 18. Bd6! Bxg1? 81 | board.push_san("Bd6") 82 | board.push_san("Bxg1") 83 | 84 | # 19. e5! Qxa1+ 85 | board.push_san("e5") 86 | board.push_san("Qxa1+") 87 | 88 | # 20. Ke2 Na6 89 | board.push_san("Ke2") 90 | board.push_san("Na6") 91 | 92 | # 21. Nxg7+ Kd8 93 | board.push_san("Nxg7+") 94 | board.push_san("Kd8") 95 | 96 | # 22. Qf6+! Nxf6 97 | board.push_san("Qf6+") 98 | board.push_san("Nxf6") 99 | 100 | # 23. Be7# 1-0 101 | board.push_san("Be7#") 102 | assert board.is_checkmate() 103 | 104 | 105 | if __name__ == "__main__": 106 | print(timeit.timeit( 107 | stmt="play_immortal_game()", 108 | setup="from __main__ import play_immortal_game", 109 | number=100)) 110 | -------------------------------------------------------------------------------- /fuzz/corpus/engine/stockfish-mv-11: -------------------------------------------------------------------------------- 1 | Stockfish 11 64 BMI2 Multi-Variant by D. Dugovic, F. Fichter et al. 2 | id name Stockfish 11 64 BMI2 Multi-Variant 3 | id author D. Dugovic, F. Fichter et al. 4 | 5 | option name Debug Log File type string default 6 | option name Contempt type spin default 24 min -100 max 100 7 | option name Analysis Contempt type combo default Both var Both var Off var White var Black 8 | option name Threads type spin default 1 min 1 max 512 9 | option name Hash type spin default 16 min 1 max 131072 10 | option name Clear Hash type button 11 | option name Ponder type check default false 12 | option name MultiPV type spin default 1 min 1 max 500 13 | option name Skill Level type spin default 20 min 0 max 20 14 | option name Move Overhead type spin default 30 min 0 max 5000 15 | option name Minimum Thinking Time type spin default 20 min 0 max 5000 16 | option name Slow Mover type spin default 84 min 10 max 1000 17 | option name nodestime type spin default 0 min 0 max 10000 18 | option name UCI_Chess960 type check default false 19 | option name UCI_Variant type combo default chess var chess var antichess var atomic var crazyhouse var horde var kingofthehill var racingkings var 3check var giveaway 20 | option name UCI_AnalyseMode type check default false 21 | option name UCI_LimitStrength type check default false 22 | option name UCI_Elo type spin default 1350 min 1350 max 2850 23 | option name SyzygyPath type string default 24 | option name SyzygyProbeDepth type spin default 1 min 1 max 100 25 | option name Syzygy50MoveRule type check default true 26 | option name SyzygyProbeLimit type spin default 7 min 0 max 7 27 | uciok 28 | ! 29 | readyok 30 | ! 31 | ! 32 | ! 33 | info depth 1 seldepth 1 multipv 1 score cp 114 nodes 20 nps 10000 tbhits 0 time 2 pv e2e3 34 | info depth 2 seldepth 2 multipv 1 score cp 126 nodes 54 nps 27000 tbhits 0 time 2 pv e2e3 b7b6 35 | info depth 3 seldepth 3 multipv 1 score cp 124 nodes 147 nps 73500 tbhits 0 time 2 pv e2e3 b7b6 f1c4 36 | info depth 4 seldepth 4 multipv 1 score cp 75 nodes 574 nps 191333 tbhits 0 time 3 pv d2d4 e7e6 e2e3 b8c6 37 | info depth 5 seldepth 5 multipv 1 score cp 86 nodes 782 nps 195500 tbhits 0 time 4 pv c2c3 b8c6 d2d4 d7d6 38 | info depth 6 seldepth 6 multipv 1 score cp 56 nodes 2734 nps 341750 tbhits 0 time 8 pv d2d4 c7c6 g1f3 d7d5 c2c3 g8f6 39 | info depth 7 seldepth 8 multipv 1 score cp 43 nodes 5780 nps 525454 tbhits 0 time 11 pv c2c3 b8c6 d2d4 d7d5 e2e3 g8f6 f1e2 40 | info depth 8 seldepth 10 multipv 1 score cp 46 nodes 9568 nps 598000 tbhits 0 time 16 pv b1c3 d7d5 e2e4 d5e4 c3e4 c7c6 g1f3 g8f6 41 | info depth 9 seldepth 13 multipv 1 score cp 48 nodes 14134 nps 673047 tbhits 0 time 21 pv e2e4 d7d5 e4d5 d8d5 d2d4 d5e6 c1e3 g8f6 g1e2 b8c6 42 | info depth 10 seldepth 14 multipv 1 score cp 105 nodes 18613 nps 744520 tbhits 0 time 25 pv e2e4 e7e6 b1c3 b8c6 d2d4 d7d5 e4d5 e6d5 g1f3 43 | bestmove e2e4 ponder e7e6 44 | ! 45 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: [push, pull_request] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | test: 10 | strategy: 11 | matrix: 12 | os: [ubuntu-latest, windows-latest] 13 | python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] 14 | fail-fast: false 15 | runs-on: ${{ matrix.os }} 16 | steps: 17 | - uses: actions/checkout@v5 18 | - uses: actions/setup-python@v6 19 | with: 20 | python-version: ${{ matrix.python-version }} 21 | - run: .github/workflows/setup-${{ matrix.os }}.sh 22 | shell: bash 23 | - run: pip install -e . 24 | - run: python test.py -v 25 | perft: 26 | runs-on: ubuntu-latest 27 | steps: 28 | - uses: actions/checkout@v5 29 | - uses: actions/setup-python@v6 30 | with: 31 | python-version: "3.14" 32 | - run: pip install -e . 33 | - run: python examples/perft/perft.py -t 1 examples/perft/random.perft --max-nodes 10000 34 | - run: python examples/perft/perft.py -t 1 examples/perft/chess960.perft --max-nodes 100000 35 | - run: python examples/perft/perft.py -t 1 examples/perft/tricky.perft 36 | - run: python examples/perft/perft.py -t 1 --variant giveaway examples/perft/giveaway.perft 37 | - run: python examples/perft/perft.py -t 1 --variant atomic examples/perft/atomic.perft 38 | - run: python examples/perft/perft.py -t 1 --variant racingkings examples/perft/racingkings.perft 39 | - run: python examples/perft/perft.py -t 1 --variant horde examples/perft/horde.perft 40 | - run: python examples/perft/perft.py -t 1 --variant crazyhouse examples/perft/crazyhouse.perft 41 | - run: python examples/perft/perft.py -t 1 --variant 3check examples/perft/3check.perft 42 | typing: 43 | strategy: 44 | matrix: 45 | os: [ubuntu-latest, windows-latest] 46 | python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] 47 | fail-fast: false 48 | runs-on: ubuntu-latest 49 | steps: 50 | - uses: actions/checkout@v5 51 | - uses: actions/setup-python@v6 52 | with: 53 | python-version: ${{ matrix.python-version }} 54 | - run: pip install -e . 55 | - run: pip install mypy 56 | - run: python -m mypy --strict chess 57 | - run: python -m mypy --strict examples/**/*.py 58 | - run: pip install pyright 59 | - run: python -m pyright chess 60 | - run: python -m pyright examples/**/*.py 61 | readme: 62 | runs-on: ubuntu-latest 63 | steps: 64 | - uses: actions/checkout@v5 65 | - uses: actions/setup-python@v6 66 | with: 67 | python-version: "3.14" 68 | - run: sudo apt-get update && sudo apt-get install -y docutils-common 69 | - run: python setup.py --long-description | rst2html --strict --no-raw > /dev/null 70 | - run: pip install -e . 71 | - run: .github/workflows/setup-ubuntu-latest.sh 72 | - run: python -m doctest README.rst 73 | -------------------------------------------------------------------------------- /examples/bratko_kopec/giveaway-puzzles.epd: -------------------------------------------------------------------------------- 1 | % Giveaway variant testsuite from https://chessvariants.training/ 2 | 2b5/K1p1pk2/6pb/8/8/8/8/8 b - - bm Bb7; 3 | rnbqkbnr/p1pppp1p/1p4p1/8/8/1P2P1P1/P1PP1P1P/RNBQKBNR b KQkq - bm b5; 4 | 8/8/7P/8/8/8/4p3/5R2 b - - bm exf1=R; 5 | 8/8/8/K7/8/1P3N2/P1n5/3N4 w - - bm Kb4; 6 | 6n1/n7/8/8/5P2/8/2P5/3R4 b - - bm Nc6; 7 | 6B1/8/7p/6k1/8/R7/7p/8 w - - bm Bd5 Be6 Bf7; 8 | 6n1/n7/8/5p2/8/4P3/2P5/4R3 w - - bm e4; 9 | 6n1/n7/8/5p2/4P3/8/2P5/4R3 b - - bm fxe4; 10 | 8/P7/8/k7/P7/8/8/8 w - - bm a8=N; 11 | 8/8/8/4b3/8/1R5R/4P3/8 w - - bm Rb2; 12 | 8/8/p7/8/8/8/7P/8 w - - bm h3; 13 | 8/8/8/8/1p6/7R/p7/8 b - - bm b3; 14 | 8/5p2/7p/8/7P/8/5P2/8 w - - bm h5; 15 | 8/P7/8/8/8/5k2/8/7b w - - bm a8=K; 16 | 2q5/3k4/8/8/8/5K2/8/8 w - - bm Ke4; 17 | 8/8/8/6b1/1NR5/8/8/8 w - - bm Rc1; 18 | 8/P7/8/8/1np5/8/8/8 w - - bm a8=R; 19 | B2n4/pP6/1b6/8/8/8/8/8 w - - bm b8=Q; 20 | 8/5P2/8/2r5/8/8/8/8 w - - bm f8=B; 21 | 8/8/8/8/4k2P/8/8/1R6 w - - bm Rg1; 22 | 8/8/8/1r1P1r2/8/8/1P3P2/8 w - - bm d6; 23 | 8/5P2/8/8/8/2n5/p7/8 w - - bm f8=B; 24 | R7/8/8/4k3/8/2k2k2/8/8 b - - bm Kg2 Kg4; 25 | K7/8/4k3/k1k5/8/8/8/8 b - - bm Kd7; 26 | 2r5/8/K3k3/8/4n3/3r4/8/8 b - - bm Rc4; 27 | rnbqkbnr/pppppppp/8/8/8/3P4/PPP1PPPP/RNBQKBNR b KQkq - bm g5; 28 | rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - bm b5; 29 | rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq - bm e5; 30 | r2k2nr/5ppp/3bp3/8/8/8/3p2PP/5KNR w - - bm Ke2; 31 | rn2k3/8/p1p1P2p/2b5/8/7N/PP1N1PP1/R1B1K3 w Qq - bm Nb1; 32 | 8/8/4R3/8/8/1P6/1NP2Pp1/5R2 b - - bm gxf1=N; 33 | r7/p4P2/P7/1pP5/3PP3/6b1/6B1/8 w - - bm e5; 34 | 8/8/5b2/8/1p6/8/2P4N/3R4 w - - bm Ra1; 35 | 8/3nPp1p/7p/8/8/8/8/8 w - - bm e8=K; 36 | 5B2/3p1k1p/5N2/8/8/8/8/8 w - - bm Nxh7; 37 | 8/8/7N/4n3/3k4/8/4P2K/8 w - - bm e4; 38 | 8/8/nk6/8/P7/5Q2/8/8 w - - bm a5; 39 | 8/8/8/1p1K2K1/8/2K1K1KK/8/2K1K1KK w - - bm Kcd3 Kc3d2 K3b2; 40 | 8/B7/8/3p4/8/1N3P2/1K2P3/7R w - - bm Nc5; 41 | 8/8/8/8/5k1k/3k4/8/7K b - - bm Kde3 Ke2; 42 | 8/1b1P3k/2r5/1n2K1P1/8/8/8/8 w - - bm g6; 43 | 3n4/8/1k6/8/8/8/8/1B6 w - - bm Be4; 44 | 8/8/8/8/8/8/8/3K2b1 b - - bm Bd4; 45 | 3k4/8/8/8/2NNNN2/1N6/8/8 w - - bm Ng5; 46 | 8/8/P4P2/8/8/2B5/7p/8 b - - bm h1=Q; 47 | 8/1K6/7N/7P/P7/8/4PP2/4b3 w - - bm Nf5; 48 | rnbqk3/p1pppp2/1p4pb/8/8/8/PPPPPP2/RNBQKBN1 w Qq - bm Bg2; 49 | rn2qbn1/p1pppQ2/8/8/P7/8/3PbP1P/RNB1K2R w - - bm Kxe2; 50 | 6B1/8/8/8/1P6/3P4/3p1K2/6N1 b - - bm d1=B; 51 | rnbqkbn1/p1pppp2/1p4p1/8/6P1/8/PPPPPP1R/RNBQKBN1 b Qq - bm g5; 52 | rnbqkbn1/p1pppp2/1p4p1/8/6P1/1P6/P1PPPP1R/RNBQKBN1 b Qq - bm g5; 53 | rnbqkbn1/p1pppp2/8/1p6/6P1/8/PPPPPP1R/RNBQKBN1 b Qq - bm f5; 54 | rnbqkbn1/p1pppp2/8/1p6/6P1/1P6/P1PPPP1R/RNBQKBN1 b Qq - bm c6; 55 | rnbqkbn1/ppp1pp2/3p4/8/6P1/8/PPPPPP1R/RNBQKBN1 w Qq - bm a3; 56 | 4k2B/5p1p/8/8/r7/8/8/8 b - - bm Ra1; 57 | rnb1k1n1/p1p2pp1/4p3/7r/8/4P3/P1PB1PPP/R3K1NR w KQq - bm Bc3; 58 | 8/8/8/KK6/8/6r1/1k6/8 w - - bm Kab4; 59 | 7K/8/3k4/5k2/8/8/8/8 b - - bm Kde6 Ke7; 60 | 8/8/8/3R4/p7/3K4/k7/8 w - - bm Rb5; 61 | rnbq1bn1/p1ppp3/1p4k1/8/8/BP6/P1PPPK2/RN1Q4 b - - bm Bg7; 62 | 8/6PP/8/8/N7/8/3p4/5r2 w - - bm g8=B; 63 | 2R5/4P3/8/7n/8/8/pp6/8 b - - bm b1=B; 64 | r2k1bnr/p1pnpqpp/8/8/8/1P5N/P1PP3P/RNBK3R w - - bm Rg1; 65 | 8/4kp2/7r/3P1P2/8/6P1/2p5/4K3 b - - bm Rh4; 66 | 7r/1K2P3/8/8/8/8/7p/8 b - - bm Rc8; 67 | 8/4kp2/1p1p3n/8/8/B2PP3/3P1P2/1N6 b - - bm Kd8; 68 | -------------------------------------------------------------------------------- /examples/perft/tricky.perft: -------------------------------------------------------------------------------- 1 | # 2 | # Source: https://chessprogramming.wikispaces.com/Perft+Results 3 | # 4 | 5 | # Position 2: Kiwipete by Peter McKenzie. 6 | id pos-2 7 | epd r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 8 | perft 1 48 9 | perft 2 2039 10 | perft 3 97862 11 | 12 | # Position 3. 13 | id pos-3 14 | epd 8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 15 | perft 1 14 16 | perft 2 191 17 | perft 3 2812 18 | perft 4 43238 19 | 20 | # Position 4 (mirrored). 21 | id pos-4 22 | epd r2q1rk1/pP1p2pp/Q4n2/bbp1p3/Np6/1B3NBn/pPPP1PPP/R3K2R b KQ - 23 | perft 1 6 24 | perft 2 264 25 | perft 3 9467 26 | 27 | # Position 5: http://www.talkchess.com/forum/viewtopic.php?t=42463 28 | id pos-5 29 | epd rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 30 | perft 1 44 31 | perft 2 1486 32 | perft 3 62379 33 | 34 | # Position 6 by Steven Edwards. 35 | id pos-6 36 | epd r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 37 | perft 1 46 38 | perft 2 2079 39 | perft 3 89890 40 | 41 | 42 | # 43 | # Source: http://www.talkchess.com/forum/viewtopic.php?t=55274 44 | # 45 | 46 | id xfen-00 47 | epd r1k1r2q/p1ppp1pp/8/8/8/8/P1PPP1PP/R1K1R2Q w KQkq - 48 | perft 1 23 49 | perft 2 522 50 | perft 3 12333 51 | perft 4 285754 52 | 53 | id xfen-01 54 | epd r1k2r1q/p1ppp1pp/8/8/8/8/P1PPP1PP/R1K2R1Q w KQkq - 55 | perft 1 28 56 | perft 2 738 57 | perft 3 20218 58 | perft 4 541480 59 | 60 | id xfen-02 61 | epd 8/8/8/4B2b/6nN/8/5P2/2R1K2k w Q - 62 | perft 1 34 63 | perft 2 318 64 | perft 3 9002 65 | perft 4 118388 66 | 67 | id xfen-03 68 | epd 2r5/8/8/8/8/8/6PP/k2KR3 w K - 69 | perft 1 17 70 | perft 2 242 71 | perft 3 3931 72 | perft 4 57700 73 | 74 | id xfen-04 75 | epd 4r3/3k4/8/8/8/8/6PP/qR1K1R2 w KQ - 76 | perft 1 19 77 | perft 2 628 78 | perft 3 12858 79 | perft 4 405636 80 | 81 | # 82 | # Source: http://talkchess.com/forum3/viewtopic.php?f=7&t=71379 83 | # 84 | 85 | id gotta-love-perft-1 86 | epd 8/ppp3p1/8/8/3p4/5Q2/1ppp2K1/brk4n w - - 87 | perft 1 27 88 | perft 2 390 89 | perft 3 9354 90 | perft 4 134167 91 | 92 | id gotta-love-perft-2 93 | epd 8/6kR/8/8/8/bq6/1rqqqqqq/K1nqnbrq b - - 94 | perft 1 7 95 | perft 2 52 96 | perft 3 4593 97 | perft 4 50268 98 | 99 | # 100 | # Impossible checker alignment. 101 | # 102 | 103 | id align-diag-1 104 | epd 3R4/8/q4k2/2B5/1NK5/3b4/8/8 w - - 105 | perft 1 4 106 | perft 2 125 107 | perft 3 2854 108 | 109 | id align-diag-2 110 | epd 2Nq4/2K5/1b6/8/7R/3k4/7P/8 w - - 111 | perft 1 3 112 | perft 2 81 113 | perft 3 1217 114 | 115 | id align-horizontal 116 | epd 5R2/2P5/8/4k3/8/3rK2r/8/8 w - - 117 | perft 1 2 118 | perft 2 56 119 | perft 3 1030 120 | 121 | id align-ep 122 | epd 8/8/8/1k6/3Pp3/8/8/4KQ2 b - d3 123 | perft 1 6 124 | perft 2 121 125 | perft 3 711 126 | 127 | id align-ep-pinned 128 | epd 1b1k4/8/8/1rPpK3/8/8/8/8 w - d6 129 | perft 1 5 130 | perft 2 100 131 | perft 3 555 132 | 133 | id ep-unrelated-check 134 | epd rnbqk1nr/bb3p1p/1q2r3/2pPp3/3P4/7P/1PP1NpPP/R1BQKBNR w KQkq c6 135 | perft 1 2 136 | perft 2 92 137 | perft 3 2528 138 | 139 | # 140 | # Impossible castling rights 141 | # 142 | 143 | id asymmetrical-and-king-on-h 144 | epd r2r3k/p7/3p4/8/8/P6P/8/R3K2R b KQq - 145 | perft 1 14 146 | perft 2 206 147 | perft 3 3672 148 | perft 4 64639 149 | perft 5 1320962 150 | -------------------------------------------------------------------------------- /docs/pgn.rst: -------------------------------------------------------------------------------- 1 | PGN parsing and writing 2 | ======================= 3 | 4 | Parsing 5 | ------- 6 | 7 | .. autofunction:: chess.pgn.read_game 8 | 9 | Writing 10 | ------- 11 | 12 | If you want to export your game with all headers, comments and variations, 13 | you can do it like this: 14 | 15 | >>> import chess 16 | >>> import chess.pgn 17 | >>> 18 | >>> game = chess.pgn.Game() 19 | >>> game.headers["Event"] = "Example" 20 | >>> node = game.add_variation(chess.Move.from_uci("e2e4")) 21 | >>> node = node.add_variation(chess.Move.from_uci("e7e5")) 22 | >>> node.comment = "Comment" 23 | >>> 24 | >>> print(game) 25 | [Event "Example"] 26 | [Site "?"] 27 | [Date "????.??.??"] 28 | [Round "?"] 29 | [White "?"] 30 | [Black "?"] 31 | [Result "*"] 32 | 33 | 1. e4 e5 { Comment } * 34 | 35 | Remember that games in files should be separated with extra blank lines. 36 | 37 | >>> print(game, file=open("/dev/null", "w"), end="\n\n") 38 | 39 | Use the :class:`~chess.pgn.StringExporter()` or 40 | :class:`~chess.pgn.FileExporter()` visitors if you need more control. 41 | 42 | Game model 43 | ---------- 44 | 45 | Games are represented as a tree of moves. Conceptually each node represents a 46 | position of the game. The tree consists of one root node 47 | (:class:`~chess.pgn.Game`, also holding game headers) and many child 48 | nodes (:class:`~chess.pgn.ChildNode`). 49 | Both extend :class:`~chess.pgn.GameNode`. 50 | 51 | .. note:: Some basic methods have complexity `O(n)` for a game with n moves. 52 | When following a variation, it is often more efficient to use visitors 53 | or incrementally update state (like board, ply counter, or turn). 54 | 55 | .. autoclass:: chess.pgn.GameNode 56 | :members: 57 | 58 | .. autoclass:: chess.pgn.Game 59 | :members: headers, errors, setup, accept, from_board, without_tag_roster 60 | 61 | .. autoclass:: chess.pgn.ChildNode 62 | :members: parent, move, starting_comment, nags, san, uci, end 63 | 64 | Visitors 65 | -------- 66 | 67 | Visitors are an advanced concept for game tree traversal. 68 | 69 | .. autoclass:: chess.pgn.BaseVisitor 70 | :members: 71 | 72 | The following visitors are readily available. 73 | 74 | .. autoclass:: chess.pgn.GameBuilder 75 | :members: handle_error, result 76 | 77 | .. autoclass:: chess.pgn.HeadersBuilder 78 | 79 | .. autoclass:: chess.pgn.BoardBuilder 80 | 81 | .. autoclass:: chess.pgn.SkipVisitor 82 | 83 | .. autoclass:: chess.pgn.StringExporter 84 | 85 | .. autoclass:: chess.pgn.FileExporter 86 | 87 | NAGs 88 | ---- 89 | 90 | Numeric anotation glyphs describe moves and positions using standardized codes 91 | that are understood by many chess programs. During PGN parsing, annotations 92 | like ``!``, ``?``, ``!!``, etc., are also converted to NAGs. 93 | 94 | .. autodata:: chess.pgn.NAG_GOOD_MOVE 95 | .. autodata:: chess.pgn.NAG_MISTAKE 96 | .. autodata:: chess.pgn.NAG_BRILLIANT_MOVE 97 | .. autodata:: chess.pgn.NAG_BLUNDER 98 | .. autodata:: chess.pgn.NAG_SPECULATIVE_MOVE 99 | .. autodata:: chess.pgn.NAG_DUBIOUS_MOVE 100 | 101 | Skimming 102 | -------- 103 | 104 | These functions allow for quickly skimming games without fully parsing them. 105 | 106 | .. autofunction:: chess.pgn.read_headers 107 | 108 | .. autofunction:: chess.pgn.skip_game 109 | -------------------------------------------------------------------------------- /data/gaviota/TEST-SOURCE.txt: -------------------------------------------------------------------------------- 1 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbbk.gtb.cp4 2 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbkb.gtb.cp4 3 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbkn.gtb.cp4 4 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbkp.gtb.cp4 5 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbnk.gtb.cp4 6 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbpk.gtb.cp4 7 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knkn.gtb.cp4 8 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knkp.gtb.cp4 9 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnk.gtb.cp4 10 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knpk.gtb.cp4 11 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kpkp.gtb.cp4 12 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kppk.gtb.cp4 13 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbk.gtb.cp4 14 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqkb.gtb.cp4 15 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqkn.gtb.cp4 16 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqkp.gtb.cp4 17 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqkq.gtb.cp4 18 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqkr.gtb.cp4 19 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqnk.gtb.cp4 20 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqpk.gtb.cp4 21 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqk.gtb.cp4 22 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrk.gtb.cp4 23 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krbk.gtb.cp4 24 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krkb.gtb.cp4 25 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krkn.gtb.cp4 26 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krkp.gtb.cp4 27 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krkr.gtb.cp4 28 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnk.gtb.cp4 29 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krpk.gtb.cp4 30 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrk.gtb.cp4 31 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrnk.gtb.cp4 32 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krpkn.gtb.cp4 33 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbpkp.gtb.cp4 34 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrpk.gtb.cp4 35 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knppk.gtb.cp4 36 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbnkb.gtb.cp4 37 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnkn.gtb.cp4 38 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrnk.gtb.cp4 39 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbbk.gtb.cp4 40 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kppkp.gtb.cp4 41 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kppkq.gtb.cp4 42 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrrk.gtb.cp4 43 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnkp.gtb.cp4 44 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kpppk.gtb.cp4 45 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnkp.gtb.cp4 46 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnpk.gtb.cp4 47 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knpkp.gtb.cp4 48 | -------------------------------------------------------------------------------- /data/pgn/knightvuillaume-jannlee-zh-lichess.pgn: -------------------------------------------------------------------------------- 1 | [Event "Crazyhouse Bullet Arena"] 2 | [Site "https://lichess.org/R4GSdrpV"] 3 | [Date "2017.04.25"] 4 | [White "knightvuillaume"] 5 | [Black "JannLee"] 6 | [Result "0-1"] 7 | [WhiteElo "1608"] 8 | [BlackElo "2774"] 9 | [PlyCount "48"] 10 | [Variant "Crazyhouse"] 11 | [TimeControl "60+0"] 12 | [ECO "?"] 13 | [Opening "?"] 14 | [Termination "Normal"] 15 | [Annotator "lichess.org"] 16 | 17 | 1. d4 { [%clk 0:01:00] } d5 { [%clk 0:01:00] } 2. Nc3 { [%clk 0:01:00] } Bf5 { [%clk 0:01:00] } 3. e3 { [%clk 0:00:59] } e6 { [%clk 0:00:59] } 4. Bd3 { [%clk 0:00:59] } Bg6?! { (0.00 → 0.75) Inaccuracy. Best move was Nf6. } { [%clk 0:00:59] } (4... Nf6) 5. Nf3 { [%clk 0:00:57] } Bd6? { (0.70 → 1.99) Mistake. Best move was Nf6. } { [%clk 0:00:59] } (5... Nf6 6. O-O Bd6 7. Bxg6 hxg6 8. Ne5 O-O 9. B@f4 B@h4 10. Nf3 Bxf4 11. exf4 B@g4 12. B@g5) 6. O-O? { (1.99 → 0.50) Mistake. Best move was e4. } { [%clk 0:00:56] } (6. e4 dxe4 7. Nxe4 Nc6 8. O-O P@g4 9. Nxd6+ cxd6 10. Bxg6 hxg6 11. Ng5 B@f6 12. Qxg4 Nxd4) 6... Ne7? { (0.50 → 1.56) Mistake. Best move was Nf6. } { [%clk 0:00:59] } (6... Nf6 7. Bxg6 hxg6 8. B@e5 B@g4 9. Bxd6 cxd6 10. B@e2 O-O 11. Nd2 Bxe2 12. Nxe2 B@g4 13. f3) 7. g3? { (1.56 → -0.90) Mistake. Best move was e4. } { [%clk 0:00:55] } (7. e4 O-O) 7... Nbc6?! { (-0.90 → -0.34) Inaccuracy. Best move was Bxd3. } { [%clk 0:00:58] } (7... Bxd3 8. cxd3 B@g4 9. B@g2 O-O 10. e4 Nbc6 11. Be3 dxe4 12. dxe4 P@h3 13. Bxh3 Bxh3 14. P@g2) 8. Re1? { (-0.34 → -1.67) Mistake. Best move was e4. } { [%clk 0:00:53] } (8. e4 O-O 9. exd5 Nxd5 10. Bxg6 hxg6 11. B@h4 Nxc3 12. bxc3 N@h3+ 13. Kg2 f6 14. Kxh3 P@g4+) 8... O-O { [%clk 0:00:58] } 9. Ne2? { (-1.54 → -4.23) Mistake. Best move was Bxg6. } { [%clk 0:00:52] } (9. Bxg6) 9... e5? { (-4.23 → -2.33) Mistake. Best move was Nb4. } { [%clk 0:00:56] } (9... Nb4) 10. dxe5?! { (-2.33 → -2.87) Inaccuracy. Best move was Bxg6. } { [%clk 0:00:51] } (10. Bxg6) 10... Nxe5 { [%clk 0:00:56] } 11. Nxe5 { [%clk 0:00:51] } Bxe5 { [%clk 0:00:56] } 12. f4?? { (-2.17 → -8.28) Blunder. Best move was P@g2. } { [%clk 0:00:50] } (12. P@g2 P@e4 13. N@g4 Bd6 14. Nf4 exd3 15. cxd3 B@g5 16. Nxg6 Nxg6 17. B@c3 h5 18. P@f5 hxg4) 12... N@f3+ { [%clk 0:00:53] } 13. Kg2? { (-7.69 → -9.81) Mistake. Best move was Kf2. } { [%clk 0:00:48] } (13. Kf2 Nxh2 14. Ng1 P@f3 15. fxe5 Ng4+ 16. Kxf3 P@h2 17. B@h3 h1=Q+ 18. P@g2 Qxh3 19. gxh3 B@e4+) 13... Nxe1+ { [%clk 0:00:52] } 14. Qxe1 { [%clk 0:00:48] } Bd6?? { (-9.90 → -4.96) Blunder. Best move was Be4+. } { [%clk 0:00:49] } (14... Be4+ 15. P@f3) 15. P@f3?? { (-4.96 → -9.72) Blunder. Best move was Ng1. } { [%clk 0:00:45] } (15. Ng1 Bxd3) 15... P@e4 { [%clk 0:00:48] } 16. fxe4?! { (-9.12 → -10.91) Inaccuracy. Best move was N@h6+. } { [%clk 0:00:44] } (16. N@h6+ Kh8) 16... dxe4 { [%clk 0:00:48] } 17. Bc4 { [%clk 0:00:43] } P@f3+ { [%clk 0:00:47] } 18. Kf2 { [%clk 0:00:42] } fxe2 { [%clk 0:00:46] } 19. Qxe2 { [%clk 0:00:42] } N@h3+ { [%clk 0:00:45] } 20. Kg2 { [%clk 0:00:41] } R@f2+ { [%clk 0:00:43] } 21. Qxf2 { [%clk 0:00:40] } Nxf2 { [%clk 0:00:43] } 22. Kxf2 { [%clk 0:00:40] } Q@f3+ { [%clk 0:00:43] } 23. Ke1?! { (-24.75 → Mate in 8) Checkmate is now unavoidable. Best move was Kg1. } { [%clk 0:00:39] } (23. Kg1 Bxf4) 23... Bxf4?! { (Mate in 8 → -23.58) Lost forced checkmate sequence. Best move was Bb4+. } { [%clk 0:00:43] } (23... Bb4+ 24. P@d2 Bxd2+ 25. Bxd2 P@f2+ 26. Kf1 Qxd2 27. N@h6+ Kh8 28. Nxf7+ Rxf7 29. R@f8+ Raxf8 30. Bxf7) 24. gxf4?! { (-23.58 → Mate in 1) Checkmate is now unavoidable. Best move was P@d3. } { [%clk 0:00:37] } (24. P@d3 exd3) 24... Qdd1# { [%clk 0:00:42] } { Black wins by checkmate. } 0-1 18 | -------------------------------------------------------------------------------- /fuzz/corpus/pgn/knightvuillaume-jannlee-zh-lichess.pgn: -------------------------------------------------------------------------------- 1 | [Event "Crazyhouse Bullet Arena"] 2 | [Site "https://lichess.org/R4GSdrpV"] 3 | [Date "2017.04.25"] 4 | [White "knightvuillaume"] 5 | [Black "JannLee"] 6 | [Result "0-1"] 7 | [WhiteElo "1608"] 8 | [BlackElo "2774"] 9 | [PlyCount "48"] 10 | [Variant "Crazyhouse"] 11 | [TimeControl "60+0"] 12 | [ECO "?"] 13 | [Opening "?"] 14 | [Termination "Normal"] 15 | [Annotator "lichess.org"] 16 | 17 | 1. d4 { [%clk 0:01:00] } d5 { [%clk 0:01:00] } 2. Nc3 { [%clk 0:01:00] } Bf5 { [%clk 0:01:00] } 3. e3 { [%clk 0:00:59] } e6 { [%clk 0:00:59] } 4. Bd3 { [%clk 0:00:59] } Bg6?! { (0.00 → 0.75) Inaccuracy. Best move was Nf6. } { [%clk 0:00:59] } (4... Nf6) 5. Nf3 { [%clk 0:00:57] } Bd6? { (0.70 → 1.99) Mistake. Best move was Nf6. } { [%clk 0:00:59] } (5... Nf6 6. O-O Bd6 7. Bxg6 hxg6 8. Ne5 O-O 9. B@f4 B@h4 10. Nf3 Bxf4 11. exf4 B@g4 12. B@g5) 6. O-O? { (1.99 → 0.50) Mistake. Best move was e4. } { [%clk 0:00:56] } (6. e4 dxe4 7. Nxe4 Nc6 8. O-O P@g4 9. Nxd6+ cxd6 10. Bxg6 hxg6 11. Ng5 B@f6 12. Qxg4 Nxd4) 6... Ne7? { (0.50 → 1.56) Mistake. Best move was Nf6. } { [%clk 0:00:59] } (6... Nf6 7. Bxg6 hxg6 8. B@e5 B@g4 9. Bxd6 cxd6 10. B@e2 O-O 11. Nd2 Bxe2 12. Nxe2 B@g4 13. f3) 7. g3? { (1.56 → -0.90) Mistake. Best move was e4. } { [%clk 0:00:55] } (7. e4 O-O) 7... Nbc6?! { (-0.90 → -0.34) Inaccuracy. Best move was Bxd3. } { [%clk 0:00:58] } (7... Bxd3 8. cxd3 B@g4 9. B@g2 O-O 10. e4 Nbc6 11. Be3 dxe4 12. dxe4 P@h3 13. Bxh3 Bxh3 14. P@g2) 8. Re1? { (-0.34 → -1.67) Mistake. Best move was e4. } { [%clk 0:00:53] } (8. e4 O-O 9. exd5 Nxd5 10. Bxg6 hxg6 11. B@h4 Nxc3 12. bxc3 N@h3+ 13. Kg2 f6 14. Kxh3 P@g4+) 8... O-O { [%clk 0:00:58] } 9. Ne2? { (-1.54 → -4.23) Mistake. Best move was Bxg6. } { [%clk 0:00:52] } (9. Bxg6) 9... e5? { (-4.23 → -2.33) Mistake. Best move was Nb4. } { [%clk 0:00:56] } (9... Nb4) 10. dxe5?! { (-2.33 → -2.87) Inaccuracy. Best move was Bxg6. } { [%clk 0:00:51] } (10. Bxg6) 10... Nxe5 { [%clk 0:00:56] } 11. Nxe5 { [%clk 0:00:51] } Bxe5 { [%clk 0:00:56] } 12. f4?? { (-2.17 → -8.28) Blunder. Best move was P@g2. } { [%clk 0:00:50] } (12. P@g2 P@e4 13. N@g4 Bd6 14. Nf4 exd3 15. cxd3 B@g5 16. Nxg6 Nxg6 17. B@c3 h5 18. P@f5 hxg4) 12... N@f3+ { [%clk 0:00:53] } 13. Kg2? { (-7.69 → -9.81) Mistake. Best move was Kf2. } { [%clk 0:00:48] } (13. Kf2 Nxh2 14. Ng1 P@f3 15. fxe5 Ng4+ 16. Kxf3 P@h2 17. B@h3 h1=Q+ 18. P@g2 Qxh3 19. gxh3 B@e4+) 13... Nxe1+ { [%clk 0:00:52] } 14. Qxe1 { [%clk 0:00:48] } Bd6?? { (-9.90 → -4.96) Blunder. Best move was Be4+. } { [%clk 0:00:49] } (14... Be4+ 15. P@f3) 15. P@f3?? { (-4.96 → -9.72) Blunder. Best move was Ng1. } { [%clk 0:00:45] } (15. Ng1 Bxd3) 15... P@e4 { [%clk 0:00:48] } 16. fxe4?! { (-9.12 → -10.91) Inaccuracy. Best move was N@h6+. } { [%clk 0:00:44] } (16. N@h6+ Kh8) 16... dxe4 { [%clk 0:00:48] } 17. Bc4 { [%clk 0:00:43] } P@f3+ { [%clk 0:00:47] } 18. Kf2 { [%clk 0:00:42] } fxe2 { [%clk 0:00:46] } 19. Qxe2 { [%clk 0:00:42] } N@h3+ { [%clk 0:00:45] } 20. Kg2 { [%clk 0:00:41] } R@f2+ { [%clk 0:00:43] } 21. Qxf2 { [%clk 0:00:40] } Nxf2 { [%clk 0:00:43] } 22. Kxf2 { [%clk 0:00:40] } Q@f3+ { [%clk 0:00:43] } 23. Ke1?! { (-24.75 → Mate in 8) Checkmate is now unavoidable. Best move was Kg1. } { [%clk 0:00:39] } (23. Kg1 Bxf4) 23... Bxf4?! { (Mate in 8 → -23.58) Lost forced checkmate sequence. Best move was Bb4+. } { [%clk 0:00:43] } (23... Bb4+ 24. P@d2 Bxd2+ 25. Bxd2 P@f2+ 26. Kf1 Qxd2 27. N@h6+ Kh8 28. Nxf7+ Rxf7 29. R@f8+ Raxf8 30. Bxf7) 24. gxf4?! { (-23.58 → Mate in 1) Checkmate is now unavoidable. Best move was P@d3. } { [%clk 0:00:37] } (24. P@d3 exd3) 24... Qdd1# { [%clk 0:00:42] } { Black wins by checkmate. } 0-1 18 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import platform 6 | import re 7 | import sys 8 | import textwrap 9 | 10 | import setuptools 11 | 12 | 13 | if sys.version_info < (3, ): 14 | raise ImportError(textwrap.dedent("""\ 15 | You are trying to install python-chess on Python 2. 16 | 17 | The last compatible branch was 0.23.x, which was supported until the 18 | end of 2018. Consider upgrading to Python 3. 19 | """)) 20 | 21 | if sys.version_info < (3, 8): 22 | raise ImportError(textwrap.dedent("""\ 23 | You are trying to install python-chess. 24 | 25 | Since version 1.11.0, python-chess requires Python 3.8 or later. 26 | Since version 1.0.0, python-chess requires Python 3.7 or later. 27 | """)) 28 | 29 | import chess 30 | 31 | 32 | def read_description(): 33 | """ 34 | Reads the description from README.rst and substitutes mentions of the 35 | latest version with a concrete version number. 36 | """ 37 | with open(os.path.join(os.path.dirname(__file__), "README.rst"), encoding="utf-8") as f: 38 | description = f.read() 39 | 40 | # Link to the documentation of the specific version. 41 | description = description.replace( 42 | "//python-chess.readthedocs.io/en/latest/", 43 | "//python-chess.readthedocs.io/en/v{}/".format(chess.__version__)) 44 | 45 | # Use documentation badge for the specific version. 46 | description = description.replace( 47 | "//readthedocs.org/projects/python-chess/badge/?version=latest", 48 | "//readthedocs.org/projects/python-chess/badge/?version=v{}".format(chess.__version__)) 49 | 50 | # Remove doctest comments. 51 | description = re.sub(r"\s*# doctest:.*", "", description) 52 | 53 | return description 54 | 55 | 56 | setuptools.setup( 57 | name="chess", 58 | version=chess.__version__, 59 | author=chess.__author__, 60 | author_email=chess.__email__, 61 | description=chess.__doc__.replace("\n", " ").strip(), 62 | long_description=read_description(), 63 | long_description_content_type="text/x-rst", 64 | license="GPL-3.0+", 65 | keywords="chess fen epd pgn polyglot syzygy gaviota uci xboard", 66 | url="https://github.com/niklasf/python-chess", 67 | packages=["chess"], 68 | test_suite="test", 69 | zip_safe=False, # For mypy 70 | package_data={ 71 | "chess": ["py.typed"], 72 | }, 73 | python_requires=">=3.8", 74 | classifiers=[ 75 | "Development Status :: 5 - Production/Stable", 76 | "Intended Audience :: Developers", 77 | "Intended Audience :: Science/Research", 78 | "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", 79 | "Operating System :: OS Independent", 80 | "Programming Language :: Python :: 3 :: Only", 81 | "Programming Language :: Python :: 3.8", 82 | "Programming Language :: Python :: 3.9", 83 | "Programming Language :: Python :: 3.10", 84 | "Programming Language :: Python :: 3.11", 85 | "Programming Language :: Python :: 3.12", 86 | "Programming Language :: Python :: 3.13", 87 | "Programming Language :: Python :: 3.14", 88 | "Topic :: Games/Entertainment :: Board Games", 89 | "Topic :: Games/Entertainment :: Turn Based Strategy", 90 | "Topic :: Software Development :: Libraries :: Python Modules", 91 | "Typing :: Typed", 92 | ], 93 | project_urls={ 94 | "Documentation": "https://python-chess.readthedocs.io", 95 | }, 96 | obsoletes=["python_chess"], 97 | ) 98 | -------------------------------------------------------------------------------- /data/pgn/stockfish-learning.pgn: -------------------------------------------------------------------------------- 1 | [Event "?"] 2 | [Site "?"] 3 | [Date "2019.01.14"] 4 | [Round "1"] 5 | [White "Stockfish-reference"] 6 | [Black "Stockfish-learning"] 7 | [Result "1-0"] 8 | [ECO "B00"] 9 | [Opening "St. George (Baker) defense"] 10 | [GameDuration "00:40:54"] 11 | [GameEndTime "2019-01-14T07:27:30.802 PST"] 12 | [GameStartTime "2019-01-14T06:46:35.929 PST"] 13 | [PlyCount "154"] 14 | [Termination "adjudication"] 15 | [TimeControl "900+5"] 16 | 17 | 1. e4 {book} a6 {book} 2. c4 {book} e5 {0.00/31 48s} 3. Nf3 {+0.69/29 36s} 18 | Nc6 {0.00/31 12s} 4. Nc3 {+0.56/28 14s} Nf6 {0.00/30 9.3s} 5. a3 {+0.50/28 29s} 19 | d6 {+0.12/28 21s} 6. Be2 {+0.43/26 16s} Bg4 {+0.14/25 8.8s} 7. d3 {+0.43/28 34s} 20 | g6 {0.00/28 14s} 8. O-O {+0.30/28 20s} Bg7 {+0.15/31 47s} 9. b4 {+0.24/27 13s} 21 | O-O {0.00/26 14s} 10. Rb1 {+0.45/30 24s} Nd7 {-0.03/29 35s} 22 | 11. Bg5 {+0.68/25 6.8s} Bf6 {0.00/27 7.9s} 12. Be3 {+0.55/29 16s} 23 | Bg7 {-0.05/30 44s} 13. Bg5 {+0.61/29 26s} Bf6 {0.00/32 8.7s} 24 | 14. Be3 {+0.51/29 11s} Bg7 {0.00/34 16s} 15. Qd2 {+0.50/30 22s} a5 {0.00/32 67s} 25 | 16. b5 {+0.45/29 7.9s} Bxf3 {0.00/32 6.0s} 17. Bxf3 {+0.51/32 9.4s} 26 | Nd4 {0.00/34 8.9s} 18. Bd1 {+0.66/31 9.5s} Nc5 {-0.09/35 18s} 27 | 19. Bxd4 {+0.65/31 12s} exd4 {-0.32/34 37s} 20. Na4 {+0.83/32 29s} 28 | Nd7 {-0.27/32 28s} 21. f4 {+0.78/32 27s} h5 {-0.35/32 21s} 29 | 22. Bf3 {+0.85/29 12s} Rb8 {-0.33/29 24s} 23. g3 {+0.81/30 30s} 30 | b6 {-0.48/29 21s} 24. Bg2 {+0.88/29 21s} Nf6 {-0.58/33 46s} 31 | 25. Nb2 {+1.03/34 9.1s} Ng4 {-0.58/36 19s} 26. Nd1 {+1.03/34 11s} 32 | Qe7 {-0.58/38 16s} 27. Bf3 {+1.03/37 13s} Nf6 {-0.58/38 7.6s} 33 | 28. Nf2 {+1.03/38 12s} Nd7 {-0.58/39 26s} 29. Bg2 {+1.03/38 17s} 34 | Nc5 {-0.58/38 11s} 30. h4 {+1.03/38 15s} Rbe8 {-0.67/38 71s} 35 | 31. Kh2 {+1.03/39 15s} Qd8 {-0.67/34 18s} 32. Rbe1 {+1.03/35 12s} 36 | Nd7 {-0.77/38 125s} 33. Qd1 {+1.03/36 16s} Nc5 {-0.87/34 30s} 37 | 34. Nh3 {+1.03/37 13s} Kh8 {-0.77/30 14s} 35. Qe2 {+1.03/37 25s} 38 | Nd7 {-0.77/33 5.2s} 36. Ng5 {+1.13/35 44s} Bh6 {-0.77/33 7.8s} 39 | 37. Qf2 {+1.24/34 15s} Bg7 {-0.77/34 7.1s} 38. Rd1 {+1.42/31 14s} 40 | Nc5 {-0.87/34 46s} 39. Kh1 {+1.33/32 24s} Kg8 {-0.77/32 9.1s} 41 | 40. Nf3 {+1.38/30 9.7s} Nb3 {-0.77/30 4.8s} 41. Bh3 {+1.68/28 14s} 42 | Kh8 {-1.10/31 53s} 42. Rg1 {+1.86/32 46s} Nc5 {-1.01/27 5.0s} 43 | 43. g4 {+1.73/30 12s} Qf6 {-1.04/28 18s} 44. Ng5 {+1.78/31 21s} 44 | hxg4 {-1.53/28 8.1s} 45. Rxg4 {+1.87/29 9.6s} Bh6 {-1.45/26 6.1s} 45 | 46. Qg3 {+1.86/29 15s} Rg8 {-1.50/29 15s} 47. Rg1 {+1.71/32 44s} 46 | Rg7 {-1.32/29 4.7s} 48. h5 {+1.86/29 6.2s} Kg8 {-1.41/28 6.2s} 47 | 49. hxg6 {+1.46/32 27s} fxg6 {-1.25/28 7.8s} 50. Qh4 {+1.61/33 20s} 48 | Bxg5 {-1.42/29 6.6s} 51. Rxg5 {+1.61/35 7.0s} Ne6 {-1.19/28 4.8s} 49 | 52. Bxe6+ {+1.61/38 10.0s} Rxe6 {-1.39/32 13s} 53. Kg2 {+1.61/39 15s} 50 | Rh7 {-1.49/29 8.5s} 54. Qg4 {+1.61/41 9.0s} Kf8 {-2.00/31 19s} 51 | 55. Rh1 {+2.24/32 7.8s} Rxh1 {-2.01/28 2.5s} 56. Kxh1 {+2.36/35 12s} 52 | Qh8+ {-1.93/29 5.9s} 57. Kg2 {+2.41/36 9.8s} Kf7 {-1.57/29 1.9s} 53 | 58. Qf3 {+2.46/37 14s} Rf6 {-2.27/33 13s} 59. e5 {+2.50/33 9.1s} 54 | dxe5 {-2.25/30 2.5s} 60. Qd5+ {+2.87/33 18s} Kg7 {-2.43/30 4.3s} 55 | 61. Qd7+ {+2.92/33 7.1s} Rf7 {-2.55/31 5.7s} 62. Qe6 {+3.02/32 8.4s} 56 | Qh6 {-2.48/28 3.7s} 63. Qxe5+ {+3.14/32 7.6s} Kh7 {-2.24/27 1.7s} 57 | 64. Qe4 {+3.13/35 13s} Qg7 {-2.39/30 8.2s} 65. Re5 {+3.45/32 6.9s} 58 | Qf8 {-2.65/30 10s} 66. Re8 {+3.78/31 9.5s} Qc5 {-2.65/30 5.5s} 59 | 67. Kg3 {+3.99/31 7.7s} a4 {-2.92/31 5.2s} 68. Rd8 {+4.10/31 7.1s} 60 | Re7 {-3.27/29 5.0s} 69. Qxd4 {+4.37/32 9.1s} Qxd4 {-3.28/27 2.5s} 61 | 70. Rxd4 {+4.41/29 7.3s} Kg7 {-3.62/31 7.5s} 71. Re4 {+5.72/31 7.3s} 62 | Rd7 {-4.53/29 5.0s} 72. d4 {+6.17/33 8.0s} Rd8 {-5.41/32 5.0s} 63 | 73. Kg4 {+6.31/39 6.0s} Kf7 {-5.92/29 5.0s} 74. d5 {+7.67/39 36s} 64 | Rh8 {-6.63/29 5.0s} 75. Re6 {+7.97/28 6.8s} Rh1 {-7.12/26 5.0s} 65 | 76. Rc6 {+8.52/27 8.6s} Rg1+ {-7.80/24 5.0s} 77. Kf3 {+8.86/27 6.4s} 66 | Rf1+ {-8.11/24 5.0s, White wins by adjudication} 1-0 67 | -------------------------------------------------------------------------------- /fuzz/corpus/pgn/stockfish-learning.pgn: -------------------------------------------------------------------------------- 1 | [Event "?"] 2 | [Site "?"] 3 | [Date "2019.01.14"] 4 | [Round "1"] 5 | [White "Stockfish-reference"] 6 | [Black "Stockfish-learning"] 7 | [Result "1-0"] 8 | [ECO "B00"] 9 | [Opening "St. George (Baker) defense"] 10 | [GameDuration "00:40:54"] 11 | [GameEndTime "2019-01-14T07:27:30.802 PST"] 12 | [GameStartTime "2019-01-14T06:46:35.929 PST"] 13 | [PlyCount "154"] 14 | [Termination "adjudication"] 15 | [TimeControl "900+5"] 16 | 17 | 1. e4 {book} a6 {book} 2. c4 {book} e5 {0.00/31 48s} 3. Nf3 {+0.69/29 36s} 18 | Nc6 {0.00/31 12s} 4. Nc3 {+0.56/28 14s} Nf6 {0.00/30 9.3s} 5. a3 {+0.50/28 29s} 19 | d6 {+0.12/28 21s} 6. Be2 {+0.43/26 16s} Bg4 {+0.14/25 8.8s} 7. d3 {+0.43/28 34s} 20 | g6 {0.00/28 14s} 8. O-O {+0.30/28 20s} Bg7 {+0.15/31 47s} 9. b4 {+0.24/27 13s} 21 | O-O {0.00/26 14s} 10. Rb1 {+0.45/30 24s} Nd7 {-0.03/29 35s} 22 | 11. Bg5 {+0.68/25 6.8s} Bf6 {0.00/27 7.9s} 12. Be3 {+0.55/29 16s} 23 | Bg7 {-0.05/30 44s} 13. Bg5 {+0.61/29 26s} Bf6 {0.00/32 8.7s} 24 | 14. Be3 {+0.51/29 11s} Bg7 {0.00/34 16s} 15. Qd2 {+0.50/30 22s} a5 {0.00/32 67s} 25 | 16. b5 {+0.45/29 7.9s} Bxf3 {0.00/32 6.0s} 17. Bxf3 {+0.51/32 9.4s} 26 | Nd4 {0.00/34 8.9s} 18. Bd1 {+0.66/31 9.5s} Nc5 {-0.09/35 18s} 27 | 19. Bxd4 {+0.65/31 12s} exd4 {-0.32/34 37s} 20. Na4 {+0.83/32 29s} 28 | Nd7 {-0.27/32 28s} 21. f4 {+0.78/32 27s} h5 {-0.35/32 21s} 29 | 22. Bf3 {+0.85/29 12s} Rb8 {-0.33/29 24s} 23. g3 {+0.81/30 30s} 30 | b6 {-0.48/29 21s} 24. Bg2 {+0.88/29 21s} Nf6 {-0.58/33 46s} 31 | 25. Nb2 {+1.03/34 9.1s} Ng4 {-0.58/36 19s} 26. Nd1 {+1.03/34 11s} 32 | Qe7 {-0.58/38 16s} 27. Bf3 {+1.03/37 13s} Nf6 {-0.58/38 7.6s} 33 | 28. Nf2 {+1.03/38 12s} Nd7 {-0.58/39 26s} 29. Bg2 {+1.03/38 17s} 34 | Nc5 {-0.58/38 11s} 30. h4 {+1.03/38 15s} Rbe8 {-0.67/38 71s} 35 | 31. Kh2 {+1.03/39 15s} Qd8 {-0.67/34 18s} 32. Rbe1 {+1.03/35 12s} 36 | Nd7 {-0.77/38 125s} 33. Qd1 {+1.03/36 16s} Nc5 {-0.87/34 30s} 37 | 34. Nh3 {+1.03/37 13s} Kh8 {-0.77/30 14s} 35. Qe2 {+1.03/37 25s} 38 | Nd7 {-0.77/33 5.2s} 36. Ng5 {+1.13/35 44s} Bh6 {-0.77/33 7.8s} 39 | 37. Qf2 {+1.24/34 15s} Bg7 {-0.77/34 7.1s} 38. Rd1 {+1.42/31 14s} 40 | Nc5 {-0.87/34 46s} 39. Kh1 {+1.33/32 24s} Kg8 {-0.77/32 9.1s} 41 | 40. Nf3 {+1.38/30 9.7s} Nb3 {-0.77/30 4.8s} 41. Bh3 {+1.68/28 14s} 42 | Kh8 {-1.10/31 53s} 42. Rg1 {+1.86/32 46s} Nc5 {-1.01/27 5.0s} 43 | 43. g4 {+1.73/30 12s} Qf6 {-1.04/28 18s} 44. Ng5 {+1.78/31 21s} 44 | hxg4 {-1.53/28 8.1s} 45. Rxg4 {+1.87/29 9.6s} Bh6 {-1.45/26 6.1s} 45 | 46. Qg3 {+1.86/29 15s} Rg8 {-1.50/29 15s} 47. Rg1 {+1.71/32 44s} 46 | Rg7 {-1.32/29 4.7s} 48. h5 {+1.86/29 6.2s} Kg8 {-1.41/28 6.2s} 47 | 49. hxg6 {+1.46/32 27s} fxg6 {-1.25/28 7.8s} 50. Qh4 {+1.61/33 20s} 48 | Bxg5 {-1.42/29 6.6s} 51. Rxg5 {+1.61/35 7.0s} Ne6 {-1.19/28 4.8s} 49 | 52. Bxe6+ {+1.61/38 10.0s} Rxe6 {-1.39/32 13s} 53. Kg2 {+1.61/39 15s} 50 | Rh7 {-1.49/29 8.5s} 54. Qg4 {+1.61/41 9.0s} Kf8 {-2.00/31 19s} 51 | 55. Rh1 {+2.24/32 7.8s} Rxh1 {-2.01/28 2.5s} 56. Kxh1 {+2.36/35 12s} 52 | Qh8+ {-1.93/29 5.9s} 57. Kg2 {+2.41/36 9.8s} Kf7 {-1.57/29 1.9s} 53 | 58. Qf3 {+2.46/37 14s} Rf6 {-2.27/33 13s} 59. e5 {+2.50/33 9.1s} 54 | dxe5 {-2.25/30 2.5s} 60. Qd5+ {+2.87/33 18s} Kg7 {-2.43/30 4.3s} 55 | 61. Qd7+ {+2.92/33 7.1s} Rf7 {-2.55/31 5.7s} 62. Qe6 {+3.02/32 8.4s} 56 | Qh6 {-2.48/28 3.7s} 63. Qxe5+ {+3.14/32 7.6s} Kh7 {-2.24/27 1.7s} 57 | 64. Qe4 {+3.13/35 13s} Qg7 {-2.39/30 8.2s} 65. Re5 {+3.45/32 6.9s} 58 | Qf8 {-2.65/30 10s} 66. Re8 {+3.78/31 9.5s} Qc5 {-2.65/30 5.5s} 59 | 67. Kg3 {+3.99/31 7.7s} a4 {-2.92/31 5.2s} 68. Rd8 {+4.10/31 7.1s} 60 | Re7 {-3.27/29 5.0s} 69. Qxd4 {+4.37/32 9.1s} Qxd4 {-3.28/27 2.5s} 61 | 70. Rxd4 {+4.41/29 7.3s} Kg7 {-3.62/31 7.5s} 71. Re4 {+5.72/31 7.3s} 62 | Rd7 {-4.53/29 5.0s} 72. d4 {+6.17/33 8.0s} Rd8 {-5.41/32 5.0s} 63 | 73. Kg4 {+6.31/39 6.0s} Kf7 {-5.92/29 5.0s} 74. d5 {+7.67/39 36s} 64 | Rh8 {-6.63/29 5.0s} 75. Re6 {+7.97/28 6.8s} Rh1 {-7.12/26 5.0s} 65 | 76. Rc6 {+8.52/27 8.6s} Rg1+ {-7.80/24 5.0s} 77. Kf3 {+8.86/27 6.4s} 66 | Rf1+ {-8.11/24 5.0s, White wins by adjudication} 1-0 67 | -------------------------------------------------------------------------------- /release.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # Helper script to create and publish a new python-chess release. 3 | 4 | import os 5 | import chess 6 | import sys 7 | import subprocess 8 | 9 | 10 | def system(command): 11 | print(command) 12 | exit_code = os.system(command) 13 | if exit_code != 0: 14 | sys.exit(exit_code) 15 | 16 | 17 | def check_git(): 18 | print("--- CHECK GIT ----------------------------------------------------") 19 | system("git diff --exit-code") 20 | system("git diff --cached --exit-code") 21 | 22 | system("git fetch origin") 23 | behind = int(subprocess.check_output(["git", "rev-list", "--count", "master..origin/master"])) 24 | if behind > 0: 25 | print(f"master is {behind} commit(s) behind origin/master") 26 | sys.exit(1) 27 | 28 | 29 | def test(): 30 | print("--- TEST ---------------------------------------------------------") 31 | system("tox --skip-missing-interpreters") 32 | 33 | 34 | def check_changelog(): 35 | print("--- CHECK CHANGELOG ----------------------------------------------") 36 | with open("CHANGELOG.rst", "r") as changelog_file: 37 | changelog = changelog_file.read() 38 | 39 | if "Upcoming in" in changelog: 40 | print("Found: Upcoming in") 41 | sys.exit(1) 42 | 43 | tagname = f"v{chess.__version__}" 44 | if tagname not in changelog: 45 | print(f"Not found: {tagname}") 46 | sys.exit(1) 47 | 48 | 49 | def check_docs(): 50 | print("--- CHECK DOCS ---------------------------------------------------") 51 | system("python3 setup.py --long-description | rst2html --strict --no-raw > /dev/null") 52 | 53 | 54 | def tag_and_push(): 55 | print("--- TAG AND PUSH -------------------------------------------------") 56 | tagname = f"v{chess.__version__}" 57 | release_filename = f"release-{tagname}.txt" 58 | 59 | if not os.path.exists(release_filename): 60 | print(f">>> Creating {release_filename} ...") 61 | first_section = False 62 | prev_line = None 63 | with open(release_filename, "w") as release_txt, open("CHANGELOG.rst", "r") as changelog_file: 64 | headline = f"python-chess {tagname}" 65 | release_txt.write(headline + os.linesep) 66 | 67 | for line in changelog_file: 68 | if not first_section: 69 | if line.startswith("-------"): 70 | first_section = True 71 | else: 72 | if line.startswith("-------"): 73 | break 74 | else: 75 | if not prev_line.startswith("------"): 76 | release_txt.write(prev_line) 77 | 78 | prev_line = line 79 | 80 | with open(release_filename, "r") as release_txt: 81 | release = release_txt.read().strip() + os.linesep 82 | print(release) 83 | 84 | with open(release_filename, "w") as release_txt: 85 | release_txt.write(release) 86 | 87 | guessed_tagname = input(">>> Sure? Confirm tagname: ") 88 | if guessed_tagname != tagname: 89 | print(f"Actual tagname is: {tagname}") 90 | sys.exit(1) 91 | 92 | system(f"git tag {tagname} -s -F {release_filename}") 93 | system(f"git push --atomic origin master {tagname}") 94 | return tagname 95 | 96 | 97 | def pypi(): 98 | print("--- PYPI ---------------------------------------------------------") 99 | system("rm -rf build") 100 | system("python3 setup.py sdist") 101 | system("twine check dist/*") 102 | system("twine upload --skip-existing dist/*") 103 | 104 | 105 | def github_release(tagname): 106 | print("--- GITHUB RELEASE -----------------------------------------------") 107 | print(f"https://github.com/niklasf/python-chess/releases/new?tag={tagname}") 108 | 109 | 110 | if __name__ == "__main__": 111 | check_docs() 112 | test() 113 | check_git() 114 | check_changelog() 115 | tagname = tag_and_push() 116 | pypi() 117 | github_release(tagname) 118 | -------------------------------------------------------------------------------- /docs/core.rst: -------------------------------------------------------------------------------- 1 | Core 2 | ==== 3 | 4 | Colors 5 | ------ 6 | 7 | Constants for the side to move or the color of a piece. 8 | 9 | .. py:data:: chess.WHITE 10 | :type: chess.Color 11 | :value: True 12 | 13 | .. py:data:: chess.BLACK 14 | :type: chess.Color 15 | :value: False 16 | 17 | You can get the opposite *color* using ``not color``. 18 | 19 | Piece types 20 | ----------- 21 | 22 | .. py:data:: chess.PAWN 23 | :type: chess.PieceType 24 | :value: 1 25 | .. py:data:: chess.KNIGHT 26 | :type: chess.PieceType 27 | :value: 2 28 | .. py:data:: chess.BISHOP 29 | :type: chess.PieceType 30 | :value: 3 31 | .. py:data:: chess.ROOK 32 | :type: chess.PieceType 33 | :value: 4 34 | .. py:data:: chess.QUEEN 35 | :type: chess.PieceType 36 | :value: 5 37 | .. py:data:: chess.KING 38 | :type: chess.PieceType 39 | :value: 6 40 | 41 | .. autofunction:: chess.piece_symbol 42 | 43 | .. autofunction:: chess.piece_name 44 | 45 | Squares 46 | ------- 47 | 48 | .. py:data:: chess.A1 49 | :type: chess.Square 50 | :value: 0 51 | .. py:data:: chess.B1 52 | :type: chess.Square 53 | :value: 1 54 | 55 | and so on to 56 | 57 | .. py:data:: chess.G8 58 | :type: chess.Square 59 | :value: 62 60 | .. py:data:: chess.H8 61 | :type: chess.Square 62 | :value: 63 63 | 64 | .. py:data:: chess.SQUARES 65 | :value: [chess.A1, chess.B1, ..., chess.G8, chess.H8] 66 | 67 | .. py:data:: chess.SQUARE_NAMES 68 | :value: ['a1', 'b1', ..., 'g8', 'h8'] 69 | 70 | .. py:data:: chess.FILE_NAMES 71 | :value: ['a', 'b', ..., 'g', 'h'] 72 | 73 | .. py:data:: chess.RANK_NAMES 74 | :value: ['1', '2', ..., '7', '8'] 75 | 76 | .. autofunction:: chess.parse_square 77 | 78 | .. autofunction:: chess.square_name 79 | 80 | .. autofunction:: chess.square 81 | 82 | .. autofunction:: chess.square_file 83 | 84 | .. autofunction:: chess.square_rank 85 | 86 | .. autofunction:: chess.square_distance 87 | 88 | .. autofunction:: chess.square_manhattan_distance 89 | 90 | .. autofunction:: chess.square_knight_distance 91 | 92 | .. autofunction:: chess.square_mirror 93 | 94 | Pieces 95 | ------ 96 | 97 | .. autoclass:: chess.Piece 98 | :members: 99 | 100 | Moves 101 | ----- 102 | 103 | .. autoclass:: chess.Move 104 | :members: 105 | 106 | Board 107 | ----- 108 | 109 | .. autodata:: chess.STARTING_FEN 110 | 111 | .. autodata:: chess.STARTING_BOARD_FEN 112 | 113 | .. autoclass:: chess.Board 114 | :members: 115 | :exclude-members: set_piece_at, remove_piece_at, reset_board, set_board_fen, set_piece_map, set_chess960_pos, apply_transform 116 | 117 | .. autoclass:: chess.BaseBoard 118 | :members: 119 | 120 | Outcome 121 | ------- 122 | 123 | .. autoclass:: chess.Outcome 124 | :members: 125 | 126 | .. autoclass:: chess.Termination 127 | :members: 128 | 129 | Square sets 130 | ----------- 131 | 132 | .. autoclass:: chess.SquareSet 133 | :members: 134 | 135 | Common integer masks are: 136 | 137 | .. py:data:: chess.BB_EMPTY 138 | :type: chess.Bitboard 139 | :value: 0 140 | .. py:data:: chess.BB_ALL 141 | :type: chess.Bitboard 142 | :value: 0xFFFF_FFFF_FFFF_FFFF 143 | 144 | Single squares: 145 | 146 | .. py:data:: chess.BB_SQUARES 147 | :value: [chess.BB_A1, chess.BB_B1, ..., chess.BB_G8, chess.BB_H8] 148 | 149 | Ranks and files: 150 | 151 | .. py:data:: chess.BB_RANKS 152 | :value: [chess.BB_RANK_1, ..., chess.BB_RANK_8] 153 | 154 | 155 | .. py:data:: chess.BB_FILES 156 | :value: [chess.BB_FILE_A, ..., chess.BB_FILE_H] 157 | 158 | Other masks: 159 | 160 | .. py:data:: chess.BB_LIGHT_SQUARES 161 | :type: chess.Bitboard 162 | :value: 0x55AA_55AA_55AA_55AA 163 | .. py:data:: chess.BB_DARK_SQUARES 164 | :type: chess.Bitboard 165 | :value: 0xAA55_AA55_AA55_AA55 166 | 167 | .. py:data:: chess.BB_BACKRANKS 168 | :value: chess.BB_RANK_1 | chess.BB_RANK_8 169 | 170 | .. py:data:: chess.BB_CORNERS 171 | :value: chess.BB_A1 | chess.BB_H1 | chess.BB_A8 | chess.BB_H8 172 | .. py:data:: chess.BB_CENTER 173 | :value: chess.BB_D4 | chess.BB_E4 | chess.BB_D5 | chess.BB_E5 174 | -------------------------------------------------------------------------------- /docs/variant.rst: -------------------------------------------------------------------------------- 1 | Variants 2 | ======== 3 | 4 | python-chess supports several chess variants. 5 | 6 | >>> import chess.variant 7 | >>> 8 | >>> board = chess.variant.GiveawayBoard() 9 | 10 | >>> # General information about the variants. 11 | >>> type(board).uci_variant 12 | 'giveaway' 13 | >>> type(board).xboard_variant 14 | 'giveaway' 15 | >>> type(board).starting_fen 16 | 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w - - 0 1' 17 | 18 | ================ ========================================= ============= ============ 19 | Variant Board class UCI/XBoard Syzygy 20 | ================ ========================================= ============= ============ 21 | Standard :class:`chess.Board` chess/normal .rtbw, .rtbz 22 | Suicide :class:`chess.variant.SuicideBoard` suicide .stbw, .stbz 23 | Giveaway :class:`chess.variant.GiveawayBoard` giveaway .gtbw, .gtbz 24 | Antichess :class:`chess.variant.AntichessBoard` antichess .gtbw, .gtbz 25 | Atomic :class:`chess.variant.AtomicBoard` atomic .atbw, .atbz 26 | King of the Hill :class:`chess.variant.KingOfTheHillBoard` kingofthehill 27 | Racing Kings :class:`chess.variant.RacingKingsBoard` racingkings 28 | Horde :class:`chess.variant.HordeBoard` horde 29 | Three-check :class:`chess.variant.ThreeCheckBoard` 3check 30 | Crazyhouse :class:`chess.variant.CrazyhouseBoard` crazyhouse 31 | ================ ========================================= ============= ============ 32 | 33 | .. autofunction:: chess.variant.find_variant 34 | 35 | Game end 36 | -------- 37 | 38 | See :func:`chess.Board.is_variant_end()`, :func:`~chess.Board.is_variant_win()`, 39 | :func:`~chess.Board.is_variant_draw()`, 40 | or :func:`~chess.Board.is_variant_loss()` for special variant end conditions 41 | and results. 42 | 43 | Note that if all of them return ``False``, the game may still be over and 44 | decided by standard conditions like :func:`~chess.Board.is_checkmate()`, 45 | :func:`~chess.Board.is_stalemate()`, 46 | :func:`~chess.Board.is_insufficient_material()`, move counters, repetitions, 47 | and legitimate claims. 48 | 49 | Chess960 50 | -------- 51 | 52 | Chess960 is orthogonal to all other variants. 53 | 54 | >>> chess.Board(chess960=True) 55 | Board('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', chess960=True) 56 | 57 | See :func:`chess.BaseBoard.set_chess960_pos()`, 58 | :func:`~chess.BaseBoard.chess960_pos()`, and 59 | :func:`~chess.BaseBoard.from_chess960_pos()` for dealing with Chess960 starting 60 | positions. 61 | 62 | Crazyhouse 63 | ---------- 64 | 65 | .. autoclass:: chess.variant.CrazyhousePocket 66 | :members: 67 | 68 | .. autoclass:: chess.variant.CrazyhouseBoard 69 | :members: legal_drop_squares 70 | 71 | .. py:attribute:: pockets 72 | :value: [chess.variant.CrazyhousePocket(), chess.variant.CrazyhousePocket()] 73 | 74 | Pockets for each color. For example, ``board.pockets[chess.WHITE]`` 75 | are the pocket pieces available to White. 76 | 77 | Three-check 78 | ----------- 79 | 80 | .. autoclass:: chess.variant.ThreeCheckBoard 81 | 82 | .. py:attribute:: remaining_checks 83 | :value: [3, 3] 84 | 85 | Remaining checks until victory for each color. For example, 86 | ``board.remaining_checks[chess.WHITE] == 0`` implies that White has won. 87 | 88 | UCI/XBoard 89 | ---------- 90 | 91 | `Multi-Variant Stockfish`_ and other engines have an ``UCI_Variant`` option. 92 | XBoard engines may declare support for ``variants``. 93 | This is automatically managed. 94 | 95 | >>> import chess.engine 96 | >>> 97 | >>> engine = chess.engine.SimpleEngine.popen_uci("stockfish-mv") 98 | >>> 99 | >>> board = chess.variant.RacingKingsBoard() 100 | >>> result = engine.play(board, chess.engine.Limit(time=1.0)) 101 | 102 | Syzygy 103 | ------ 104 | 105 | Syzygy tablebases are available for suicide, giveaway and atomic chess. 106 | 107 | >>> import chess.syzygy 108 | >>> import chess.variant 109 | >>> 110 | >>> tables = chess.syzygy.open_tablebase("data/syzygy", VariantBoard=chess.variant.AtomicBoard) 111 | 112 | 113 | .. _Multi-Variant Stockfish: https://github.com/ddugovic/Stockfish 114 | -------------------------------------------------------------------------------- /data/pgn/kasparov-deep-blue-1997.pgn: -------------------------------------------------------------------------------- 1 | [Event "IBM Man-Machine, New York USA"] 2 | [Site "01"] 3 | [Date "1997.??.??"] 4 | [EventDate "?"] 5 | [Round "?"] 6 | [Result "1-0"] 7 | [White "Garry Kasparov"] 8 | [Black "Deep Blue (Computer)"] 9 | [ECO "A06"] 10 | [WhiteElo "?"] 11 | [BlackElo "?"] 12 | [PlyCount "89"] 13 | 14 | 1.Nf3 d5 2.g3 Bg4 3.b3 Nd7 4.Bb2 e6 5.Bg2 Ngf6 6.O-O c6 7.d3 15 | Bd6 8.Nbd2 O-O 9.h3 Bh5 10.e3 h6 11.Qe1 Qa5 12.a3 Bc7 13.Nh4 16 | g5 14.Nhf3 e5 15.e4 Rfe8 16.Nh2 Qb6 17.Qc1 a5 18.Re1 Bd6 17 | 19.Ndf1 dxe4 20.dxe4 Bc5 21.Ne3 Rad8 22.Nhf1 g4 23.hxg4 Nxg4 18 | 24.f3 Nxe3 25.Nxe3 Be7 26.Kh1 Bg5 27.Re2 a4 28.b4 f5 29.exf5 19 | e4 30.f4 Bxe2 31.fxg5 Ne5 32.g6 Bf3 33.Bc3 Qb5 34.Qf1 Qxf1+ 20 | 35.Rxf1 h5 36.Kg1 Kf8 37.Bh3 b5 38.Kf2 Kg7 39.g4 Kh6 40.Rg1 21 | hxg4 41.Bxg4 Bxg4 42.Nxg4+ Nxg4+ 43.Rxg4 Rd5 44.f6 Rd1 45.g7 22 | 1-0 23 | 24 | [Event "IBM Man-Machine, New York USA"] 25 | [Site "02"] 26 | [Date "1997.??.??"] 27 | [EventDate "?"] 28 | [Round "?"] 29 | [Result "1-0"] 30 | [White "Deep Blue (Computer)"] 31 | [Black "Garry Kasparov"] 32 | [ECO "C93"] 33 | [WhiteElo "?"] 34 | [BlackElo "?"] 35 | [PlyCount "89"] 36 | 37 | 1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Ba4 Nf6 5.O-O Be7 6.Re1 b5 7.Bb3 38 | d6 8.c3 O-O 9.h3 h6 10.d4 Re8 11.Nbd2 Bf8 12.Nf1 Bd7 13.Ng3 39 | Na5 14.Bc2 c5 15.b3 Nc6 16.d5 Ne7 17.Be3 Ng6 18.Qd2 Nh7 19.a4 40 | Nh4 20.Nxh4 Qxh4 21.Qe2 Qd8 22.b4 Qc7 23.Rec1 c4 24.Ra3 Rec8 41 | 25.Rca1 Qd8 26.f4 Nf6 27.fxe5 dxe5 28.Qf1 Ne8 29.Qf2 Nd6 42 | 30.Bb6 Qe8 31.R3a2 Be7 32.Bc5 Bf8 33.Nf5 Bxf5 34.exf5 f6 43 | 35.Bxd6 Bxd6 36.axb5 axb5 37.Be4 Rxa2 38.Qxa2 Qd7 39.Qa7 Rc7 44 | 40.Qb6 Rb7 41.Ra8+ Kf7 42.Qa6 Qc7 43.Qc6 Qb6+ 44.Kf1 Rb8 45 | 45.Ra6 1-0 46 | 47 | [Event "IBM Man-Machine, New York USA"] 48 | [Site "03"] 49 | [Date "1997.??.??"] 50 | [EventDate "?"] 51 | [Round "?"] 52 | [Result "1/2-1/2"] 53 | [White "Garry Kasparov"] 54 | [Black "Deep Blue (Computer)"] 55 | [ECO "A00"] 56 | [WhiteElo "?"] 57 | [BlackElo "?"] 58 | [PlyCount "95"] 59 | 60 | 1.d3 e5 2.Nf3 Nc6 3.c4 Nf6 4.a3 d6 5.Nc3 Be7 6.g3 O-O 7.Bg2 61 | Be6 8.O-O Qd7 9.Ng5 Bf5 10.e4 Bg4 11.f3 Bh5 12.Nh3 Nd4 13.Nf2 62 | h6 14.Be3 c5 15.b4 b6 16.Rb1 Kh8 17.Rb2 a6 18.bxc5 bxc5 19.Bh3 63 | Qc7 20.Bg4 Bg6 21.f4 exf4 22.gxf4 Qa5 23.Bd2 Qxa3 24.Ra2 Qb3 64 | 25.f5 Qxd1 26.Bxd1 Bh7 27.Nh3 Rfb8 28.Nf4 Bd8 29.Nfd5 Nc6 65 | 30.Bf4 Ne5 31.Ba4 Nxd5 32.Nxd5 a5 33.Bb5 Ra7 34.Kg2 g5 66 | 35.Bxe5+ dxe5 36.f6 Bg6 37.h4 gxh4 38.Kh3 Kg8 39.Kxh4 Kh7 67 | 40.Kg4 Bc7 41.Nxc7 Rxc7 42.Rxa5 Rd8 43.Rf3 Kh8 44.Kh4 Kg8 68 | 45.Ra3 Kh8 46.Ra6 Kh7 47.Ra3 Kh8 48.Ra6 1/2-1/2 69 | 70 | [Event "IBM Man-Machine, New York USA"] 71 | [Site "04"] 72 | [Date "1997.??.??"] 73 | [EventDate "?"] 74 | [Round "?"] 75 | [Result "1/2-1/2"] 76 | [White "Deep Blue (Computer)"] 77 | [Black "Garry Kasparov"] 78 | [ECO "B10"] 79 | [WhiteElo "?"] 80 | [BlackElo "?"] 81 | [PlyCount "111"] 82 | 83 | 1.e4 c6 2.d4 d6 3.Nf3 Nf6 4.Nc3 Bg4 5.h3 Bh5 6.Bd3 e6 7.Qe2 d5 84 | 8.Bg5 Be7 9.e5 Nfd7 10.Bxe7 Qxe7 11.g4 Bg6 12.Bxg6 hxg6 13.h4 85 | Na6 14.O-O-O O-O-O 15.Rdg1 Nc7 16.Kb1 f6 17.exf6 Qxf6 18.Rg3 86 | Rde8 19.Re1 Rhf8 20.Nd1 e5 21.dxe5 Qf4 22.a3 Ne6 23.Nc3 Ndc5 87 | 24.b4 Nd7 25.Qd3 Qf7 26.b5 Ndc5 27.Qe3 Qf4 28.bxc6 bxc6 29.Rd1 88 | Kc7 30.Ka1 Qxe3 31.fxe3 Rf7 32.Rh3 Ref8 33.Nd4 Rf2 34.Rb1 Rg2 89 | 35.Nce2 Rxg4 36.Nxe6+ Nxe6 37.Nd4 Nxd4 38.exd4 Rxd4 39.Rg1 Rc4 90 | 40.Rxg6 Rxc2 41.Rxg7+ Kb6 42.Rb3+ Kc5 43.Rxa7 Rf1+ 44.Rb1 Rff2 91 | 45.Rb4 Rc1+ 46.Rb1 Rcc2 47.Rb4 Rc1+ 48.Rb1 Rxb1+ 49.Kxb1 Re2 92 | 50.Re7 Rh2 51.Rh7 Kc4 52.Rc7 c5 53.e6 Rxh4 54.e7 Re4 55.a4 Kb3 93 | 56.Kc1 1/2-1/2 94 | 95 | [Event "IBM Man-Machine, New York USA"] 96 | [Site "05"] 97 | [Date "1997.??.??"] 98 | [EventDate "?"] 99 | [Round "?"] 100 | [Result "1/2-1/2"] 101 | [White "Garry Kasparov"] 102 | [Black "Deep Blue (Computer)"] 103 | [ECO "A07"] 104 | [WhiteElo "?"] 105 | [BlackElo "?"] 106 | [PlyCount "98"] 107 | 108 | 1.Nf3 d5 2.g3 Bg4 3.Bg2 Nd7 4.h3 Bxf3 5.Bxf3 c6 6.d3 e6 7.e4 109 | Ne5 8.Bg2 dxe4 9.Bxe4 Nf6 10.Bg2 Bb4+ 11.Nd2 h5 12.Qe2 Qc7 110 | 13.c3 Be7 14.d4 Ng6 15.h4 e5 16.Nf3 exd4 17.Nxd4 O-O-O 18.Bg5 111 | Ng4 19.O-O-O Rhe8 20.Qc2 Kb8 21.Kb1 Bxg5 22.hxg5 N6e5 23.Rhe1 112 | c5 24.Nf3 Rxd1+ 25.Rxd1 Nc4 26.Qa4 Rd8 27.Re1 Nb6 28.Qc2 Qd6 113 | 29.c4 Qg6 30.Qxg6 fxg6 31.b3 Nxf2 32.Re6 Kc7 33.Rxg6 Rd7 114 | 34.Nh4 Nc8 35.Bd5 Nd6 36.Re6 Nb5 37.cxb5 Rxd5 38.Rg6 Rd7 115 | 39.Nf5 Ne4 40.Nxg7 Rd1+ 41.Kc2 Rd2+ 42.Kc1 Rxa2 43.Nxh5 Nd2 116 | 44.Nf4 Nxb3+ 45.Kb1 Rd2 46.Re6 c4 47.Re3 Kb6 48.g6 Kxb5 49.g7 117 | Kb4 1/2-1/2 118 | 119 | [Event "IBM Man-Machine, New York USA"] 120 | [Site "06"] 121 | [Date "1997.??.??"] 122 | [EventDate "?"] 123 | [Round "?"] 124 | [Result "1-0"] 125 | [White "Deep Blue (Computer)"] 126 | [Black "Garry Kasparov"] 127 | [ECO "B17"] 128 | [WhiteElo "?"] 129 | [BlackElo "?"] 130 | [PlyCount "37"] 131 | 132 | 1.e4 c6 2.d4 d5 3.Nc3 dxe4 4.Nxe4 Nd7 5.Ng5 Ngf6 6.Bd3 e6 133 | 7.N1f3 h6 8.Nxe6 Qe7 9.O-O fxe6 10.Bg6+ Kd8 11.Bf4 b5 12.a4 134 | Bb7 13.Re1 Nd5 14.Bg3 Kc8 15.axb5 cxb5 16.Qd3 Bc6 17.Bf5 exf5 135 | 18.Rxe7 Bxe7 19.c4 1-0 136 | -------------------------------------------------------------------------------- /fuzz/corpus/pgn/kasparov-deep-blue-1997.pgn: -------------------------------------------------------------------------------- 1 | [Event "IBM Man-Machine, New York USA"] 2 | [Site "01"] 3 | [Date "1997.??.??"] 4 | [EventDate "?"] 5 | [Round "?"] 6 | [Result "1-0"] 7 | [White "Garry Kasparov"] 8 | [Black "Deep Blue (Computer)"] 9 | [ECO "A06"] 10 | [WhiteElo "?"] 11 | [BlackElo "?"] 12 | [PlyCount "89"] 13 | 14 | 1.Nf3 d5 2.g3 Bg4 3.b3 Nd7 4.Bb2 e6 5.Bg2 Ngf6 6.O-O c6 7.d3 15 | Bd6 8.Nbd2 O-O 9.h3 Bh5 10.e3 h6 11.Qe1 Qa5 12.a3 Bc7 13.Nh4 16 | g5 14.Nhf3 e5 15.e4 Rfe8 16.Nh2 Qb6 17.Qc1 a5 18.Re1 Bd6 17 | 19.Ndf1 dxe4 20.dxe4 Bc5 21.Ne3 Rad8 22.Nhf1 g4 23.hxg4 Nxg4 18 | 24.f3 Nxe3 25.Nxe3 Be7 26.Kh1 Bg5 27.Re2 a4 28.b4 f5 29.exf5 19 | e4 30.f4 Bxe2 31.fxg5 Ne5 32.g6 Bf3 33.Bc3 Qb5 34.Qf1 Qxf1+ 20 | 35.Rxf1 h5 36.Kg1 Kf8 37.Bh3 b5 38.Kf2 Kg7 39.g4 Kh6 40.Rg1 21 | hxg4 41.Bxg4 Bxg4 42.Nxg4+ Nxg4+ 43.Rxg4 Rd5 44.f6 Rd1 45.g7 22 | 1-0 23 | 24 | [Event "IBM Man-Machine, New York USA"] 25 | [Site "02"] 26 | [Date "1997.??.??"] 27 | [EventDate "?"] 28 | [Round "?"] 29 | [Result "1-0"] 30 | [White "Deep Blue (Computer)"] 31 | [Black "Garry Kasparov"] 32 | [ECO "C93"] 33 | [WhiteElo "?"] 34 | [BlackElo "?"] 35 | [PlyCount "89"] 36 | 37 | 1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Ba4 Nf6 5.O-O Be7 6.Re1 b5 7.Bb3 38 | d6 8.c3 O-O 9.h3 h6 10.d4 Re8 11.Nbd2 Bf8 12.Nf1 Bd7 13.Ng3 39 | Na5 14.Bc2 c5 15.b3 Nc6 16.d5 Ne7 17.Be3 Ng6 18.Qd2 Nh7 19.a4 40 | Nh4 20.Nxh4 Qxh4 21.Qe2 Qd8 22.b4 Qc7 23.Rec1 c4 24.Ra3 Rec8 41 | 25.Rca1 Qd8 26.f4 Nf6 27.fxe5 dxe5 28.Qf1 Ne8 29.Qf2 Nd6 42 | 30.Bb6 Qe8 31.R3a2 Be7 32.Bc5 Bf8 33.Nf5 Bxf5 34.exf5 f6 43 | 35.Bxd6 Bxd6 36.axb5 axb5 37.Be4 Rxa2 38.Qxa2 Qd7 39.Qa7 Rc7 44 | 40.Qb6 Rb7 41.Ra8+ Kf7 42.Qa6 Qc7 43.Qc6 Qb6+ 44.Kf1 Rb8 45 | 45.Ra6 1-0 46 | 47 | [Event "IBM Man-Machine, New York USA"] 48 | [Site "03"] 49 | [Date "1997.??.??"] 50 | [EventDate "?"] 51 | [Round "?"] 52 | [Result "1/2-1/2"] 53 | [White "Garry Kasparov"] 54 | [Black "Deep Blue (Computer)"] 55 | [ECO "A00"] 56 | [WhiteElo "?"] 57 | [BlackElo "?"] 58 | [PlyCount "95"] 59 | 60 | 1.d3 e5 2.Nf3 Nc6 3.c4 Nf6 4.a3 d6 5.Nc3 Be7 6.g3 O-O 7.Bg2 61 | Be6 8.O-O Qd7 9.Ng5 Bf5 10.e4 Bg4 11.f3 Bh5 12.Nh3 Nd4 13.Nf2 62 | h6 14.Be3 c5 15.b4 b6 16.Rb1 Kh8 17.Rb2 a6 18.bxc5 bxc5 19.Bh3 63 | Qc7 20.Bg4 Bg6 21.f4 exf4 22.gxf4 Qa5 23.Bd2 Qxa3 24.Ra2 Qb3 64 | 25.f5 Qxd1 26.Bxd1 Bh7 27.Nh3 Rfb8 28.Nf4 Bd8 29.Nfd5 Nc6 65 | 30.Bf4 Ne5 31.Ba4 Nxd5 32.Nxd5 a5 33.Bb5 Ra7 34.Kg2 g5 66 | 35.Bxe5+ dxe5 36.f6 Bg6 37.h4 gxh4 38.Kh3 Kg8 39.Kxh4 Kh7 67 | 40.Kg4 Bc7 41.Nxc7 Rxc7 42.Rxa5 Rd8 43.Rf3 Kh8 44.Kh4 Kg8 68 | 45.Ra3 Kh8 46.Ra6 Kh7 47.Ra3 Kh8 48.Ra6 1/2-1/2 69 | 70 | [Event "IBM Man-Machine, New York USA"] 71 | [Site "04"] 72 | [Date "1997.??.??"] 73 | [EventDate "?"] 74 | [Round "?"] 75 | [Result "1/2-1/2"] 76 | [White "Deep Blue (Computer)"] 77 | [Black "Garry Kasparov"] 78 | [ECO "B10"] 79 | [WhiteElo "?"] 80 | [BlackElo "?"] 81 | [PlyCount "111"] 82 | 83 | 1.e4 c6 2.d4 d6 3.Nf3 Nf6 4.Nc3 Bg4 5.h3 Bh5 6.Bd3 e6 7.Qe2 d5 84 | 8.Bg5 Be7 9.e5 Nfd7 10.Bxe7 Qxe7 11.g4 Bg6 12.Bxg6 hxg6 13.h4 85 | Na6 14.O-O-O O-O-O 15.Rdg1 Nc7 16.Kb1 f6 17.exf6 Qxf6 18.Rg3 86 | Rde8 19.Re1 Rhf8 20.Nd1 e5 21.dxe5 Qf4 22.a3 Ne6 23.Nc3 Ndc5 87 | 24.b4 Nd7 25.Qd3 Qf7 26.b5 Ndc5 27.Qe3 Qf4 28.bxc6 bxc6 29.Rd1 88 | Kc7 30.Ka1 Qxe3 31.fxe3 Rf7 32.Rh3 Ref8 33.Nd4 Rf2 34.Rb1 Rg2 89 | 35.Nce2 Rxg4 36.Nxe6+ Nxe6 37.Nd4 Nxd4 38.exd4 Rxd4 39.Rg1 Rc4 90 | 40.Rxg6 Rxc2 41.Rxg7+ Kb6 42.Rb3+ Kc5 43.Rxa7 Rf1+ 44.Rb1 Rff2 91 | 45.Rb4 Rc1+ 46.Rb1 Rcc2 47.Rb4 Rc1+ 48.Rb1 Rxb1+ 49.Kxb1 Re2 92 | 50.Re7 Rh2 51.Rh7 Kc4 52.Rc7 c5 53.e6 Rxh4 54.e7 Re4 55.a4 Kb3 93 | 56.Kc1 1/2-1/2 94 | 95 | [Event "IBM Man-Machine, New York USA"] 96 | [Site "05"] 97 | [Date "1997.??.??"] 98 | [EventDate "?"] 99 | [Round "?"] 100 | [Result "1/2-1/2"] 101 | [White "Garry Kasparov"] 102 | [Black "Deep Blue (Computer)"] 103 | [ECO "A07"] 104 | [WhiteElo "?"] 105 | [BlackElo "?"] 106 | [PlyCount "98"] 107 | 108 | 1.Nf3 d5 2.g3 Bg4 3.Bg2 Nd7 4.h3 Bxf3 5.Bxf3 c6 6.d3 e6 7.e4 109 | Ne5 8.Bg2 dxe4 9.Bxe4 Nf6 10.Bg2 Bb4+ 11.Nd2 h5 12.Qe2 Qc7 110 | 13.c3 Be7 14.d4 Ng6 15.h4 e5 16.Nf3 exd4 17.Nxd4 O-O-O 18.Bg5 111 | Ng4 19.O-O-O Rhe8 20.Qc2 Kb8 21.Kb1 Bxg5 22.hxg5 N6e5 23.Rhe1 112 | c5 24.Nf3 Rxd1+ 25.Rxd1 Nc4 26.Qa4 Rd8 27.Re1 Nb6 28.Qc2 Qd6 113 | 29.c4 Qg6 30.Qxg6 fxg6 31.b3 Nxf2 32.Re6 Kc7 33.Rxg6 Rd7 114 | 34.Nh4 Nc8 35.Bd5 Nd6 36.Re6 Nb5 37.cxb5 Rxd5 38.Rg6 Rd7 115 | 39.Nf5 Ne4 40.Nxg7 Rd1+ 41.Kc2 Rd2+ 42.Kc1 Rxa2 43.Nxh5 Nd2 116 | 44.Nf4 Nxb3+ 45.Kb1 Rd2 46.Re6 c4 47.Re3 Kb6 48.g6 Kxb5 49.g7 117 | Kb4 1/2-1/2 118 | 119 | [Event "IBM Man-Machine, New York USA"] 120 | [Site "06"] 121 | [Date "1997.??.??"] 122 | [EventDate "?"] 123 | [Round "?"] 124 | [Result "1-0"] 125 | [White "Deep Blue (Computer)"] 126 | [Black "Garry Kasparov"] 127 | [ECO "B17"] 128 | [WhiteElo "?"] 129 | [BlackElo "?"] 130 | [PlyCount "37"] 131 | 132 | 1.e4 c6 2.d4 d5 3.Nc3 dxe4 4.Nxe4 Nd7 5.Ng5 Ngf6 6.Bd3 e6 133 | 7.N1f3 h6 8.Nxe6 Qe7 9.O-O fxe6 10.Bg6+ Kd8 11.Bf4 b5 12.a4 134 | Bb7 13.Re1 Nd5 14.Bg3 Kc8 15.axb5 cxb5 16.Qd3 Bc6 17.Bf5 exf5 135 | 18.Rxe7 Bxe7 19.c4 1-0 136 | -------------------------------------------------------------------------------- /examples/perft/perft.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Run perft test to check correctness and speed of the legal move generator. 5 | """ 6 | 7 | import multiprocessing 8 | import multiprocessing.pool 9 | import functools 10 | import time 11 | import argparse 12 | import sys 13 | 14 | from typing import Callable, Iterator, Optional, TextIO, Type 15 | 16 | import chess 17 | import chess.variant 18 | 19 | 20 | def perft(depth: int, board: chess.Board) -> int: 21 | if depth == 1: 22 | return board.legal_moves.count() 23 | elif depth > 1: 24 | count = 0 25 | 26 | for move in board.legal_moves: 27 | board.push(move) 28 | count += perft(depth - 1, board) 29 | board.pop() 30 | 31 | return count 32 | else: 33 | return 1 34 | 35 | 36 | def parallel_perft(pool: multiprocessing.pool.Pool, depth: int, board: chess.Board) -> int: 37 | if depth == 1: 38 | return board.legal_moves.count() 39 | elif depth > 1: 40 | def successors(board: chess.Board) -> Iterator[chess.Board]: 41 | for move in board.legal_moves: 42 | board_after = board.copy(stack=False) 43 | board_after.push(move) 44 | yield board_after 45 | 46 | return sum(pool.imap_unordered(functools.partial(perft, depth - 1), successors(board))) 47 | else: 48 | return 1 49 | 50 | 51 | def sdiv(a: float, b: float) -> float: 52 | try: 53 | return a / b 54 | except ZeroDivisionError: 55 | return float("Inf") 56 | 57 | 58 | def main(perft_file: TextIO, VariantBoard: Type[chess.Board], perft_f: Callable[[int, chess.Board], int], max_depth: Optional[int], max_nodes: Optional[int]) -> None: 59 | current_id = None 60 | board = VariantBoard(chess960=True) 61 | column = 0 62 | total_nodes = 0 63 | start_time = time.perf_counter() 64 | 65 | for line in perft_file: 66 | # Skip comments and empty lines. 67 | line = line.strip() 68 | if not line or line.startswith("#") or line.startswith("%"): 69 | continue 70 | 71 | cmd, arg = line.split(None, 1) 72 | if cmd == "id": 73 | current_id = arg 74 | elif cmd == "epd": 75 | board.set_epd(arg) 76 | elif cmd == "perft": 77 | depth, nodes = map(int, arg.split(None, 1)) 78 | if (max_depth and depth > max_depth) or (max_nodes and nodes > max_nodes): 79 | continue 80 | 81 | perft_nodes = perft_f(depth, board) 82 | if nodes != perft_nodes: 83 | print() 84 | print() 85 | print(f" !!! Failure in {current_id or ''}") 86 | print(f" epd {board.epd()}") 87 | print(f" perft {depth} {nodes} (got {perft_nodes} instead)") 88 | print() 89 | print(board) 90 | print() 91 | for move in sorted(board.legal_moves, key=lambda m: m.uci()): 92 | board.push(move) 93 | print(f"{move}: {perft_f(depth - 1, board)}") 94 | board.pop() 95 | sys.exit(1) 96 | 97 | total_nodes += perft_nodes 98 | print(".", end="", flush=True) 99 | column += 1 100 | 101 | if column >= 40: 102 | column = 0 103 | sys.stdout.write(f" nodes {total_nodes} nps {sdiv(total_nodes, time.perf_counter() - start_time):.0f}\n") 104 | else: 105 | print() 106 | print("Unknown command:", cmd, arg) 107 | sys.exit(2) 108 | 109 | if column: 110 | sys.stdout.write(f" nodes {total_nodes} nps {sdiv(total_nodes, time.perf_counter() - start_time):.0f}\n") 111 | 112 | 113 | if __name__ == "__main__": 114 | parser = argparse.ArgumentParser(description=__doc__) 115 | parser.add_argument("perft", nargs="+", type=argparse.FileType("r"), 116 | help="Perft test suite(s)") 117 | parser.add_argument("--max-depth", type=int, help="Skip deeper perft tests") 118 | parser.add_argument("--max-nodes", type=int, default=1000000, 119 | help="Skip larger perft tests. Defaults to 1000000") 120 | parser.add_argument("-v", "--variant", default="standard", 121 | help="Use a non-standard chess variant") 122 | parser.add_argument("-t", "--threads", type=int, help="Number of threads") 123 | 124 | args = parser.parse_args() 125 | VariantBoard = chess.variant.find_variant(args.variant) 126 | 127 | if args.threads == 1: 128 | perft_f = perft 129 | else: 130 | pool = multiprocessing.Pool(args.threads) 131 | perft_f = functools.partial(parallel_perft, pool) 132 | 133 | for perft_file in args.perft: 134 | print("###", perft_file.name) 135 | main(perft_file, VariantBoard, perft_f, args.max_depth, args.max_nodes) 136 | -------------------------------------------------------------------------------- /examples/bratko_kopec/bratko_kopec.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """Run an EPD test suite with a UCI engine.""" 4 | 5 | import asyncio 6 | import argparse 7 | import itertools 8 | import logging 9 | import sys 10 | import typing 11 | 12 | from typing import List, Tuple, Type 13 | 14 | import chess 15 | import chess.engine 16 | import chess.variant 17 | 18 | 19 | def parse_epd(epd: str, VariantBoard: Type[chess.Board]) -> Tuple[chess.Board, str, List[chess.Move], List[chess.Move]]: 20 | board, epd_info = VariantBoard.from_epd(epd) 21 | 22 | description = str(epd_info.get("id", board.fen())) 23 | 24 | if "am" in epd_info: 25 | am = typing.cast(List[chess.Move], epd_info["am"]) 26 | description = "{} (avoid {})".format(description, " and ".join(board.san(m) for m in am)) 27 | else: 28 | am = [] 29 | 30 | if "bm" in epd_info: 31 | bm = typing.cast(List[chess.Move], epd_info["bm"]) 32 | description = "{} (expect {})".format(description, " or ".join(board.san(m) for m in bm)) 33 | else: 34 | bm = [] 35 | 36 | return board, description, am, bm 37 | 38 | 39 | async def test_epd(engine: chess.engine.Protocol, epd: str, VariantBoard: Type[chess.Board], movetime: float) -> float: 40 | board, description, am, bm = parse_epd(epd, VariantBoard) 41 | 42 | limit = chess.engine.Limit(time=movetime) 43 | result = await engine.play(board, limit, game=object()) 44 | 45 | if not result.move: 46 | print(f"{description}: -- | +0") 47 | return 0.0 48 | elif result.move in am: 49 | print(f"{description}: {board.san(result.move)} | +0") 50 | return 0.0 51 | elif bm and result.move not in bm: 52 | print(f"{description}: {board.san(result.move)} | +0") 53 | return 0.0 54 | else: 55 | print(f"{description}: {board.san(result.move)} | +1") 56 | return 1.0 57 | 58 | 59 | async def test_epd_with_fractional_scores(engine: chess.engine.Protocol, epd: str, VariantBoard: Type[chess.Board], movetime: float) -> float: 60 | board, description, am, bm = parse_epd(epd, VariantBoard) 61 | 62 | # Start analysis. 63 | score = 0.0 64 | print(f"{description}:", end=" ", flush=True) 65 | analysis = await engine.analysis(board, game=object()) 66 | 67 | with analysis: 68 | for step in range(0, 4): 69 | await asyncio.sleep(movetime / 4) 70 | 71 | # Assess the current principal variation. 72 | if "pv" in analysis.info and len(analysis.info["pv"]) >= 1: 73 | move = analysis.info["pv"][0] 74 | print(board.san(move), end=" ", flush=True) 75 | if move in am: 76 | continue # fail 77 | elif bm and move not in bm: 78 | continue # fail 79 | else: 80 | score = 1.0 / (4 - step) 81 | else: 82 | print("(no pv)", end=" ", flush=True) 83 | 84 | # Done. 85 | print(f"| +{score}") 86 | return score 87 | 88 | 89 | async def main() -> None: 90 | # Parse command line arguments. 91 | parser = argparse.ArgumentParser(description=__doc__) 92 | 93 | engine_group = parser.add_mutually_exclusive_group(required=True) 94 | engine_group.add_argument("-u", "--uci", 95 | help="The UCI engine under test.") 96 | engine_group.add_argument("-x", "--xboard", 97 | help="The XBoard engine under test.") 98 | 99 | parser.add_argument("epd", nargs="+", type=argparse.FileType("r"), 100 | help="EPD test suite(s).") 101 | parser.add_argument("-v", "--variant", default="standard", 102 | help="Use a non-standard chess variant.") 103 | parser.add_argument("-t", "--threads", default=1, type=int, 104 | help="Threads for use by the UCI engine.") 105 | parser.add_argument("-m", "--movetime", default=1.0, type=float, 106 | help="Time to move in seconds.") 107 | parser.add_argument("-s", "--simple", dest="test_epd", action="store_const", 108 | default=test_epd_with_fractional_scores, 109 | const=test_epd, 110 | help="Run in simple mode without fractional scores.") 111 | parser.add_argument("-d", "--debug", action="store_true", 112 | help="Show debug logs.") 113 | 114 | args = parser.parse_args() 115 | 116 | # Configure logger. 117 | logging.basicConfig(level=logging.DEBUG if args.debug else logging.WARNING) 118 | 119 | # Find variant. 120 | VariantBoard = chess.variant.find_variant(args.variant) 121 | 122 | # Open and configure engine. 123 | engine: chess.engine.Protocol 124 | if args.uci: 125 | _, engine = await chess.engine.popen_uci(args.uci) 126 | if args.threads > 1: 127 | await engine.configure({"Threads": args.threads}) 128 | else: 129 | _, engine = await chess.engine.popen_xboard(args.xboard) 130 | if args.threads > 1: 131 | await engine.configure({"cores": args.threads}) 132 | 133 | # Run each test line. 134 | score = 0.0 135 | count = 0 136 | 137 | for epd in itertools.chain(*args.epd): 138 | # Skip comments and empty lines. 139 | epd = epd.strip() 140 | if not epd or epd.startswith("#") or epd.startswith("%"): 141 | print(epd.rstrip()) 142 | continue 143 | 144 | # Run the actual test. 145 | score += await args.test_epd(engine, epd, VariantBoard, args.movetime) 146 | count += 1 147 | 148 | await engine.quit() 149 | 150 | print("-------------------------------") 151 | print(f"{score} / {count}") 152 | 153 | 154 | if __name__ == "__main__": 155 | asyncio.run(main()) 156 | -------------------------------------------------------------------------------- /data/gaviota/MD5SUMS.txt: -------------------------------------------------------------------------------- 1 | a8f890093de502c3e136e73780356f59 kbbbk.gtb.cp4 2 | 04bffa7e7414ae8d96b3a727ed5fe050 kbbkb.gtb.cp4 3 | 4fcdcf8aeae40ed340524d3064db8f00 kbbk.gtb.cp4 4 | 9b82696889d0144ed16975d4ae026fc9 kbbkn.gtb.cp4 5 | c69782fdcd8e206d47d4e76479342c93 kbbkp.gtb.cp4 6 | 76bacddb2b06151ee853b7067b8de78f kbbkq.gtb.cp4 7 | d79daa3ab2c49b5f9bab0e9cb4293852 kbbkr.gtb.cp4 8 | 6eb1d11108f2574fe8e6e3ff5436b717 kbbnk.gtb.cp4 9 | a94e07a402110066c29cfd4e5bbfe582 kbbpk.gtb.cp4 10 | ba458a182dab40ebe55b603436b2df6c kbkb.gtb.cp4 11 | d7a5b1b3ead671273ed96b41e0616510 kbk.gtb.cp4 12 | ab567cdcd5db194dc359a758b788de59 kbkn.gtb.cp4 13 | 6faa8559ec6d859d11fd1b910670baf2 kbkp.gtb.cp4 14 | 66142fc0b46b7940fc09df0997735eac kbnkb.gtb.cp4 15 | a8535ea4eaf24da8f39269405176c20d kbnk.gtb.cp4 16 | a4b4d2cc7428fc48fda81f8e55727802 kbnkn.gtb.cp4 17 | 74b529ca7d73186ce6414ec3f026f18a kbnkp.gtb.cp4 18 | 4a830baf7a59fa61ef14d22a7610f238 kbnkq.gtb.cp4 19 | dded1b638084872a87a0dad7ac13c744 kbnkr.gtb.cp4 20 | 140f5d3b5b0bfa8bb81344a8616f1884 kbnnk.gtb.cp4 21 | 62bc5067166360a75b6e8eca2264ebaf kbnpk.gtb.cp4 22 | 3a1aae1fcd1cdb6ccad5e85a3c5a258a kbpkb.gtb.cp4 23 | 15bf2c4eda7ce13f365ffcc415f43755 kbpk.gtb.cp4 24 | 28c023da2920a6fae7fb1072d4ba2efc kbpkn.gtb.cp4 25 | acbfd3cbd7e1c599ad66536230471146 kbpkp.gtb.cp4 26 | 77b78d4e0f3733971356ee327c8a11cd kbpkq.gtb.cp4 27 | 2528ea44f6c998b766360b2419cb3bf5 kbpkr.gtb.cp4 28 | 984b96cffc7abaf0652e56385b24bec1 kbppk.gtb.cp4 29 | 5b56485e4c99f2d91172d4676a0de939 knk.gtb.cp4 30 | 6dad70682e806c4b8857126fd0c00ef6 knkn.gtb.cp4 31 | 5c6386b80580d428db86ac6660af0407 knkp.gtb.cp4 32 | d0ac83502ff3177704b49a14f05aae21 knnkb.gtb.cp4 33 | 0c098f3f87e951148347ab05ba3f83ad knnk.gtb.cp4 34 | 0fc7014da6ebb46639d73fa0c7019b25 knnkn.gtb.cp4 35 | 5768291aec98fa3e5101ee8cdb840207 knnkp.gtb.cp4 36 | 8680eeb6319ad7ad5ed64df0a5bede06 knnkq.gtb.cp4 37 | af8646512e16feb9fff32a0a974df267 knnkr.gtb.cp4 38 | 18f41848a10dd0a29dd654f52f4bef1e knnnk.gtb.cp4 39 | 97c84fed8d00a997d64283ab28a71eb9 knnpk.gtb.cp4 40 | 39923cb8966170e600e57280f91bb2a2 knpkb.gtb.cp4 41 | 181a3ea0ee0c9fff38074fa5c5c116d1 knpk.gtb.cp4 42 | 6c7eda069bbc38cc8e52fc88fac46eb6 knpkn.gtb.cp4 43 | 34fbb37b8d058e5b5cef3633009230fb knpkp.gtb.cp4 44 | 58a30bb06cbb9ed62cc291cf512a1a36 knpkq.gtb.cp4 45 | 2b51af797ecff8089fe88db53ceb2a23 knpkr.gtb.cp4 46 | 4a88a971f2a15bb593a7161ef9d45649 knppk.gtb.cp4 47 | ecaa0490d03cc256b5183eddee44d035 kpk.gtb.cp4 48 | ce6140faf1be7b9a3f0b4f2bcc865cba kpkp.gtb.cp4 49 | 9165a27cd193f45c7220d6a6b958b77d kppkb.gtb.cp4 50 | 6394960362d45f3890966908faff8e08 kppk.gtb.cp4 51 | 999d73c6ae63d1b9af9a502d6d4bdd75 kppkn.gtb.cp4 52 | a305cf31262bb8fe0c16c7a08a12e02c kppkp.gtb.cp4 53 | a3b310ca7ad2832d514397d7f555f5b0 kppkq.gtb.cp4 54 | 65af4818e2900e9d71e3826a63b64690 kppkr.gtb.cp4 55 | 482f44afc2f79e9a5fad4b4999f5ebb8 kpppk.gtb.cp4 56 | 531ba8063886d60060f2109a651b9184 kqbbk.gtb.cp4 57 | 6da22d75bfd0ea65158c92df4f91fbfd kqbkb.gtb.cp4 58 | 4f2ce5825092badb27ac9f043618a757 kqbk.gtb.cp4 59 | c02c88aba3965c599c46fdc8b17083b4 kqbkn.gtb.cp4 60 | b1fbf3ef4b29228169b607a80ebb3c40 kqbkp.gtb.cp4 61 | 2d9aa0de54333b7420e57caf304b090b kqbkq.gtb.cp4 62 | 183cd91d512cd3f3b2c2fb02b87db5d1 kqbkr.gtb.cp4 63 | 92618cb777f11d0852fd929f11b6aefb kqbnk.gtb.cp4 64 | c35ff872e9a96a1a16e9439cd4654309 kqbpk.gtb.cp4 65 | ca66e0dde89d878ae4e169c7d215f394 kqkb.gtb.cp4 66 | c80c5b3e32f601dfaa7f3f6b6a431ef7 kqk.gtb.cp4 67 | c2595ff5cbecce1da16a74ab6320a41f kqkn.gtb.cp4 68 | 3f67e8e868da5e5d041149409ec68dda kqkp.gtb.cp4 69 | 43d12fb52c7290b50a3291563f91c85b kqkq.gtb.cp4 70 | d0280706e743b4321aa5d17fc2b559e0 kqkr.gtb.cp4 71 | bd6afd6c2ffb765bf71ec92df4b54c78 kqnkb.gtb.cp4 72 | 0f10dda2145623eedfb8448db0d142fd kqnk.gtb.cp4 73 | a3caf7f1eb2a2a1298e7defcd437dea9 kqnkn.gtb.cp4 74 | ec32dfa1fc5219e55cb7effa0a5780e5 kqnkp.gtb.cp4 75 | ccc3ff0a7f1de7f874e07c99de7eef25 kqnkq.gtb.cp4 76 | cc12538e4ff9e6243ab136144a8c9f52 kqnkr.gtb.cp4 77 | 0d7d0ac820bcf5b726ddf25bcd4fdb29 kqnnk.gtb.cp4 78 | 5424c1c560928cdffde9b9a9c04b794a kqnpk.gtb.cp4 79 | 2c63aefb98b74d76e63b136b18359ef5 kqpkb.gtb.cp4 80 | 4b3bca9064e50169830cd6df4140cc31 kqpk.gtb.cp4 81 | 67e29251acef7501ec9aa3586ac849cb kqpkn.gtb.cp4 82 | 210823e26ad07483bbd8313cb9d9226f kqpkp.gtb.cp4 83 | 89a58dbed5a816bf95c43acafbd8d0cf kqpkq.gtb.cp4 84 | 5e972e913ad9a9fd174c182055db3436 kqpkr.gtb.cp4 85 | 72cfe4cf6b15098b9398e7cb86b0c622 kqppk.gtb.cp4 86 | 0414d5ab06526ae141c0d3f6338e0412 kqqbk.gtb.cp4 87 | f236d8782ab4492264026acbd006218c kqqkb.gtb.cp4 88 | 40cd9c8dbdc7a214c72f4d92d62ca293 kqqk.gtb.cp4 89 | b37688f6deaa0a333616ffdd9b886453 kqqkn.gtb.cp4 90 | d4bb160dc4aeaeec2e1953bd81b66cac kqqkp.gtb.cp4 91 | 6df046cef68f3dd1cbcd822cf2dfb626 kqqkq.gtb.cp4 92 | 80e306b557a9cc7af05495a151642a00 kqqkr.gtb.cp4 93 | 785e8e5895856144695cd6ab88e45173 kqqnk.gtb.cp4 94 | 5dfc76bc714ab8e045ce5a6dd840ac00 kqqpk.gtb.cp4 95 | 868a980f137122641a80b1079e2e4e8b kqqqk.gtb.cp4 96 | 0f117c298bc47dbbb138ca89331fd9cd kqqrk.gtb.cp4 97 | 97e1b72d3dfc22e1ae629e801b8151d1 kqrbk.gtb.cp4 98 | b4dcc3d37b19b8118f8450297f9e7298 kqrkb.gtb.cp4 99 | 98a640759dc1a41442a733a408614b3d kqrk.gtb.cp4 100 | 3fa3f1d4c6a037d89c70931c9c173d68 kqrkn.gtb.cp4 101 | 4a2b1f72ed228f3b630e31c4bc7b865b kqrkp.gtb.cp4 102 | 43ba93d167fa2d3fc61b3aa7f661baa2 kqrkq.gtb.cp4 103 | b07d79302a632706d8397f0e0ad17358 kqrkr.gtb.cp4 104 | 60ecea32b15a8134aa3d5ae7e7fd9155 kqrnk.gtb.cp4 105 | 78503609013afef7680aeea8ad6fffc3 kqrpk.gtb.cp4 106 | 1caf14ef4e63f1f11d3ad640905b30e3 kqrrk.gtb.cp4 107 | 3ada834784208fedf8d063939fc2162a krbbk.gtb.cp4 108 | 8b7af56135ec11b7a487c3a45781e400 krbkb.gtb.cp4 109 | 94436bdbde50a729bfdc4b0c555b461b krbk.gtb.cp4 110 | 6dd48d2c3c8f3d2f13a1bc0edf12dbeb krbkn.gtb.cp4 111 | 9ed81ee94967377d112a416871991e4c krbkp.gtb.cp4 112 | ebd0fd750340258c017c5191f3bf8e87 krbkq.gtb.cp4 113 | 5317cab585889301053879d864222fb5 krbkr.gtb.cp4 114 | fc60350011c4c9401cd1009a4c57f9f7 krbnk.gtb.cp4 115 | b61a73019d16632a184e204c5e4c853c krbpk.gtb.cp4 116 | 495fe78e5114fc3f71fde18c200a7cb9 krkb.gtb.cp4 117 | 959fd626c3ef3183aa4ddeca4ecf63a6 krk.gtb.cp4 118 | 7205930e8b753b72e8126c9ddb71ef96 krkn.gtb.cp4 119 | c7265398554b100b27f3073c9fa40b02 krkp.gtb.cp4 120 | 05cb36f60da56ba5bdf199e3073b391b krkr.gtb.cp4 121 | 902a8495997a68268ab8ff13995ca406 krnkb.gtb.cp4 122 | 774968a2412336ff2877c7bce065eede krnk.gtb.cp4 123 | e082f01333a90024fc893d9a8490d46c krnkn.gtb.cp4 124 | 1005b5b5911975b14920ea74e972fb77 krnkp.gtb.cp4 125 | bc045beda2fe9d76b20fab45c4dff056 krnkq.gtb.cp4 126 | 02db6817c92183ac3946fe11df091a05 krnkr.gtb.cp4 127 | 209fd5a5243ae7f0485a1e9fe9ede45b krnnk.gtb.cp4 128 | b061faf8b6a17a098f8afbba343a55ef krnpk.gtb.cp4 129 | 657436f28c4c739b2d449e94ee388bfe krpkb.gtb.cp4 130 | e16129bc69cdc655c11d0d58c02461c5 krpk.gtb.cp4 131 | 346ff695f92adae7be6d4f8baa76d799 krpkn.gtb.cp4 132 | 5c61d50b5e4ccbfe9cf1355f53365c02 krpkp.gtb.cp4 133 | d674b3296276a75260d18d2f4c3eb307 krpkq.gtb.cp4 134 | 59f3e3f392937b02c2530244944a6c25 krpkr.gtb.cp4 135 | 59bd05f7ac4359fe8a6b239991904e43 krppk.gtb.cp4 136 | c157625aab03ca7b809d3188063e6aa0 krrbk.gtb.cp4 137 | ac98073e8646b2c756853e7c74673a1d krrkb.gtb.cp4 138 | 9e61da42b0b345c66a71db00f15a38b8 krrk.gtb.cp4 139 | 215cc6e989bc50a209af13a52f481a66 krrkn.gtb.cp4 140 | 9119c5f01ebcf3f1b189f9425fca1715 krrkp.gtb.cp4 141 | 7f78c8b41d4b5abc610a1817ced75753 krrkq.gtb.cp4 142 | f7fe3ec24945f940cffc7a8e7a42c0d7 krrkr.gtb.cp4 143 | f975b76cf64ca964346b42808cded508 krrnk.gtb.cp4 144 | 88bba6d0554e136ce8590d6c137085e7 krrpk.gtb.cp4 145 | edca4203628a99fd66b90411a975447b krrrk.gtb.cp4 146 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/python-chess.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/python-chess.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/python-chess" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/python-chess" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\python-chess.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\python-chess.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /docs/engine.rst: -------------------------------------------------------------------------------- 1 | UCI/XBoard engine communication 2 | =============================== 3 | 4 | The `Universal chess interface (UCI) `_ 5 | and `XBoard protocol `_ 6 | are standards for communicating with chess engines. This module 7 | implements an abstraction for playing moves and analysing positions with 8 | both kinds of engines. 9 | 10 | .. warning:: 11 | Many popular chess engines make no guarantees, not even memory 12 | safety, when parameters and positions are not completely 13 | :func:`valid `. This module tries to deal with 14 | benign misbehaving engines, but ultimately they are executables running 15 | on your system. 16 | 17 | The preferred way to use the API is with an 18 | `asyncio `_ event loop. 19 | The examples also show a synchronous wrapper 20 | :class:`~chess.engine.SimpleEngine` that automatically spawns an event loop 21 | in the background. 22 | :class:`~chess.engine.SimpleEngine` methods block until there is a result. 23 | 24 | Playing 25 | ------- 26 | 27 | Example: Let Stockfish play against itself, 100 milliseconds per move. 28 | 29 | .. code-block:: python 30 | :caption: Using synchronous :class:`~chess.engine.SimpleEngine` 31 | 32 | import chess 33 | import chess.engine 34 | 35 | engine = chess.engine.SimpleEngine.popen_uci(r"C:\Users\xxxxx\Downloads\stockfish_14_win_x64\stockfish_14_win_x64_avx2.exe") 36 | 37 | board = chess.Board() 38 | while not board.is_game_over(): 39 | result = engine.play(board, chess.engine.Limit(time=0.1)) 40 | board.push(result.move) 41 | 42 | engine.quit() 43 | 44 | .. code-block:: python 45 | :caption: Using asyncio 46 | 47 | import asyncio 48 | import chess 49 | import chess.engine 50 | 51 | async def main() -> None: 52 | transport, engine = await chess.engine.popen_uci(r"C:\Users\xxxxx\Downloads\stockfish_14_win_x64\stockfish_14_win_x64_avx2.exe") 53 | 54 | board = chess.Board() 55 | while not board.is_game_over(): 56 | result = await engine.play(board, chess.engine.Limit(time=0.1)) 57 | board.push(result.move) 58 | 59 | await engine.quit() 60 | 61 | asyncio.run(main()) 62 | 63 | .. autoclass:: chess.engine.Protocol 64 | :members: play 65 | 66 | .. autoclass:: chess.engine.Limit 67 | :members: 68 | 69 | .. autoclass:: chess.engine.PlayResult 70 | :members: 71 | 72 | .. autoclass:: chess.engine.Protocol 73 | :members: send_opponent_information 74 | 75 | .. autoclass:: chess.engine.Opponent 76 | :members: 77 | 78 | .. autoclass:: chess.engine.Protocol 79 | :members: send_game_result 80 | 81 | Analysing and evaluating a position 82 | ----------------------------------- 83 | 84 | Example: 85 | 86 | .. code-block:: python 87 | :caption: Using synchronous :class:`~chess.engine.SimpleEngine` 88 | 89 | import chess 90 | import chess.engine 91 | 92 | engine = chess.engine.SimpleEngine.popen_uci("/usr/bin/stockfish") 93 | 94 | board = chess.Board() 95 | info = engine.analyse(board, chess.engine.Limit(time=0.1)) 96 | print("Score:", info["score"]) 97 | # Score: PovScore(Cp(+20), WHITE) 98 | 99 | board = chess.Board("r1bqkbnr/p1pp1ppp/1pn5/4p3/2B1P3/5Q2/PPPP1PPP/RNB1K1NR w KQkq - 2 4") 100 | info = engine.analyse(board, chess.engine.Limit(depth=20)) 101 | print("Score:", info["score"]) 102 | # Score: PovScore(Mate(+1), WHITE) 103 | 104 | engine.quit() 105 | 106 | .. code-block:: python 107 | :caption: Using asyncio 108 | 109 | import asyncio 110 | import chess 111 | import chess.engine 112 | 113 | async def main() -> None: 114 | transport, engine = await chess.engine.popen_uci("/usr/bin/stockfish") 115 | 116 | board = chess.Board() 117 | info = await engine.analyse(board, chess.engine.Limit(time=0.1)) 118 | print(info["score"]) 119 | # Score: PovScore(Cp(+20), WHITE) 120 | 121 | board = chess.Board("r1bqkbnr/p1pp1ppp/1pn5/4p3/2B1P3/5Q2/PPPP1PPP/RNB1K1NR w KQkq - 2 4") 122 | info = await engine.analyse(board, chess.engine.Limit(depth=20)) 123 | print(info["score"]) 124 | # Score: PovScore(Mate(+1), WHITE) 125 | 126 | await engine.quit() 127 | 128 | asyncio.run(main()) 129 | 130 | .. autoclass:: chess.engine.Protocol 131 | :members: analyse 132 | 133 | .. autoclass:: chess.engine.InfoDict 134 | 135 | .. autoclass:: chess.engine.PovScore 136 | :members: 137 | 138 | .. autoclass:: chess.engine.Score 139 | :members: 140 | 141 | .. autoclass:: chess.engine.PovWdl 142 | :members: 143 | 144 | .. autoclass:: chess.engine.Wdl 145 | :members: 146 | 147 | Indefinite or infinite analysis 148 | ------------------------------- 149 | 150 | Example: Stream information from the engine and stop on an arbitrary condition. 151 | 152 | .. code-block:: python 153 | :caption: Using synchronous :class:`~chess.engine.SimpleEngine` 154 | 155 | import chess 156 | import chess.engine 157 | 158 | engine = chess.engine.SimpleEngine.popen_uci("/usr/bin/stockfish") 159 | 160 | with engine.analysis(chess.Board()) as analysis: 161 | for info in analysis: 162 | print(info.get("score"), info.get("pv")) 163 | 164 | # Arbitrary stop condition. 165 | if info.get("seldepth", 0) > 20: 166 | break 167 | 168 | engine.quit() 169 | 170 | .. code-block:: python 171 | :caption: Using asyncio 172 | 173 | import asyncio 174 | import chess 175 | import chess.engine 176 | 177 | async def main() -> None: 178 | transport, engine = await chess.engine.popen_uci("/usr/bin/stockfish") 179 | 180 | with await engine.analysis(chess.Board()) as analysis: 181 | async for info in analysis: 182 | print(info.get("score"), info.get("pv")) 183 | 184 | # Arbitrary stop condition. 185 | if info.get("seldepth", 0) > 20: 186 | break 187 | 188 | await engine.quit() 189 | 190 | asyncio.run(main()) 191 | 192 | .. autoclass:: chess.engine.Protocol 193 | :members: analysis 194 | 195 | .. autoclass:: chess.engine.AnalysisResult 196 | :members: 197 | 198 | .. autoclass:: chess.engine.BestMove 199 | :members: 200 | 201 | Options 202 | ------- 203 | 204 | :func:`~chess.Protocol.configure()`, 205 | :func:`~chess.Protocol.play()`, 206 | :func:`~chess.Protocol.analyse()` and 207 | :func:`~chess.Protocol.analysis()` accept a dictionary of options. 208 | 209 | .. code-block:: python 210 | :caption: Using synchronous :class:`~chess.engine.SimpleEngine` 211 | 212 | import chess.engine 213 | 214 | engine = chess.engine.SimpleEngine.popen_uci("/usr/bin/stockfish") 215 | 216 | # Check available options. 217 | engine.options["Hash"] 218 | # Option(name='Hash', type='spin', default=16, min=1, max=131072, var=[]) 219 | 220 | # Set an option. 221 | engine.configure({"Hash": 32}) 222 | 223 | # [...] 224 | 225 | .. code-block:: python 226 | :caption: Using asyncio 227 | 228 | import asyncio 229 | import chess.engine 230 | 231 | async def main() -> None: 232 | transport, engine = await chess.engine.popen_uci("/usr/bin/stockfish") 233 | 234 | # Check available options. 235 | print(engine.options["Hash"]) 236 | # Option(name='Hash', type='spin', default=16, min=1, max=131072, var=[]) 237 | 238 | # Set an option. 239 | await engine.configure({"Hash": 32}) 240 | 241 | # [...] 242 | 243 | asyncio.run(main()) 244 | 245 | .. autoclass:: chess.engine.Protocol 246 | :members: options, configure 247 | 248 | .. autoclass:: chess.engine.Option 249 | :members: 250 | 251 | Logging 252 | ------- 253 | 254 | Communication is logged with debug level on a logger named ``chess.engine``. 255 | Debug logs are useful while troubleshooting. Please also provide them 256 | when submitting bug reports. 257 | 258 | .. code:: python 259 | 260 | import logging 261 | 262 | # Enable debug logging. 263 | logging.basicConfig(level=logging.DEBUG) 264 | 265 | AsyncSSH 266 | -------- 267 | 268 | :class:`chess.engine.Protocol` can also be used with 269 | `AsyncSSH `_ (since 1.16.0) 270 | to communicate with an engine on a remote computer. 271 | 272 | .. code:: python 273 | 274 | import asyncio 275 | import asyncssh 276 | import chess 277 | import chess.engine 278 | 279 | async def main() -> None: 280 | async with asyncssh.connect("localhost") as conn: 281 | channel, engine = await conn.create_subprocess(chess.engine.UciProtocol, "/usr/bin/stockfish") 282 | await engine.initialize() 283 | 284 | # Play, analyse, ... 285 | await engine.ping() 286 | 287 | asyncio.run(main()) 288 | 289 | Reference 290 | --------- 291 | 292 | .. autoclass:: chess.engine.EngineError 293 | 294 | .. autoclass:: chess.engine.EngineTerminatedError 295 | 296 | .. autoclass:: chess.engine.AnalysisComplete 297 | 298 | .. autofunction:: chess.engine.popen_uci 299 | 300 | .. autofunction:: chess.engine.popen_xboard 301 | 302 | .. autoclass:: chess.engine.Protocol 303 | :members: id, returncode, initialize, ping, quit 304 | 305 | .. autoclass:: chess.engine.UciProtocol 306 | 307 | .. autoclass:: chess.engine.XBoardProtocol 308 | 309 | .. autoclass:: chess.engine.SimpleEngine 310 | :members: 311 | 312 | .. autoclass:: chess.engine.SimpleAnalysisResult 313 | :members: 314 | -------------------------------------------------------------------------------- /data/gaviota/SOURCE.txt: -------------------------------------------------------------------------------- 1 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbk.gtb.cp4 2 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knk.gtb.cp4 3 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kpk.gtb.cp4 4 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqk.gtb.cp4 5 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krk.gtb.cp4 6 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbbk.gtb.cp4 7 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbkb.gtb.cp4 8 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbkn.gtb.cp4 9 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbkp.gtb.cp4 10 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbnk.gtb.cp4 11 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbpk.gtb.cp4 12 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knkn.gtb.cp4 13 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knkp.gtb.cp4 14 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnk.gtb.cp4 15 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knpk.gtb.cp4 16 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kpkp.gtb.cp4 17 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kppk.gtb.cp4 18 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbk.gtb.cp4 19 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqkb.gtb.cp4 20 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqkn.gtb.cp4 21 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqkp.gtb.cp4 22 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqkq.gtb.cp4 23 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqkr.gtb.cp4 24 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqnk.gtb.cp4 25 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqpk.gtb.cp4 26 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqk.gtb.cp4 27 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrk.gtb.cp4 28 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krbk.gtb.cp4 29 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krkb.gtb.cp4 30 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krkn.gtb.cp4 31 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krkp.gtb.cp4 32 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krkr.gtb.cp4 33 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnk.gtb.cp4 34 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krpk.gtb.cp4 35 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrk.gtb.cp4 36 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbbbk.gtb.cp4 37 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbbkb.gtb.cp4 38 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbbkn.gtb.cp4 39 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbbkp.gtb.cp4 40 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbbkq.gtb.cp4 41 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbbkr.gtb.cp4 42 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbbnk.gtb.cp4 43 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbbpk.gtb.cp4 44 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbnkb.gtb.cp4 45 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbnkn.gtb.cp4 46 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbnkp.gtb.cp4 47 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbnkq.gtb.cp4 48 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbnkr.gtb.cp4 49 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbnnk.gtb.cp4 50 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbnpk.gtb.cp4 51 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbpkb.gtb.cp4 52 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbpkn.gtb.cp4 53 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbpkp.gtb.cp4 54 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbpkq.gtb.cp4 55 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbpkr.gtb.cp4 56 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kbppk.gtb.cp4 57 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnkb.gtb.cp4 58 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnkn.gtb.cp4 59 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnkp.gtb.cp4 60 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnkq.gtb.cp4 61 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnkr.gtb.cp4 62 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnnk.gtb.cp4 63 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knnpk.gtb.cp4 64 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knpkb.gtb.cp4 65 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knpkn.gtb.cp4 66 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knpkp.gtb.cp4 67 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knpkq.gtb.cp4 68 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knpkr.gtb.cp4 69 | https://tablebase.lichess.ovh/tables/standard/Gaviota/knppk.gtb.cp4 70 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kppkb.gtb.cp4 71 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kppkn.gtb.cp4 72 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kppkp.gtb.cp4 73 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kppkq.gtb.cp4 74 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kppkr.gtb.cp4 75 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kpppk.gtb.cp4 76 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbbk.gtb.cp4 77 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbkb.gtb.cp4 78 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbkn.gtb.cp4 79 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbkp.gtb.cp4 80 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbkq.gtb.cp4 81 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbkr.gtb.cp4 82 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbnk.gtb.cp4 83 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqbpk.gtb.cp4 84 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqnkb.gtb.cp4 85 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqnkn.gtb.cp4 86 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqnkp.gtb.cp4 87 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqnkq.gtb.cp4 88 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqnkr.gtb.cp4 89 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqnnk.gtb.cp4 90 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqnpk.gtb.cp4 91 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqpkb.gtb.cp4 92 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqpkn.gtb.cp4 93 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqpkp.gtb.cp4 94 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqpkq.gtb.cp4 95 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqpkr.gtb.cp4 96 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqppk.gtb.cp4 97 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqbk.gtb.cp4 98 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqkb.gtb.cp4 99 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqkn.gtb.cp4 100 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqkp.gtb.cp4 101 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqkq.gtb.cp4 102 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqkr.gtb.cp4 103 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqnk.gtb.cp4 104 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqpk.gtb.cp4 105 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqqk.gtb.cp4 106 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqqrk.gtb.cp4 107 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrbk.gtb.cp4 108 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrkb.gtb.cp4 109 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrkn.gtb.cp4 110 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrkp.gtb.cp4 111 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrkq.gtb.cp4 112 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrkr.gtb.cp4 113 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrnk.gtb.cp4 114 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrpk.gtb.cp4 115 | https://tablebase.lichess.ovh/tables/standard/Gaviota/kqrrk.gtb.cp4 116 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krbbk.gtb.cp4 117 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krbkb.gtb.cp4 118 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krbkn.gtb.cp4 119 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krbkp.gtb.cp4 120 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krbkq.gtb.cp4 121 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krbkr.gtb.cp4 122 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krbnk.gtb.cp4 123 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krbpk.gtb.cp4 124 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnkb.gtb.cp4 125 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnkn.gtb.cp4 126 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnkp.gtb.cp4 127 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnkq.gtb.cp4 128 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnkr.gtb.cp4 129 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnnk.gtb.cp4 130 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krnpk.gtb.cp4 131 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krpkb.gtb.cp4 132 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krpkn.gtb.cp4 133 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krpkp.gtb.cp4 134 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krpkq.gtb.cp4 135 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krpkr.gtb.cp4 136 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krppk.gtb.cp4 137 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrbk.gtb.cp4 138 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrkb.gtb.cp4 139 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrkn.gtb.cp4 140 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrkp.gtb.cp4 141 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrkq.gtb.cp4 142 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrkr.gtb.cp4 143 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrnk.gtb.cp4 144 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrpk.gtb.cp4 145 | https://tablebase.lichess.ovh/tables/standard/Gaviota/krrrk.gtb.cp4 146 | -------------------------------------------------------------------------------- /data/pgn/cutechess-fischerrandom.pgn: -------------------------------------------------------------------------------- 1 | [Event "?"] 2 | [Site "?"] 3 | [Date "2016.07.28"] 4 | [Round "1"] 5 | [White "Maverick 1.5"] 6 | [Black "Stockfish 7"] 7 | [Result "0-1"] 8 | [FEN "nbbrknrq/pppppppp/8/8/8/8/PPPPPPPP/NBBRKNRQ w KQkq - 0 1"] 9 | [PlyCount "120"] 10 | [SetUp "1"] 11 | [TimeControl "10+0.05"] 12 | [Variant "fischerandom"] 13 | 14 | 1. d4 {+0.13/12 0.29s} d5 {-0.17/15 0.30s} 2. c3 {+0.22/13 0.28s} 15 | Nb6 {-0.17/14 0.14s} 3. e4 {+0.21/13 0.95s} dxe4 {+0.14/13 0.29s} 16 | 4. Bxe4 {+0.25/12 0.22s} g6 {-0.03/15 0.69s} 5. g4 {+0.31/11 0.30s} 17 | c6 {+0.26/13 0.19s} 6. Qf3 {+0.29/11 0.30s} Ne6 {+0.25/15 0.67s} 18 | 7. Nb3 {+0.22/10 0.35s} Qf6 {+0.23/15 0.14s} 8. Qxf6 {+0.34/12 0.27s} 19 | exf6 {+0.25/15 0.13s} 9. h4 {+0.32/12 0.39s} O-O {+0.20/15 0.073s} 20 | 10. Be3 {+0.15/11 0.33s} Nf4 {+0.68/14 0.60s} 11. Nc5 {+0.21/10 0.17s} 21 | Rfe8 {+0.77/15 0.34s} 12. Nd2 {0.00/10 0.25s} Nbd5 {+1.24/14 0.27s} 22 | 13. c4 {0.00/10 0.16s} b6 {+1.51/14 0.19s} 14. cxd5 {-0.26/10 0.15s} 23 | cxd5 {+1.69/12 0.030s} 15. Bc2 {-1.01/10 0.23s} bxc5 {+2.00/14 0.29s} 24 | 16. Nb3 {-1.29/11 0.17s} c4 {+1.82/15 0.50s} 17. Nc5 {-1.25/13 0.22s} 25 | Bd6 {+2.05/15 0.19s} 18. Ba4 {-1.31/10 0.20s} Re7 {+1.91/15 0.27s} 26 | 19. Bc2 {-1.46/10 0.15s} h5 {+2.11/16 0.82s} 20. gxh5 {-1.62/12 0.20s} 27 | Nxh5 {+1.89/16 0.43s} 21. O-O-O {-1.50/11 0.22s} Nf4 {+2.04/15 0.36s} 28 | 22. Rde1 {-1.74/10 0.13s} Kg7 {+2.14/15 0.20s} 23. h5 {-1.65/11 0.15s} 29 | Nxh5 {+2.23/12 0.030s} 24. Kd2 {-1.92/10 0.19s} f5 {+2.43/14 0.36s} 30 | 25. Bg5 {-1.74/10 0.15s} Rxe1 {+2.37/15 0.22s} 26. Rxe1 {-2.13/11 0.17s} 31 | f6 {+3.39/15 0.20s} 27. Bh4 {-2.74/13 0.14s} g5 {+3.22/13 0.13s} 32 | 28. Rg1 {-2.88/13 0.15s} Rh8 {+4.22/15 0.44s} 29. Bd1 {-2.88/10 0.15s} 33 | Kf8 {+4.10/16 0.24s} 30. Bg3 {-3.61/12 0.14s} f4 {+4.29/16 0.25s} 34 | 31. Bh2 {-3.70/13 0.15s} Ng7 {+4.40/14 0.038s} 32. Rh1 {-4.06/14 0.23s} 35 | Nf5 {+4.48/16 0.17s} 33. Bg4 {-4.56/13 0.11s} Ke7 {+4.60/14 0.021s} 36 | 34. Bxf5 {-4.14/11 0.13s} Bxf5 {+4.70/16 0.16s} 35. f3 {-4.34/12 0.25s} 37 | Rh3 {+4.84/15 0.092s} 36. Ke2 {-5.89/12 0.32s} g4 {+4.83/13 0.025s} 38 | 37. fxg4 {-4.74/11 0.13s} Bg6 {+4.91/15 0.079s} 38. Ke1 {-4.95/10 0.12s} 39 | Bxc5 {+5.01/13 0.038s} 39. dxc5 {-5.95/12 0.14s} Be4 {+5.22/14 0.11s} 40 | 40. a4 {-6.42/12 0.38s} Bxh1 {+5.82/13 0.079s} 41. Bxf4 {-7.92/12 0.12s} 41 | d4 {+5.91/13 0.033s} 42. Kd2 {-6.92/10 0.083s} Kd7 {+6.10/14 0.082s} 42 | 43. g5 {-7.26/10 0.11s} fxg5 {+6.57/15 0.11s} 44. Bxg5 {-8.34/10 0.091s} 43 | Kc6 {+6.81/13 0.026s} 45. Bf4 {-8.56/11 0.20s} Kxc5 {+7.90/15 0.14s} 44 | 46. a5 {-8.94/11 0.17s} Be4 {+11.14/16 0.22s} 47. a6 {-9.64/10 0.10s} 45 | Rb3 {+15.84/15 0.094s} 48. Kc1 {-11.49/13 0.12s} c3 {+48.50/24 0.078s} 46 | 49. bxc3 {-10.88/13 0.088s} dxc3 {+48.54/23 0.018s} 50. Kd1 {-11.10/13 0.17s} 47 | c2+ {+M35/23 0.14s} 51. Ke2 {-10.72/12 0.16s} Rb1 {+M31/23 0.024s} 48 | 52. Bd2 {-11.36/12 0.080s} c1=Q {+M21/24 0.076s} 53. Bxc1 {-12.14/14 0.11s} 49 | Rxc1 {+M19/23 0.025s} 54. Ke3 {-12.35/13 0.072s} Kd5 {+M15/23 0.10s} 50 | 55. Kf2 {-M18/13 0.14s} Kd4 {+M11/24 0.070s} 56. Kg3 {-M10/12 0.026s} 51 | Ke3 {+M9/24 0.016s} 57. Kg4 {-M8/8 0.001s} Rg1+ {+M7/40 0.063s} 52 | 58. Kh5 {-M6/6 0.001s} Kf4 {+M5/91 0.015s} 59. Kh6 {-M4/4 0.002s} 53 | Rg2 {+M3/127 0.004s} 60. Kh5 {-M2/2 0.001s} Rh2# {+M1/127 0.003s, Black mates} 54 | 0-1 55 | 56 | [Event "?"] 57 | [Site "?"] 58 | [Date "2016.07.28"] 59 | [Round "1"] 60 | [White "Stockfish 7"] 61 | [Black "Maverick 1.5"] 62 | [Result "1-0"] 63 | [FEN "rqkrbnnb/pppppppp/8/8/8/8/PPPPPPPP/RQKRBNNB w KQkq - 0 1"] 64 | [PlyCount "99"] 65 | [SetUp "1"] 66 | [TimeControl "10+0.05"] 67 | [Variant "fischerandom"] 68 | 69 | 1. g3 {+0.14/14 0.54s} g6 {-0.11/13 0.39s} 2. e4 {+0.12/14 0.31s} 70 | Ne6 {+0.01/12 0.22s} 3. c3 {+0.32/15 0.54s} d6 {+0.31/12 0.25s} 71 | 4. d4 {+0.64/15 0.64s} Nf6 {+0.15/12 0.27s} 5. Ne3 {+0.55/14 0.29s} 72 | Bg7 {+0.02/12 0.39s} 6. f4 {+0.72/15 1.1s} h5 {-0.25/11 0.32s} 73 | 7. Bf3 {+0.87/14 0.27s} Ba4 {-0.57/11 0.38s} 8. b3 {+0.94/13 0.18s} 74 | Bd7 {-0.67/13 0.25s} 9. Kb2 {+0.91/14 0.65s} Nf8 {-0.44/11 0.31s} 75 | 10. h3 {+1.22/12 0.10s} e5 {-0.29/12 0.46s} 11. dxe5 {+1.53/13 0.27s} 76 | dxe5 {-0.44/13 0.19s} 12. fxe5 {+1.49/14 0.51s} Ng8 {-0.40/12 0.30s} 77 | 13. g4 {+1.65/13 0.16s} hxg4 {-0.58/11 0.27s} 14. Bxg4 {+1.86/14 0.33s} 78 | Bxe5 {-0.50/12 0.19s} 15. Nf3 {+2.20/14 0.23s} Bf4 {-0.79/12 0.19s} 79 | 16. Bh4 {+2.73/14 0.17s} Re8 {-0.87/12 0.16s} 17. Qd3 {+4.34/14 0.17s} 80 | f5 {-2.56/13 0.17s} 18. Nxf5 {+4.28/15 0.30s} gxf5 {-2.69/14 0.17s} 81 | 19. Bxf5 {+4.68/15 0.061s} Bd6 {-3.08/14 0.22s} 20. e5 {+5.62/14 0.23s} 82 | Nh6 {-3.56/13 0.37s} 21. Bxd7+ {+6.66/14 0.15s} Nxd7 {-3.81/12 0.13s} 83 | 22. Qg6 {+7.05/14 0.060s} Rf8 {-4.75/11 0.17s} 23. e6 {+8.47/15 0.36s} 84 | b5 {-5.56/12 0.46s} 24. exd7+ {+9.50/15 0.28s} Kxd7 {-6.15/12 0.24s} 85 | 25. Ne5+ {+10.51/18 0.10s} Kc8 {-6.52/11 0.036s} 26. Qe6+ {+10.58/15 0.021s} 86 | Kb7 {-5.07/8 0.021s} 27. Rxd6 {+11.11/19 0.24s} cxd6 {-10.56/11 0.22s} 87 | 28. Qd5+ {+11.15/16 0.062s} Kc8 {-11.09/15 0.24s} 29. Qc6+ {+11.23/17 0.13s} 88 | Qc7 {-11.23/15 0.034s} 30. Qxa8+ {+11.31/15 0.066s} Qb8 {-11.23/15 0.038s} 89 | 31. Qxb8+ {+11.41/16 0.14s} Kxb8 {-11.23/13 0.030s} 32. Nd7+ {+11.39/15 0.034s} 90 | Kb7 {-11.74/14 0.51s} 33. Nxf8 {+11.46/16 0.12s} Nf5 {-11.71/13 0.25s} 91 | 34. Bg5 {+11.51/15 0.032s} Kc6 {-11.69/11 0.26s} 35. h4 {+11.75/15 0.095s} 92 | Ng3 {-12.05/11 0.12s} 36. Ne6 {+12.06/14 0.31s} Ne4 {-12.04/10 0.17s} 93 | 37. Nd4+ {+12.31/13 0.090s} Kb6 {-12.39/11 0.14s} 38. Bf4 {+12.75/15 0.22s} 94 | a6 {-11.93/9 0.13s} 39. h5 {+15.20/16 0.20s} Kc5 {-13.49/11 0.26s} 95 | 40. h6 {+21.53/15 0.24s} Nf6 {-14.72/12 0.12s} 41. Re1 {+22.26/13 0.053s} 96 | b4 {-14.64/11 0.13s} 42. Bxd6+ {+M21/19 0.20s} Kxd6 {-17.58/12 0.10s} 97 | 43. Re6+ {+M17/21 0.095s} Kd7 {-17.90/12 0.12s} 44. Rxf6 {+M15/21 0.047s} 98 | Ke7 {-M18/11 0.25s} 45. Rf5 {+M13/19 0.069s} Kd6 {-M12/12 0.12s} 99 | 46. h7 {+M11/20 0.085s} a5 {-M10/10 0.010s} 47. h8=Q {+M9/20 0.076s} 100 | Kc7 {-M8/8 0.007s} 48. Qg7+ {+M5/127 0.031s} Kd6 {-M4/4 0.001s} 101 | 49. Nb5+ {+M3/127 0.003s} Kc6 {-M2/2 0s} 50. Qc7# {+M1/127 0.003s, White mates} 102 | 1-0 103 | 104 | [Event "?"] 105 | [Site "?"] 106 | [Date "2016.07.28"] 107 | [Round "1"] 108 | [White "Maverick 1.5"] 109 | [Black "Stockfish 7"] 110 | [Result "0-1"] 111 | [FEN "rnkqnbbr/pppppppp/8/8/8/8/PPPPPPPP/RNKQNBBR w KQkq - 0 1"] 112 | [PlyCount "70"] 113 | [SetUp "1"] 114 | [TimeControl "10+0.05"] 115 | [Variant "fischerandom"] 116 | 117 | 1. f4 {+0.30/11 0.23s} d5 {-0.09/13 0.15s} 2. Nc3 {+0.50/11 0.35s} 118 | Nf6 {+0.03/14 0.27s} 3. Nf3 {+0.41/13 0.40s} e6 {+0.08/13 0.18s} 119 | 4. Bd4 {+0.33/12 0.42s} h6 {+0.32/13 0.29s} 5. e3 {+0.30/11 0.23s} 120 | Ng4 {+0.24/13 0.16s} 6. Qe1 {+0.26/12 0.35s} c5 {+0.61/14 0.11s} 121 | 7. Be5 {+0.37/13 0.23s} Nc6 {+0.60/14 0.30s} 8. Bb5 {+0.23/13 0.54s} 122 | Ngxe5 {+0.66/14 0.30s} 9. fxe5 {+0.10/13 0.23s} Bh7 {+0.55/13 0.069s} 123 | 10. Bxc6 {+0.28/11 0.20s} bxc6 {+0.76/14 0.35s} 11. Rf1 {+0.08/11 0.58s} 124 | Rb8 {+1.28/13 0.22s} 12. b3 {0.00/10 0.32s} Rb7 {+1.54/13 0.20s} 125 | 13. e4 {-0.03/9 0.17s} c4 {+1.73/15 0.53s} 14. Qe3 {-0.31/9 0.19s} 126 | Qa5 {+1.85/14 0.76s} 15. Nd4 {-0.57/8 0.19s} c5 {+3.82/13 0.34s} 127 | 16. Nxe6 {-1.50/10 0.18s} cxb3 {+3.82/15 0.45s} 17. cxb3 {-1.25/10 0.23s} 128 | fxe6 {+4.14/13 0.15s} 18. exd5 {-1.72/10 0.17s} exd5 {+4.05/13 0.23s} 129 | 19. Qh3+ {-1.57/10 0.39s} Kb8 {+4.59/14 0.20s} 20. Nxd5 {-1.62/10 0.14s} 130 | c4 {+8.22/14 0.32s} 21. Qe6 {-4.82/10 0.34s} Bc5 {+11.06/14 0.26s} 131 | 22. Kd1 {-6.91/10 0.48s} cxb3 {+12.77/14 0.20s} 23. d4 {-8.16/10 0.24s} 132 | b2 {+21.67/14 0.23s} 24. Rb1 {-14.22/11 0.36s} Qa4+ {+23.31/14 0.24s} 133 | 25. Ke1 {-14.18/11 0.14s} Qxd4 {+30.39/15 0.80s} 26. Rf3 {-18.19/9 0.11s} 134 | Qe4+ {+30.58/13 0.026s} 27. Ne3 {-21.85/11 0.16s} Qxb1+ {+40.76/14 0.84s} 135 | 28. Kf2 {-24.98/12 0.26s} Qe4 {+41.45/13 0.047s} 29. Kg3 {-24.92/12 0.56s} 136 | b1=Q {+M21/13 0.18s} 30. Qg4 {-42.56/12 0.49s} Bxe3 {+M11/17 0.16s} 137 | 31. Qxe4 {-M18/10 0.11s} Qxe4 {+M9/20 0.022s} 32. a3 {-M8/11 0.32s} 138 | g5 {+M7/30 0.094s} 33. h3 {-M6/6 0.005s} Qxe5+ {+M5/46 0.021s} 139 | 34. Kg4 {-M8/8 0.003s} h5+ {+M3/127 0.004s} 35. Kxh5 {-M2/2 0s} 140 | Bf5# {+M1/127 0.003s, Black mates} 0-1 141 | 142 | [Event "?"] 143 | [Site "?"] 144 | [Date "2016.07.28"] 145 | [Round "1"] 146 | [White "Stockfish 7"] 147 | [Black "Maverick 1.5"] 148 | [Result "1-0"] 149 | [FEN "nbrnbkqr/pppppppp/8/8/8/8/PPPPPPPP/NBRNBKQR w KQkq - 0 1"] 150 | [PlyCount "107"] 151 | [SetUp "1"] 152 | [TimeControl "10+0.05"] 153 | [Variant "fischerandom"] 154 | 155 | 1. c4 {+0.13/15 0.38s} c5 {-0.41/13 0.34s} 2. f3 {+0.17/14 0.36s} 156 | Be5 {-0.27/13 0.29s} 3. Nb3 {+0.26/14 0.20s} d6 {-0.30/14 0.34s} 157 | 4. e3 {+0.11/15 0.67s} Nb6 {+0.08/12 0.32s} 5. d4 {0.00/14 0.60s} 158 | cxd4 {+0.02/13 0.22s} 6. exd4 {+0.05/15 0.22s} Bf4 {-0.07/13 0.25s} 159 | 7. Bd2 {-0.05/12 0.029s} Bxd2 {-0.08/13 0.25s} 8. Nxd2 {+0.50/13 0.16s} 160 | Bd7 {-0.12/12 0.23s} 9. b3 {+0.69/13 0.15s} Nc6 {-0.23/11 0.37s} 161 | 10. Nc3 {+0.85/14 0.35s} f6 {-0.33/11 0.23s} 11. d5 {+1.24/14 0.39s} 162 | Ne5 {-0.83/11 0.19s} 12. f4 {+1.51/15 0.57s} Ng6 {-0.85/11 0.28s} 163 | 13. Qf2 {+1.67/16 0.36s} Qf7 {-0.67/11 0.17s} 14. a4 {+1.74/15 0.36s} 164 | Rc7 {-0.99/11 0.29s} 15. Bd3 {+1.89/16 0.43s} O-O {-1.09/11 0.39s} 165 | 16. O-O {+1.80/15 0.077s} f5 {-1.07/11 0.19s} 17. g3 {+1.96/15 0.25s} 166 | Nc8 {-1.09/10 0.18s} 18. Nf3 {+1.87/14 0.33s} a5 {-1.18/11 0.60s} 167 | 19. Ng5 {+2.46/14 0.24s} Qf6 {-1.35/14 0.19s} 20. Nb5 {+2.37/13 0.040s} 168 | Bxb5 {-2.07/14 0.16s} 21. axb5 {+3.17/15 0.41s} Rd7 {-2.19/13 0.16s} 169 | 22. Ne6 {+3.39/14 0.11s} Re8 {-2.69/13 0.34s} 23. Qc2 {+3.75/15 0.34s} 170 | Nb6 {-2.58/12 0.17s} 24. Bxf5 {+4.00/14 0.26s} Rc8 {-3.29/11 0.21s} 171 | 25. Ng5 {+4.98/13 0.099s} Kh8 {-4.05/11 0.20s} 26. Be6 {+4.99/12 0.024s} 172 | Qd4+ {-4.27/11 0.12s} 27. Kh1 {+5.51/15 0.19s} Nf8 {-4.33/11 0.15s} 173 | 28. Rfe1 {+5.56/14 0.031s} a4 {-5.63/11 0.37s} 29. bxa4 {+5.70/15 0.16s} 174 | g6 {-4.90/10 0.11s} 30. Re4 {+6.24/14 0.13s} Qf6 {-5.64/13 0.17s} 175 | 31. a5 {+6.28/13 0.031s} Nxd5 {-5.63/12 0.38s} 32. Bxd5 {+6.81/14 0.37s} 176 | h6 {-6.27/12 0.60s} 33. Ne6 {+7.60/15 0.15s} Nh7 {-6.31/11 0.10s} 177 | 34. a6 {+8.36/16 0.23s} b6 {-6.96/12 0.20s} 35. Qa2 {+9.66/16 0.24s} 178 | Ra7 {-7.23/12 0.13s} 36. Qf2 {+9.66/16 0.18s} Rb8 {-8.02/12 0.17s} 179 | 37. Nd4 {+9.86/15 0.029s} Ng5 {-9.02/12 0.19s} 38. Nc6 {+10.75/15 0.12s} 180 | Nxe4 {-8.81/12 0.15s} 39. Bxe4 {+10.89/13 0.029s} d5 {-9.34/13 0.16s} 181 | 40. Bxd5 {+11.75/15 0.15s} Rba8 {-10.57/13 0.21s} 41. Nxa7 {+13.36/17 0.31s} 182 | Rxa7 {-10.97/12 0.13s} 42. c5 {+13.46/14 0.023s} Rc7 {-10.67/11 0.13s} 183 | 43. Bc6 {+16.80/14 0.17s} Rxc6 {-11.13/9 0.094s} 44. bxc6 {+18.21/13 0.11s} 184 | Qxc6+ {-14.47/9 0.17s} 45. Qg2 {+21.11/14 0.31s} Qa4 {-17.24/10 0.17s} 185 | 46. cxb6 {+27.63/15 0.41s} Qxa6 {-17.80/9 0.10s} 47. Qb2+ {+56.80/14 0.085s} 186 | Kh7 {-19.85/10 0.19s} 48. b7 {+M19/15 0.045s} Qd6 {-17.43/11 0.31s} 187 | 49. b8=Q {+M13/17 0.060s} Qxb8 {-M12/13 0.25s} 50. Qxb8 {+M9/28 0.063s} 188 | g5 {-M8/8 0.001s} 51. Qe8 {+M7/31 0.058s} Kg7 {-M6/6 0.001s} 189 | 52. Rc6 {+M5/77 0.014s} g4 {-M4/4 0.001s} 53. Qxe7+ {+M3/127 0.002s} 190 | Kg8 {-M2/2 0.001s} 54. Rc8# {+M1/127 0.002s, White mates} 1-0 191 | -------------------------------------------------------------------------------- /fuzz/corpus/pgn/cutechess-fischerrandom.pgn: -------------------------------------------------------------------------------- 1 | [Event "?"] 2 | [Site "?"] 3 | [Date "2016.07.28"] 4 | [Round "1"] 5 | [White "Maverick 1.5"] 6 | [Black "Stockfish 7"] 7 | [Result "0-1"] 8 | [FEN "nbbrknrq/pppppppp/8/8/8/8/PPPPPPPP/NBBRKNRQ w KQkq - 0 1"] 9 | [PlyCount "120"] 10 | [SetUp "1"] 11 | [TimeControl "10+0.05"] 12 | [Variant "fischerandom"] 13 | 14 | 1. d4 {+0.13/12 0.29s} d5 {-0.17/15 0.30s} 2. c3 {+0.22/13 0.28s} 15 | Nb6 {-0.17/14 0.14s} 3. e4 {+0.21/13 0.95s} dxe4 {+0.14/13 0.29s} 16 | 4. Bxe4 {+0.25/12 0.22s} g6 {-0.03/15 0.69s} 5. g4 {+0.31/11 0.30s} 17 | c6 {+0.26/13 0.19s} 6. Qf3 {+0.29/11 0.30s} Ne6 {+0.25/15 0.67s} 18 | 7. Nb3 {+0.22/10 0.35s} Qf6 {+0.23/15 0.14s} 8. Qxf6 {+0.34/12 0.27s} 19 | exf6 {+0.25/15 0.13s} 9. h4 {+0.32/12 0.39s} O-O {+0.20/15 0.073s} 20 | 10. Be3 {+0.15/11 0.33s} Nf4 {+0.68/14 0.60s} 11. Nc5 {+0.21/10 0.17s} 21 | Rfe8 {+0.77/15 0.34s} 12. Nd2 {0.00/10 0.25s} Nbd5 {+1.24/14 0.27s} 22 | 13. c4 {0.00/10 0.16s} b6 {+1.51/14 0.19s} 14. cxd5 {-0.26/10 0.15s} 23 | cxd5 {+1.69/12 0.030s} 15. Bc2 {-1.01/10 0.23s} bxc5 {+2.00/14 0.29s} 24 | 16. Nb3 {-1.29/11 0.17s} c4 {+1.82/15 0.50s} 17. Nc5 {-1.25/13 0.22s} 25 | Bd6 {+2.05/15 0.19s} 18. Ba4 {-1.31/10 0.20s} Re7 {+1.91/15 0.27s} 26 | 19. Bc2 {-1.46/10 0.15s} h5 {+2.11/16 0.82s} 20. gxh5 {-1.62/12 0.20s} 27 | Nxh5 {+1.89/16 0.43s} 21. O-O-O {-1.50/11 0.22s} Nf4 {+2.04/15 0.36s} 28 | 22. Rde1 {-1.74/10 0.13s} Kg7 {+2.14/15 0.20s} 23. h5 {-1.65/11 0.15s} 29 | Nxh5 {+2.23/12 0.030s} 24. Kd2 {-1.92/10 0.19s} f5 {+2.43/14 0.36s} 30 | 25. Bg5 {-1.74/10 0.15s} Rxe1 {+2.37/15 0.22s} 26. Rxe1 {-2.13/11 0.17s} 31 | f6 {+3.39/15 0.20s} 27. Bh4 {-2.74/13 0.14s} g5 {+3.22/13 0.13s} 32 | 28. Rg1 {-2.88/13 0.15s} Rh8 {+4.22/15 0.44s} 29. Bd1 {-2.88/10 0.15s} 33 | Kf8 {+4.10/16 0.24s} 30. Bg3 {-3.61/12 0.14s} f4 {+4.29/16 0.25s} 34 | 31. Bh2 {-3.70/13 0.15s} Ng7 {+4.40/14 0.038s} 32. Rh1 {-4.06/14 0.23s} 35 | Nf5 {+4.48/16 0.17s} 33. Bg4 {-4.56/13 0.11s} Ke7 {+4.60/14 0.021s} 36 | 34. Bxf5 {-4.14/11 0.13s} Bxf5 {+4.70/16 0.16s} 35. f3 {-4.34/12 0.25s} 37 | Rh3 {+4.84/15 0.092s} 36. Ke2 {-5.89/12 0.32s} g4 {+4.83/13 0.025s} 38 | 37. fxg4 {-4.74/11 0.13s} Bg6 {+4.91/15 0.079s} 38. Ke1 {-4.95/10 0.12s} 39 | Bxc5 {+5.01/13 0.038s} 39. dxc5 {-5.95/12 0.14s} Be4 {+5.22/14 0.11s} 40 | 40. a4 {-6.42/12 0.38s} Bxh1 {+5.82/13 0.079s} 41. Bxf4 {-7.92/12 0.12s} 41 | d4 {+5.91/13 0.033s} 42. Kd2 {-6.92/10 0.083s} Kd7 {+6.10/14 0.082s} 42 | 43. g5 {-7.26/10 0.11s} fxg5 {+6.57/15 0.11s} 44. Bxg5 {-8.34/10 0.091s} 43 | Kc6 {+6.81/13 0.026s} 45. Bf4 {-8.56/11 0.20s} Kxc5 {+7.90/15 0.14s} 44 | 46. a5 {-8.94/11 0.17s} Be4 {+11.14/16 0.22s} 47. a6 {-9.64/10 0.10s} 45 | Rb3 {+15.84/15 0.094s} 48. Kc1 {-11.49/13 0.12s} c3 {+48.50/24 0.078s} 46 | 49. bxc3 {-10.88/13 0.088s} dxc3 {+48.54/23 0.018s} 50. Kd1 {-11.10/13 0.17s} 47 | c2+ {+M35/23 0.14s} 51. Ke2 {-10.72/12 0.16s} Rb1 {+M31/23 0.024s} 48 | 52. Bd2 {-11.36/12 0.080s} c1=Q {+M21/24 0.076s} 53. Bxc1 {-12.14/14 0.11s} 49 | Rxc1 {+M19/23 0.025s} 54. Ke3 {-12.35/13 0.072s} Kd5 {+M15/23 0.10s} 50 | 55. Kf2 {-M18/13 0.14s} Kd4 {+M11/24 0.070s} 56. Kg3 {-M10/12 0.026s} 51 | Ke3 {+M9/24 0.016s} 57. Kg4 {-M8/8 0.001s} Rg1+ {+M7/40 0.063s} 52 | 58. Kh5 {-M6/6 0.001s} Kf4 {+M5/91 0.015s} 59. Kh6 {-M4/4 0.002s} 53 | Rg2 {+M3/127 0.004s} 60. Kh5 {-M2/2 0.001s} Rh2# {+M1/127 0.003s, Black mates} 54 | 0-1 55 | 56 | [Event "?"] 57 | [Site "?"] 58 | [Date "2016.07.28"] 59 | [Round "1"] 60 | [White "Stockfish 7"] 61 | [Black "Maverick 1.5"] 62 | [Result "1-0"] 63 | [FEN "rqkrbnnb/pppppppp/8/8/8/8/PPPPPPPP/RQKRBNNB w KQkq - 0 1"] 64 | [PlyCount "99"] 65 | [SetUp "1"] 66 | [TimeControl "10+0.05"] 67 | [Variant "fischerandom"] 68 | 69 | 1. g3 {+0.14/14 0.54s} g6 {-0.11/13 0.39s} 2. e4 {+0.12/14 0.31s} 70 | Ne6 {+0.01/12 0.22s} 3. c3 {+0.32/15 0.54s} d6 {+0.31/12 0.25s} 71 | 4. d4 {+0.64/15 0.64s} Nf6 {+0.15/12 0.27s} 5. Ne3 {+0.55/14 0.29s} 72 | Bg7 {+0.02/12 0.39s} 6. f4 {+0.72/15 1.1s} h5 {-0.25/11 0.32s} 73 | 7. Bf3 {+0.87/14 0.27s} Ba4 {-0.57/11 0.38s} 8. b3 {+0.94/13 0.18s} 74 | Bd7 {-0.67/13 0.25s} 9. Kb2 {+0.91/14 0.65s} Nf8 {-0.44/11 0.31s} 75 | 10. h3 {+1.22/12 0.10s} e5 {-0.29/12 0.46s} 11. dxe5 {+1.53/13 0.27s} 76 | dxe5 {-0.44/13 0.19s} 12. fxe5 {+1.49/14 0.51s} Ng8 {-0.40/12 0.30s} 77 | 13. g4 {+1.65/13 0.16s} hxg4 {-0.58/11 0.27s} 14. Bxg4 {+1.86/14 0.33s} 78 | Bxe5 {-0.50/12 0.19s} 15. Nf3 {+2.20/14 0.23s} Bf4 {-0.79/12 0.19s} 79 | 16. Bh4 {+2.73/14 0.17s} Re8 {-0.87/12 0.16s} 17. Qd3 {+4.34/14 0.17s} 80 | f5 {-2.56/13 0.17s} 18. Nxf5 {+4.28/15 0.30s} gxf5 {-2.69/14 0.17s} 81 | 19. Bxf5 {+4.68/15 0.061s} Bd6 {-3.08/14 0.22s} 20. e5 {+5.62/14 0.23s} 82 | Nh6 {-3.56/13 0.37s} 21. Bxd7+ {+6.66/14 0.15s} Nxd7 {-3.81/12 0.13s} 83 | 22. Qg6 {+7.05/14 0.060s} Rf8 {-4.75/11 0.17s} 23. e6 {+8.47/15 0.36s} 84 | b5 {-5.56/12 0.46s} 24. exd7+ {+9.50/15 0.28s} Kxd7 {-6.15/12 0.24s} 85 | 25. Ne5+ {+10.51/18 0.10s} Kc8 {-6.52/11 0.036s} 26. Qe6+ {+10.58/15 0.021s} 86 | Kb7 {-5.07/8 0.021s} 27. Rxd6 {+11.11/19 0.24s} cxd6 {-10.56/11 0.22s} 87 | 28. Qd5+ {+11.15/16 0.062s} Kc8 {-11.09/15 0.24s} 29. Qc6+ {+11.23/17 0.13s} 88 | Qc7 {-11.23/15 0.034s} 30. Qxa8+ {+11.31/15 0.066s} Qb8 {-11.23/15 0.038s} 89 | 31. Qxb8+ {+11.41/16 0.14s} Kxb8 {-11.23/13 0.030s} 32. Nd7+ {+11.39/15 0.034s} 90 | Kb7 {-11.74/14 0.51s} 33. Nxf8 {+11.46/16 0.12s} Nf5 {-11.71/13 0.25s} 91 | 34. Bg5 {+11.51/15 0.032s} Kc6 {-11.69/11 0.26s} 35. h4 {+11.75/15 0.095s} 92 | Ng3 {-12.05/11 0.12s} 36. Ne6 {+12.06/14 0.31s} Ne4 {-12.04/10 0.17s} 93 | 37. Nd4+ {+12.31/13 0.090s} Kb6 {-12.39/11 0.14s} 38. Bf4 {+12.75/15 0.22s} 94 | a6 {-11.93/9 0.13s} 39. h5 {+15.20/16 0.20s} Kc5 {-13.49/11 0.26s} 95 | 40. h6 {+21.53/15 0.24s} Nf6 {-14.72/12 0.12s} 41. Re1 {+22.26/13 0.053s} 96 | b4 {-14.64/11 0.13s} 42. Bxd6+ {+M21/19 0.20s} Kxd6 {-17.58/12 0.10s} 97 | 43. Re6+ {+M17/21 0.095s} Kd7 {-17.90/12 0.12s} 44. Rxf6 {+M15/21 0.047s} 98 | Ke7 {-M18/11 0.25s} 45. Rf5 {+M13/19 0.069s} Kd6 {-M12/12 0.12s} 99 | 46. h7 {+M11/20 0.085s} a5 {-M10/10 0.010s} 47. h8=Q {+M9/20 0.076s} 100 | Kc7 {-M8/8 0.007s} 48. Qg7+ {+M5/127 0.031s} Kd6 {-M4/4 0.001s} 101 | 49. Nb5+ {+M3/127 0.003s} Kc6 {-M2/2 0s} 50. Qc7# {+M1/127 0.003s, White mates} 102 | 1-0 103 | 104 | [Event "?"] 105 | [Site "?"] 106 | [Date "2016.07.28"] 107 | [Round "1"] 108 | [White "Maverick 1.5"] 109 | [Black "Stockfish 7"] 110 | [Result "0-1"] 111 | [FEN "rnkqnbbr/pppppppp/8/8/8/8/PPPPPPPP/RNKQNBBR w KQkq - 0 1"] 112 | [PlyCount "70"] 113 | [SetUp "1"] 114 | [TimeControl "10+0.05"] 115 | [Variant "fischerandom"] 116 | 117 | 1. f4 {+0.30/11 0.23s} d5 {-0.09/13 0.15s} 2. Nc3 {+0.50/11 0.35s} 118 | Nf6 {+0.03/14 0.27s} 3. Nf3 {+0.41/13 0.40s} e6 {+0.08/13 0.18s} 119 | 4. Bd4 {+0.33/12 0.42s} h6 {+0.32/13 0.29s} 5. e3 {+0.30/11 0.23s} 120 | Ng4 {+0.24/13 0.16s} 6. Qe1 {+0.26/12 0.35s} c5 {+0.61/14 0.11s} 121 | 7. Be5 {+0.37/13 0.23s} Nc6 {+0.60/14 0.30s} 8. Bb5 {+0.23/13 0.54s} 122 | Ngxe5 {+0.66/14 0.30s} 9. fxe5 {+0.10/13 0.23s} Bh7 {+0.55/13 0.069s} 123 | 10. Bxc6 {+0.28/11 0.20s} bxc6 {+0.76/14 0.35s} 11. Rf1 {+0.08/11 0.58s} 124 | Rb8 {+1.28/13 0.22s} 12. b3 {0.00/10 0.32s} Rb7 {+1.54/13 0.20s} 125 | 13. e4 {-0.03/9 0.17s} c4 {+1.73/15 0.53s} 14. Qe3 {-0.31/9 0.19s} 126 | Qa5 {+1.85/14 0.76s} 15. Nd4 {-0.57/8 0.19s} c5 {+3.82/13 0.34s} 127 | 16. Nxe6 {-1.50/10 0.18s} cxb3 {+3.82/15 0.45s} 17. cxb3 {-1.25/10 0.23s} 128 | fxe6 {+4.14/13 0.15s} 18. exd5 {-1.72/10 0.17s} exd5 {+4.05/13 0.23s} 129 | 19. Qh3+ {-1.57/10 0.39s} Kb8 {+4.59/14 0.20s} 20. Nxd5 {-1.62/10 0.14s} 130 | c4 {+8.22/14 0.32s} 21. Qe6 {-4.82/10 0.34s} Bc5 {+11.06/14 0.26s} 131 | 22. Kd1 {-6.91/10 0.48s} cxb3 {+12.77/14 0.20s} 23. d4 {-8.16/10 0.24s} 132 | b2 {+21.67/14 0.23s} 24. Rb1 {-14.22/11 0.36s} Qa4+ {+23.31/14 0.24s} 133 | 25. Ke1 {-14.18/11 0.14s} Qxd4 {+30.39/15 0.80s} 26. Rf3 {-18.19/9 0.11s} 134 | Qe4+ {+30.58/13 0.026s} 27. Ne3 {-21.85/11 0.16s} Qxb1+ {+40.76/14 0.84s} 135 | 28. Kf2 {-24.98/12 0.26s} Qe4 {+41.45/13 0.047s} 29. Kg3 {-24.92/12 0.56s} 136 | b1=Q {+M21/13 0.18s} 30. Qg4 {-42.56/12 0.49s} Bxe3 {+M11/17 0.16s} 137 | 31. Qxe4 {-M18/10 0.11s} Qxe4 {+M9/20 0.022s} 32. a3 {-M8/11 0.32s} 138 | g5 {+M7/30 0.094s} 33. h3 {-M6/6 0.005s} Qxe5+ {+M5/46 0.021s} 139 | 34. Kg4 {-M8/8 0.003s} h5+ {+M3/127 0.004s} 35. Kxh5 {-M2/2 0s} 140 | Bf5# {+M1/127 0.003s, Black mates} 0-1 141 | 142 | [Event "?"] 143 | [Site "?"] 144 | [Date "2016.07.28"] 145 | [Round "1"] 146 | [White "Stockfish 7"] 147 | [Black "Maverick 1.5"] 148 | [Result "1-0"] 149 | [FEN "nbrnbkqr/pppppppp/8/8/8/8/PPPPPPPP/NBRNBKQR w KQkq - 0 1"] 150 | [PlyCount "107"] 151 | [SetUp "1"] 152 | [TimeControl "10+0.05"] 153 | [Variant "fischerandom"] 154 | 155 | 1. c4 {+0.13/15 0.38s} c5 {-0.41/13 0.34s} 2. f3 {+0.17/14 0.36s} 156 | Be5 {-0.27/13 0.29s} 3. Nb3 {+0.26/14 0.20s} d6 {-0.30/14 0.34s} 157 | 4. e3 {+0.11/15 0.67s} Nb6 {+0.08/12 0.32s} 5. d4 {0.00/14 0.60s} 158 | cxd4 {+0.02/13 0.22s} 6. exd4 {+0.05/15 0.22s} Bf4 {-0.07/13 0.25s} 159 | 7. Bd2 {-0.05/12 0.029s} Bxd2 {-0.08/13 0.25s} 8. Nxd2 {+0.50/13 0.16s} 160 | Bd7 {-0.12/12 0.23s} 9. b3 {+0.69/13 0.15s} Nc6 {-0.23/11 0.37s} 161 | 10. Nc3 {+0.85/14 0.35s} f6 {-0.33/11 0.23s} 11. d5 {+1.24/14 0.39s} 162 | Ne5 {-0.83/11 0.19s} 12. f4 {+1.51/15 0.57s} Ng6 {-0.85/11 0.28s} 163 | 13. Qf2 {+1.67/16 0.36s} Qf7 {-0.67/11 0.17s} 14. a4 {+1.74/15 0.36s} 164 | Rc7 {-0.99/11 0.29s} 15. Bd3 {+1.89/16 0.43s} O-O {-1.09/11 0.39s} 165 | 16. O-O {+1.80/15 0.077s} f5 {-1.07/11 0.19s} 17. g3 {+1.96/15 0.25s} 166 | Nc8 {-1.09/10 0.18s} 18. Nf3 {+1.87/14 0.33s} a5 {-1.18/11 0.60s} 167 | 19. Ng5 {+2.46/14 0.24s} Qf6 {-1.35/14 0.19s} 20. Nb5 {+2.37/13 0.040s} 168 | Bxb5 {-2.07/14 0.16s} 21. axb5 {+3.17/15 0.41s} Rd7 {-2.19/13 0.16s} 169 | 22. Ne6 {+3.39/14 0.11s} Re8 {-2.69/13 0.34s} 23. Qc2 {+3.75/15 0.34s} 170 | Nb6 {-2.58/12 0.17s} 24. Bxf5 {+4.00/14 0.26s} Rc8 {-3.29/11 0.21s} 171 | 25. Ng5 {+4.98/13 0.099s} Kh8 {-4.05/11 0.20s} 26. Be6 {+4.99/12 0.024s} 172 | Qd4+ {-4.27/11 0.12s} 27. Kh1 {+5.51/15 0.19s} Nf8 {-4.33/11 0.15s} 173 | 28. Rfe1 {+5.56/14 0.031s} a4 {-5.63/11 0.37s} 29. bxa4 {+5.70/15 0.16s} 174 | g6 {-4.90/10 0.11s} 30. Re4 {+6.24/14 0.13s} Qf6 {-5.64/13 0.17s} 175 | 31. a5 {+6.28/13 0.031s} Nxd5 {-5.63/12 0.38s} 32. Bxd5 {+6.81/14 0.37s} 176 | h6 {-6.27/12 0.60s} 33. Ne6 {+7.60/15 0.15s} Nh7 {-6.31/11 0.10s} 177 | 34. a6 {+8.36/16 0.23s} b6 {-6.96/12 0.20s} 35. Qa2 {+9.66/16 0.24s} 178 | Ra7 {-7.23/12 0.13s} 36. Qf2 {+9.66/16 0.18s} Rb8 {-8.02/12 0.17s} 179 | 37. Nd4 {+9.86/15 0.029s} Ng5 {-9.02/12 0.19s} 38. Nc6 {+10.75/15 0.12s} 180 | Nxe4 {-8.81/12 0.15s} 39. Bxe4 {+10.89/13 0.029s} d5 {-9.34/13 0.16s} 181 | 40. Bxd5 {+11.75/15 0.15s} Rba8 {-10.57/13 0.21s} 41. Nxa7 {+13.36/17 0.31s} 182 | Rxa7 {-10.97/12 0.13s} 42. c5 {+13.46/14 0.023s} Rc7 {-10.67/11 0.13s} 183 | 43. Bc6 {+16.80/14 0.17s} Rxc6 {-11.13/9 0.094s} 44. bxc6 {+18.21/13 0.11s} 184 | Qxc6+ {-14.47/9 0.17s} 45. Qg2 {+21.11/14 0.31s} Qa4 {-17.24/10 0.17s} 185 | 46. cxb6 {+27.63/15 0.41s} Qxa6 {-17.80/9 0.10s} 47. Qb2+ {+56.80/14 0.085s} 186 | Kh7 {-19.85/10 0.19s} 48. b7 {+M19/15 0.045s} Qd6 {-17.43/11 0.31s} 187 | 49. b8=Q {+M13/17 0.060s} Qxb8 {-M12/13 0.25s} 50. Qxb8 {+M9/28 0.063s} 188 | g5 {-M8/8 0.001s} 51. Qe8 {+M7/31 0.058s} Kg7 {-M6/6 0.001s} 189 | 52. Rc6 {+M5/77 0.014s} g4 {-M4/4 0.001s} 53. Qxe7+ {+M3/127 0.002s} 190 | Kg8 {-M2/2 0.001s} 54. Rc8# {+M1/127 0.002s, White mates} 1-0 191 | -------------------------------------------------------------------------------- /data/endgame.epd: -------------------------------------------------------------------------------- 1 | 8/2K5/8/8/8/8/3p4/1k2N3 b - - wdl_table 2; wdl 2; dtz 1; 2 | 8/8/1n6/8/7K/8/3k4/1Q6 w - - wdl_table 2; wdl 2; dtz 1; 3 | 8/4r3/8/K7/4R3/8/8/5k2 w - - wdl_table 0; wdl 2; dtz 1; 4 | 2K5/8/8/8/6P1/8/2n5/1k6 w - - wdl_table 0; wdl 0; dtz 0; 5 | 8/1K6/4q3/8/8/6p1/8/2k5 w - - wdl_table -2; wdl -2; dtz -2; 6 | 8/8/R2k4/8/8/K7/8/4r3 b - - wdl_table 0; wdl 0; dtz 0; 7 | 8/8/8/8/8/1K2B3/b6k/8 w - - wdl_table 0; wdl 0; dtz 0; 8 | R7/8/6k1/8/8/8/2K4r/8 w - - wdl_table 0; wdl 0; dtz 0; 9 | q7/k2K4/5B2/8/8/8/8/8 b - - wdl_table 2; wdl 2; dtz 19; 10 | 3B4/K7/8/k3N3/8/8/8/8 b - - wdl_table -2; wdl -2; dtz -53; 11 | 4k3/8/8/8/8/8/P2Kp3/8 b - - wdl_table 0; wdl 0; dtz 0; 12 | 8/6k1/4K3/6B1/8/8/5N2/8 w - - wdl_table 2; wdl 2; dtz 20; 13 | 8/8/3K4/5P2/Q7/8/1k6/8 w - - wdl_table 2; wdl 2; dtz 1; 14 | 8/8/8/8/5k2/3Kb3/8/1N6 w - - wdl_table 0; wdl 0; dtz 0; 15 | 2K5/8/2P5/8/4k3/8/3r4/8 w - - wdl_table 0; wdl 0; dtz 0; 16 | 8/8/8/3R1p2/8/1k6/3K4/8 b - - wdl_table -2; wdl -2; dtz -2; 17 | 8/8/K4k2/7q/8/8/7Q/8 b - - wdl_table 0; wdl 2; dtz 1; 18 | K2R4/8/8/8/2n5/8/8/6k1 w - - wdl_table 0; wdl 0; dtz 0; 19 | n7/8/8/8/1K6/6k1/2r5/8 w - - wdl_table -2; wdl -2; dtz -18; 20 | K7/8/5r2/8/3k4/5p2/8/8 w - - wdl_table -2; wdl -2; dtz -2; 21 | 8/8/K7/5k2/3R4/8/7b/8 w - - wdl_table 0; wdl 0; dtz 0; 22 | 8/Q7/8/1K6/2B5/1k6/8/8 b - - wdl_table -2; wdl -2; dtz -8; 23 | 8/3r4/7K/5R2/8/8/8/5k2 b - - wdl_table 0; wdl 0; dtz 0; 24 | 8/8/k5N1/8/8/5p2/8/1K6 b - - wdl_table 2; wdl 2; dtz 1; 25 | 8/8/8/8/7r/6q1/2K5/6k1 w - - wdl_table -2; wdl -2; dtz -4; 26 | 1r4k1/8/8/p7/8/8/8/K7 b - - wdl_table 2; wdl 2; dtz 1; 27 | 8/4K3/8/2k5/8/8/8/5Q1N b - - wdl_table -2; wdl -2; dtz -12; 28 | 8/8/2r5/6bk/8/8/6K1/8 b - - wdl_table 2; wdl 2; dtz 9; 29 | 4n3/8/7b/8/8/7K/8/7k w - - wdl_table -2; wdl -2; dtz -51; 30 | 8/8/1k6/3K4/1b5r/8/8/8 w - - wdl_table -2; wdl -2; dtz -16; 31 | 3k4/3rq3/8/1K6/8/8/8/8 w - - wdl_table -2; wdl -2; dtz -4; 32 | 8/1p3K2/4R3/8/8/5k2/8/8 w - - wdl_table 2; wdl 2; dtz 3; 33 | 3R4/3K4/8/8/k7/8/n7/8 b - - wdl_table 0; wdl 0; dtz 0; 34 | 8/8/1B6/4K3/8/6B1/4k3/8 b - - wdl_table 0; wdl 0; dtz 0; 35 | 8/8/1k6/8/2R2R2/8/6K1/8 w - - wdl_table 2; wdl 2; dtz 5; 36 | 4K3/8/8/7B/8/4R3/2k5/8 b - - wdl_table -2; wdl -2; dtz -20; 37 | 5r1K/8/8/8/8/6n1/7k/8 w - - wdl_table -2; wdl -2; dtz -14; 38 | 8/4P3/1k2K3/8/8/8/8/6R1 b - - wdl_table -2; wdl -2; dtz -2; 39 | 1n6/4Q3/8/k1K5/8/8/8/8 b - - wdl_table -2; wdl -2; dtz -14; 40 | 8/8/8/4Kp2/2k5/8/8/7B w - - wdl_table 0; wdl 0; dtz 0; 41 | 7R/8/8/8/8/N1k5/8/5K2 w - - wdl_table 2; wdl 2; dtz 11; 42 | K7/5N2/8/8/3p4/8/k7/8 w - - wdl_table 0; wdl 0; dtz 0; 43 | K7/3n4/6r1/8/8/4k3/8/8 w - - wdl_table -2; wdl -2; dtz -12; 44 | 2q5/8/8/8/6N1/8/4K3/k7 w - - wdl_table -2; wdl -2; dtz -30; 45 | 8/8/8/7K/7r/7N/8/4k3 w - - wdl_table 0; wdl 0; dtz 0; 46 | 8/8/8/1B6/5K2/3n4/8/5k2 w - - wdl_table 0; wdl 0; dtz 0; 47 | 8/8/8/8/8/1q3k2/8/2R4K w - - wdl_table -2; wdl -2; dtz -8; 48 | 4QK2/8/5k2/8/8/8/b7/8 w - - wdl_table 2; wdl 2; dtz 9; 49 | 2k5/8/8/1q2K1n1/8/8/8/8 w - - wdl_table -2; wdl -2; dtz -10; 50 | 8/2B5/2k5/8/2K5/3n4/8/8 w - - wdl_table 0; wdl 0; dtz 0; 51 | K7/8/4B3/5k2/8/8/8/2n5 b - - wdl_table 0; wdl 0; dtz 0; 52 | 8/8/3b4/6K1/8/8/1Q6/1k6 b - - wdl_table -2; wdl 0; dtz 0; 53 | 8/4k3/8/7P/5K2/2b5/8/8 w - - wdl_table 0; wdl 0; dtz 0; 54 | 7Q/8/4k3/6K1/n7/8/8/8 w - - wdl_table 2; wdl 2; dtz 3; 55 | 8/k3p3/b7/8/8/K7/8/8 b - - wdl_table 2; wdl 2; dtz 1; 56 | 8/8/3p1k2/8/8/6K1/8/4n3 w - - wdl_table -2; wdl -2; dtz -4; 57 | 4b3/4n3/8/8/2k5/8/3K4/8 w - - wdl_table -2; wdl -2; dtz -47; 58 | 5Q2/8/8/2k5/8/8/2K5/6B1 b - - wdl_table -2; wdl -2; dtz -8; 59 | 8/7p/8/8/8/bk6/8/1K6 w - - wdl_table -2; wdl -2; dtz -2; 60 | 6Q1/8/1K6/8/1p5k/8/8/8 b - - wdl_table -2; wdl -2; dtz -4; 61 | 8/6K1/8/8/4Q3/7p/1k6/8 b - - wdl_table -2; wdl -2; dtz -4; 62 | 8/8/1k6/8/8/5q2/n7/5K2 w - - wdl_table -2; wdl -2; dtz -8; 63 | 8/6P1/p7/8/8/8/8/1K1k4 w - - wdl_table 2; wdl 2; dtz 1; 64 | 8/5K2/3k1r2/8/8/8/2Q5/8 w - - wdl_table 2; wdl 2; dtz 1; 65 | 8/5p2/6k1/K7/8/8/8/8 w - - wdl_table -2; wdl -2; dtz -2; 66 | 6k1/1n6/1B6/8/8/8/8/2K5 w - - wdl_table 0; wdl 0; dtz 0; 67 | 7k/1R6/8/8/8/8/4r3/K7 w - - wdl_table 0; wdl 0; dtz 0; 68 | 8/6k1/8/8/3K4/b7/1Q6/8 w - - wdl_table 2; wdl 2; dtz 1; 69 | K5n1/8/8/7n/k7/8/8/8 w - - wdl_table 0; wdl 0; dtz 0; 70 | 8/8/2K5/k7/1q6/5r2/8/8 w - - wdl_table -2; wdl -2; dtz -4; 71 | 7N/8/8/7P/8/1K6/8/5k2 w - - wdl_table 2; wdl 2; dtz 1; 72 | 3K4/4n3/2k5/8/b7/8/8/8 w - - wdl_table -2; wdl 0; dtz 0; 73 | 4b3/6k1/8/8/8/8/7b/4K3 b - - wdl_table 2; wdl 2; dtz 28; 74 | 8/5k2/1K6/8/8/6n1/8/2B5 w - - wdl_table 0; wdl 0; dtz 0; 75 | 4Kn2/2R5/8/8/8/3k4/8/8 b - - wdl_table 0; wdl 0; dtz 0; 76 | 8/k7/8/3q4/8/7Q/2K5/8 b - - wdl_table 0; wdl 0; dtz 0; 77 | 4K3/8/8/8/1Q6/3b4/7k/8 b - - wdl_table -2; wdl -2; dtz -18; 78 | 8/8/8/3Kn3/8/8/4k3/N7 b - - wdl_table 0; wdl 0; dtz 0; 79 | 2kn4/8/K7/8/4R3/8/8/8 b - - wdl_table 0; wdl 0; dtz 0; 80 | 8/2k5/8/8/8/4Qr2/6K1/8 b - - wdl_table -2; wdl 2; dtz 1; 81 | 4r3/8/8/2K5/8/8/3P4/k7 w - - wdl_table 0; wdl 0; dtz 0; 82 | 5K2/1Pk5/4b3/8/8/8/8/8 b - - wdl_table 0; wdl 0; dtz 0; 83 | 8/4K3/5r2/8/8/8/6k1/7b w - - wdl_table -2; wdl 0; dtz 0; 84 | 8/8/Q1q5/8/8/2k5/4K3/8 w - - wdl_table 0; wdl 2; dtz 1; 85 | 6q1/8/6K1/4R3/1k6/8/8/8 w - - wdl_table -2; wdl -2; dtz -46; 86 | 8/3K4/8/8/1k6/1B4P1/8/8 w - - wdl_table 2; wdl 2; dtz 1; 87 | 1n6/8/8/3k4/8/1K2n3/8/8 w - - wdl_table 0; wdl 0; dtz 0; 88 | 2b5/3K4/4R3/3k4/8/8/8/8 w - - wdl_table 0; wdl 0; dtz 0; 89 | 8/8/8/8/4k3/2q5/3K4/6r1 w - - wdl_table -2; wdl -2; dtz -2; 90 | 8/8/3K4/3n4/8/3k4/8/4n3 b - - wdl_table 0; wdl 0; dtz 0; 91 | 5K2/8/8/8/8/8/N7/4k2n b - - wdl_table 0; wdl 0; dtz 0; 92 | 8/8/6K1/8/p7/5R2/6k1/8 w - - wdl_table 2; wdl 2; dtz 3; 93 | 7N/q7/8/7K/1k6/8/8/8 w - - wdl_table -2; wdl -2; dtz -20; 94 | 8/2k5/p7/3K2P1/8/8/8/8 b - - wdl_table 0; wdl 0; dtz 0; 95 | 1bB5/8/1k6/8/8/8/6K1/8 b - - wdl_table 0; wdl 0; dtz 0; 96 | 8/8/3Q4/8/8/8/q7/4k1K1 b - - wdl_table 0; wdl 0; dtz 0; 97 | 8/1K6/1R6/8/8/8/2k5/5B2 w - - wdl_table 2; wdl 2; dtz 15; 98 | 8/4p3/8/3n4/6K1/8/8/6k1 w - - wdl_table -2; wdl -2; dtz -4; 99 | 8/8/8/2K5/5kp1/8/8/8 b - - wdl_table 2; wdl 2; dtz 1; 100 | 8/3K4/5k2/8/1N6/4n3/8/8 b - - wdl_table 0; wdl 0; dtz 0; 101 | 8/8/8/3k2P1/8/8/3q4/K7 b - - wdl_table 2; wdl 2; dtz 1; 102 | 6B1/8/8/1n6/8/5k2/8/1K6 w - - wdl_table 0; wdl 0; dtz 0; 103 | 8/8/1n5B/8/8/8/6K1/2k5 b - - wdl_table 0; wdl 0; dtz 0; 104 | 3K1b2/2R5/8/8/8/1k6/8/8 w - - wdl_table 0; wdl 0; dtz 0; 105 | 7K/8/8/8/4k3/1N6/3n4/8 b - - wdl_table 0; wdl 0; dtz 0; 106 | 6r1/8/5K2/8/8/8/8/1k1n4 b - - wdl_table 2; wdl 2; dtz 21; 107 | 8/8/4K3/k7/4q3/8/6p1/8 w - - wdl_table -2; wdl -2; dtz -2; 108 | 7B/8/8/7B/8/3k4/8/6K1 b - - wdl_table -2; wdl -2; dtz -33; 109 | 8/8/8/3r4/2K5/8/2k3n1/8 w - - wdl_table -2; wdl 0; dtz 0; 110 | 8/8/q1P5/8/5k2/8/8/6K1 b - - wdl_table 2; wdl 2; dtz 1; 111 | 7B/2k5/8/8/6p1/8/8/1K6 w - - wdl_table 0; wdl 0; dtz 0; 112 | 5k2/8/4K3/8/3r1B2/8/8/8 b - - wdl_table 0; wdl 2; dtz 1; 113 | 8/8/8/8/4k3/8/8/1R2R1K1 b - - wdl_table -2; wdl -2; dtz -8; 114 | k7/7K/8/p7/6n1/8/8/8 w - - wdl_table -2; wdl -2; dtz -2; 115 | 8/4p2K/3B4/7k/8/8/8/8 b - - wdl_table 0; wdl 2; dtz 1; 116 | 7K/6p1/8/8/k1R5/8/8/8 b - - wdl_table -2; wdl -2; dtz -4; 117 | 8/7n/8/N1K5/6k1/8/8/8 w - - wdl_table 0; wdl 0; dtz 0; 118 | 8/8/5k2/8/2K5/3N4/2B5/8 w - - wdl_table 2; wdl 2; dtz 48; 119 | 8/7r/8/1k4K1/8/8/8/3B4 w - - wdl_table 0; wdl 0; dtz 0; 120 | 8/8/4K3/8/8/1k6/8/4RN2 b - - wdl_table -2; wdl -2; dtz -16; 121 | 8/5q2/8/2K5/8/8/k7/1R6 w - - wdl_table -2; wdl -2; dtz -54; 122 | 8/8/8/5Q2/6K1/1k6/7p/8 w - - wdl_table 2; wdl 2; dtz 3; 123 | 2K5/8/8/kr6/8/8/8/4b3 b - - wdl_table 2; wdl 2; dtz 11; 124 | 8/8/8/N2K1k2/P7/8/8/8 b - - wdl_table -2; wdl -2; dtz -4; 125 | 8/8/8/8/4P3/6k1/5N2/4K3 w - - wdl_table 2; wdl 2; dtz 1; 126 | 8/6N1/8/8/7k/8/p7/4K3 b - - wdl_table 2; wdl 2; dtz 1; 127 | 8/3p4/5p2/2K5/8/8/8/2k5 b - - wdl_table 2; wdl 2; dtz 1; 128 | 8/8/2q1k3/8/5K2/8/3r4/8 w - - wdl_table -2; wdl -2; dtz -6; 129 | 3Kb3/7k/8/8/8/8/4Q3/8 b - - wdl_table -2; wdl -2; dtz -10; 130 | 8/8/8/3p4/7b/8/6K1/3k4 b - - wdl_table 2; wdl 2; dtz 1; 131 | 8/4K3/2P5/4k3/7B/8/8/8 w - - wdl_table 2; wdl 2; dtz 1; 132 | 8/7k/8/4KP2/8/8/1p6/8 w - - wdl_table -2; wdl -2; dtz -1; 133 | 8/8/8/8/7K/p4k2/8/1r6 w - - wdl_table -2; wdl -2; dtz -2; 134 | 2K1N3/8/8/8/8/7p/4k3/8 b - - wdl_table 2; wdl 2; dtz 1; 135 | 8/k7/8/5N2/8/4K3/3r4/8 w - - wdl_table 0; wdl 0; dtz 0; 136 | 1k6/1R3P2/8/8/8/8/8/6K1 b - - wdl_table -2; wdl -2; dtz -2; 137 | 8/5k2/8/6n1/7r/7K/8/8 w - - wdl_table -2; wdl 0; dtz 0; 138 | 8/6K1/6R1/6R1/7k/8/8/8 w - - wdl_table 2; wdl 2; dtz 1; 139 | 5b2/8/2kq4/4K3/8/8/8/8 w - - wdl_table -2; wdl -2; dtz -10; 140 | 8/2K5/8/8/8/4k2N/8/6n1 w - - wdl_table 0; wdl 0; dtz 0; 141 | 1k6/4P3/8/5QK1/8/8/8/8 b - - wdl_table -2; wdl -2; dtz -2; 142 | 8/8/2r5/8/k7/3K4/6r1/8 w - - wdl_table -2; wdl -2; dtz -6; 143 | 6N1/8/8/2k5/7N/1K6/8/8 b - - wdl_table 0; wdl 0; dtz 0; 144 | 8/2k5/8/8/2n5/8/8/K5q1 w - - wdl_table -2; wdl -2; dtz -4; 145 | 8/3k4/8/8/8/4q3/3K4/7r w - - wdl_table -2; wdl -2; dtz -2; 146 | 8/4K3/8/2B1k3/8/8/7P/8 b - - wdl_table -2; wdl -2; dtz -2; 147 | 8/8/r7/8/7k/8/2K5/5N2 b - - wdl_table 0; wdl 0; dtz 0; 148 | 8/8/8/2k5/8/2b5/8/K2R4 w - - wdl_table 0; wdl 0; dtz 0; 149 | 5k2/5P2/8/8/8/8/4B3/1K6 b - - wdl_table -2; wdl 0; dtz 0; 150 | 8/2q5/8/8/1k6/7K/8/7B w - - wdl_table -2; wdl -2; dtz -14; 151 | 2b4q/4K3/8/5k2/8/8/8/8 b - - wdl_table 2; wdl 2; dtz 3; 152 | 8/8/8/1K6/8/7Q/8/3kb3 w - - wdl_table 2; wdl 2; dtz 7; 153 | 8/7k/K7/6r1/8/5R2/8/8 w - - wdl_table 0; wdl 0; dtz 0; 154 | 8/8/1b6/8/8/8/1k4QK/8 b - - wdl_table -2; wdl -2; dtz -18; 155 | q7/8/8/2b2k2/8/3K4/8/8 b - - wdl_table 2; wdl 2; dtz 5; 156 | 7k/5K2/6q1/8/8/8/8/2Q5 w - - wdl_table 0; wdl 2; dtz 1; 157 | 1B6/8/8/1Q6/8/k7/8/7K b - - wdl_table -2; wdl -2; dtz -6; 158 | 6R1/8/5b2/5K2/8/8/8/1k6 b - - wdl_table 0; wdl 0; dtz 0; 159 | 8/8/8/1N1Q4/2K5/6k1/8/8 w - - wdl_table 2; wdl 2; dtz 9; 160 | 2k5/8/4N3/2K5/8/1b6/8/8 b - - wdl_table 0; wdl 0; dtz 0; 161 | 8/8/2Q5/8/8/1b6/7K/1k6 w - - wdl_table 2; wdl 2; dtz 15; 162 | 8/8/2N5/3k4/8/1K6/2b5/8 w - - wdl_table 0; wdl 0; dtz 0; 163 | 8/8/8/3k4/6p1/8/P7/2K5 b - - wdl_table 2; wdl 2; dtz 1; 164 | 8/8/3P1K1p/1k6/8/8/8/8 b - - wdl_table -2; wdl -2; dtz -3; 165 | 8/8/6k1/2r5/6K1/8/N7/8 w - - wdl_table 0; wdl 0; dtz 0; 166 | 5R2/1K6/8/4N3/8/8/8/1k6 w - - wdl_table 2; wdl 2; dtz 13; 167 | 8/8/8/2R5/1K6/8/5k2/8 w - - wdl_table 2; wdl 2; dtz 21; 168 | 3K4/8/8/8/8/8/2k2b1N/8 b - - wdl_table 0; wdl 0; dtz 0; 169 | 8/8/8/3q4/8/5k1P/7K/8 w - - wdl_table -2; wdl -2; dtz -4; 170 | 4k3/2b5/2N5/8/4K3/8/8/8 b - - wdl_table 0; wdl 0; dtz 0; 171 | R7/8/6R1/8/7k/1K6/8/8 b - - wdl_table -2; wdl -2; dtz -2; 172 | K7/3q4/5R2/5k2/8/8/8/8 b - - wdl_table 2; wdl 2; dtz 1; 173 | 2k1b3/1q6/8/8/8/8/K7/8 w - - wdl_table -2; wdl -2; dtz -6; 174 | 8/8/1Pk5/8/8/4b3/8/7K b - - wdl_table 0; wdl 0; dtz 0; 175 | 4k3/8/8/8/8/4b3/1K6/n7 b - - wdl_table 2; wdl 2; dtz 56; 176 | 2B5/8/1K6/r7/5k2/8/8/8 w - - wdl_table 0; wdl 0; dtz 0; 177 | 7K/8/8/N3k3/7P/8/8/8 b - - wdl_table 0; wdl 0; dtz 0; 178 | 8/1K6/1b6/8/8/4n3/2k5/8 b - - wdl_table 2; wdl 2; dtz 52; 179 | K7/8/8/3R4/8/8/7B/7k b - - wdl_table -2; wdl -2; dtz -16; 180 | 1K6/8/6B1/8/8/8/5B2/k7 b - - wdl_table -2; wdl -2; dtz -27; 181 | 8/1KP5/8/8/8/2N1k3/8/8 w - - wdl_table 2; wdl 2; dtz 1; 182 | 8/8/8/8/5r2/8/3N2k1/3K4 w - - wdl_table 0; wdl 0; dtz 0; 183 | 7R/8/8/8/B6k/8/8/K7 b - - wdl_table -2; wdl -2; dtz -22; 184 | 5N2/8/8/6K1/1k6/8/3n4/8 w - - wdl_table 0; wdl 0; dtz 0; 185 | 1K6/8/8/8/5k2/1Q6/8/5b2 b - - wdl_table -2; wdl -2; dtz -22; 186 | 1r6/5k2/1n6/8/8/K7/8/8 w - - wdl_table -2; wdl -2; dtz -16; 187 | 8/8/6K1/8/4n3/4p1k1/8/8 b - - wdl_table 2; wdl 2; dtz 1; 188 | 8/7k/8/8/3K4/pQ6/8/8 w - - wdl_table 2; wdl 2; dtz 1; 189 | 8/8/5N2/6K1/8/3kN3/8/8 w - - wdl_table 0; wdl 0; dtz 0; 190 | 1k4b1/8/1r2K3/8/8/8/8/8 w - - wdl_table -2; wdl -2; dtz -18; 191 | 8/8/2kb4/8/8/7Q/8/7K b - - wdl_table -2; wdl -2; dtz -22; 192 | 6n1/8/8/8/4r3/8/k4K2/8 w - - wdl_table -2; wdl -2; dtz -18; 193 | K7/8/b3N3/7k/8/8/8/8 w - - wdl_table 0; wdl 0; dtz 0; 194 | 8/3k4/8/8/8/8/4P3/3K4 w - - wdl_table 0; wdl 0; dtz 0; 195 | 8/8/3k4/8/8/6KN/3N4/8 b - - wdl_table 0; wdl 0; dtz 0; 196 | 8/6k1/8/8/8/3Q4/8/4K2N b - - wdl_table -2; wdl -2; dtz -12; 197 | B3K2B/8/8/8/8/8/4k3/8 b - - wdl_table -2; wdl -2; dtz -33; 198 | 6k1/8/8/8/8/4n3/8/K7 b - - wdl_table 0; wdl 0; dtz 0; 199 | 8/2k5/8/1K6/4n3/8/7n/8 w - - wdl_table 0; wdl 0; dtz 0; 200 | 1R6/3k4/8/8/8/1K6/8/2q5 b - - wdl_table 2; wdl 2; dtz 3; 201 | --------------------------------------------------------------------------------