Chess player: Difference between revisions

Content added Content deleted
(→‎{{header|Python}}: add a simple Python engine using python-chess)
Line 956: Line 956:


==={{libheader|python-chess}}===
==={{libheader|python-chess}}===
A very simple chess engine (two-ply search plus mobility) using [https://github.com/niklasf/python-chess python-chess]. The computer plays Black.
A very simple chess engine (based on two-ply search plus mobility) using [https://github.com/niklasf/python-chess python-chess]. The computer plays Black.


The default Unicode board may look wonky and misaligned with certain terminal fonts. To use an ASCII board instead (like shown below), replace "print(board.unicode())" with "print(board)".
The default Unicode board may look wonky and misaligned with certain terminal fonts. To use an ASCII board instead (like shown below), replace "print(board.unicode())" with "print(board)".
Line 1,020: Line 1,020:
P P P P . P P P
P P P P . P P P
R N B Q K B . R
R N B Q K B . R
Your move?</pre>
Your move?
…</pre>
Here is the PGN of a full game against Stockfish. Like many simple chess engines, it has an unfortunate tendency to rush out with its Queen early in the game, leading to its loss:
Here is the PGN of a full game against Stockfish. Like many simple chess engines, it has an unfortunate tendency to rush out with its Queen early in the game, leading to its loss:
<pre>
<pre>
Line 1,035: Line 1,036:
15.Qxe5 Ne8 16.Qg5+ Kd6 17.O-O-O+ Kc6 18.Qb5# 1-0
15.Qxe5 Ne8 16.Qg5+ Kd6 17.O-O-O+ Kc6 18.Qb5# 1-0
</pre>
</pre>
Opening play could be improved a lot by using book moves, which is easy to do in python-chess with its Polyglot support.


=={{header|Wren}}==
=={{header|Wren}}==