Chess player/PicoLisp: Difference between revisions

no edit summary
m (→‎{{header|PicoLisp}}: "header" template isn't necessary on this page)
No edit summary
 
Line 1:
This implementation supports all chess rules (including castling, pawn promotion and en passant), switching sides, unlimited undo/redo, and the setup, saving and loading of board positions to/from files.
<langsyntaxhighlight lang="PicoLisp"># *Board a1 .. h8
# *White *Black *WKPos *BKPos *Pinned
# *Depth *Moved *Undo *Redo *Me *You
Line 566:
(val This)
(not (memq This *Moved)) ) )
(append *White *Black) ) ) ) ) ) )</lang>
</syntaxhighlight>
Start:
<pre>
<pre>$ pil chess.l -main +
+---+---+---+---+---+---+---+---+
8 |<R>|<N>|<B>|<Q>|<K>|<B>|<N>|<R>|
Line 586 ⟶ 588:
1 | R | N | B | Q | K | B | N | R |
+---+---+---+---+---+---+---+---+
a b c d e f g h</pre>
</pre>
Entering moves:
<syntaxhighlight lang ="PicoLisp">: (go e2 e4)</langsyntaxhighlight>
 
Undo moves:
<syntaxhighlight lang ="PicoLisp">: (go -)</langsyntaxhighlight>
 
Redo:
<syntaxhighlight lang ="PicoLisp">: (go +)</langsyntaxhighlight>
 
Switch sides:
<syntaxhighlight lang ="PicoLisp">: (go)</langsyntaxhighlight>
 
Save position to a file:
<langsyntaxhighlight lang="PicoLisp">: (ppos "file")</langsyntaxhighlight>
 
Load position from file:
<langsyntaxhighlight lang="PicoLisp">: (load "file")</langsyntaxhighlight>