Chess player/PicoLisp: Difference between revisions
Content added Content deleted
m (→{{header|PicoLisp}}: "header" template isn't necessary on this page) |
No edit summary |
||
Line 1: | 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. |
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. |
||
< |
<syntaxhighlight lang="PicoLisp"># *Board a1 .. h8 |
||
# *White *Black *WKPos *BKPos *Pinned |
# *White *Black *WKPos *BKPos *Pinned |
||
# *Depth *Moved *Undo *Redo *Me *You |
# *Depth *Moved *Undo *Redo *Me *You |
||
Line 566: | Line 566: | ||
(val This) |
(val This) |
||
(not (memq This *Moved)) ) ) |
(not (memq This *Moved)) ) ) |
||
(append *White *Black) ) ) ) ) ) ) |
(append *White *Black) ) ) ) ) ) ) |
||
</syntaxhighlight> |
|||
Start: |
Start: |
||
<pre> |
|||
$ pil chess.l -main + |
|||
+---+---+---+---+---+---+---+---+ |
+---+---+---+---+---+---+---+---+ |
||
8 |<R>|<N>|<B>|<Q>|<K>|<B>|<N>|<R>| |
8 |<R>|<N>|<B>|<Q>|<K>|<B>|<N>|<R>| |
||
Line 586: | Line 588: | ||
1 | R | N | B | Q | K | B | N | R | |
1 | R | N | B | Q | K | B | N | R | |
||
+---+---+---+---+---+---+---+---+ |
+---+---+---+---+---+---+---+---+ |
||
a b c d e f g h |
a b c d e f g h |
||
</pre> |
|||
Entering moves: |
Entering moves: |
||
<lang |
<syntaxhighlight lang="PicoLisp">: (go e2 e4)</syntaxhighlight> |
||
Undo moves: |
Undo moves: |
||
<lang |
<syntaxhighlight lang="PicoLisp">: (go -)</syntaxhighlight> |
||
Redo: |
Redo: |
||
<lang |
<syntaxhighlight lang="PicoLisp">: (go +)</syntaxhighlight> |
||
Switch sides: |
Switch sides: |
||
<lang |
<syntaxhighlight lang="PicoLisp">: (go)</syntaxhighlight> |
||
Save position to a file: |
Save position to a file: |
||
< |
<syntaxhighlight lang="PicoLisp">: (ppos "file")</syntaxhighlight> |
||
Load position from file: |
Load position from file: |
||
< |
<syntaxhighlight lang="PicoLisp">: (load "file")</syntaxhighlight> |