Chess player: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
m (Automated syntax highlighting fixup (second round - minor fixes))
Line 14: Line 14:


or use those components as part of a complete program, demonstrating your language's support for modularity.
or use those components as part of a complete program, demonstrating your language's support for modularity.


=={{header|BASIC}}==
=={{header|BASIC}}==
{{works with|QBasic}}
{{works with|QBasic}}
Line 21: Line 19:


Encontrado en: http://www.petesqbsite.com/sections/express/issue23/Tut_QB_Chess.txt
Encontrado en: http://www.petesqbsite.com/sections/express/issue23/Tut_QB_Chess.txt
<syntaxhighlight lang=qbasic>DEFINT A-Z
<syntaxhighlight lang="qbasic">DEFINT A-Z


DECLARE SUB SQUARE (A, B, C)
DECLARE SUB SQUARE (A, B, C)
Line 497: Line 495:
COLOR 7, 0
COLOR 7, 0
END SUB</syntaxhighlight>
END SUB</syntaxhighlight>


=={{header|Go}}==
=={{header|Go}}==
There are a number of open source Chess programs written in Go on Github.
There are a number of open source Chess programs written in Go on Github.


Rather than spend a lot of time trying to write my own (likely mediocre) program, I thought I'd simply post a link to [https://github.com/notnil/chess notnil/chess] which explains its various capabilities quite well. However, you need to look at the code itself to see that it can cope with all types of move including castling, ''en passant'' capture and promotion to a piece of the player's choice.
Rather than spend a lot of time trying to write my own (likely mediocre) program, I thought I'd simply post a link to [https://github.com/notnil/chess notnil/chess] which explains its various capabilities quite well. However, you need to look at the code itself to see that it can cope with all types of move including castling, ''en passant'' capture and promotion to a piece of the player's choice.

=={{header|Perl}}==
=={{header|Perl}}==
Primarily written to see if I could find all moves with one regex. The answer was "mostly", the main problem being
Primarily written to see if I could find all moves with one regex. The answer was "mostly", the main problem being
some moves require history (the current state of the board is not sufficient for castling and en passant).
some moves require history (the current state of the board is not sufficient for castling and en passant).
I also wanted to try different methods of making moves. It does not play well, but then neither do I.
I also wanted to try different methods of making moves. It does not play well, but then neither do I.
<syntaxhighlight lang=perl>#!/usr/bin/perl
<syntaxhighlight lang="perl">#!/usr/bin/perl


use strict;
use strict;
Line 940: Line 935:
END
END
}</syntaxhighlight>
}</syntaxhighlight>

=={{header|Phix}}==
=={{header|Phix}}==
Version 0.8.1+ contains demo\rosetta\chess.exw, a slightly cleaned-up copy of a 20-year old translation of TSCP.<br>
Version 0.8.1+ contains demo\rosetta\chess.exw, a slightly cleaned-up copy of a 20-year old translation of TSCP.<br>
It isn't particularly good (though perhaps a reasonable starting point for something better), at over 1,600 lines it does not really bear any useful comparison to the lisp version, and is simply not worth posting on this site, especially in light of potential copyright issues.
It isn't particularly good (though perhaps a reasonable starting point for something better), at over 1,600 lines it does not really bear any useful comparison to the lisp version, and is simply not worth posting on this site, especially in light of potential copyright issues.

=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
{{:Chess player/PicoLisp}}
{{:Chess player/PicoLisp}}

=={{header|Python}}==
=={{header|Python}}==
==={{libheader|pygame}}===
==={{libheader|pygame}}===
Line 963: Line 955:


The computer may say some things that allude to the chess game in ''2001: A Space Odyssey'', by the way.
The computer may say some things that allude to the chess game in ''2001: A Space Odyssey'', by the way.
<syntaxhighlight lang=python># Simple Python chess engine
<syntaxhighlight lang="python"># Simple Python chess engine
# Computer plays Black
# Computer plays Black


Line 1,100: Line 1,092:
18.Ke2 Bxa1 19.Kd2 Qxf1 20.Kc2 Qxf2+ 21.Kb1 Qb2# 0-1
18.Ke2 Bxa1 19.Kd2 Qxf1 20.Kc2 Qxf2+ 21.Kb1 Qb2# 0-1
</pre>
</pre>

=={{header|Wren}}==
=={{header|Wren}}==
{{trans|BASIC}}
{{trans|BASIC}}
Line 1,107: Line 1,098:
{{libheader|Wren-ioutil}}
{{libheader|Wren-ioutil}}
{{libheader|Wren-str}}
{{libheader|Wren-str}}
<syntaxhighlight lang=ecmascript>import "/trait" for Stepped
<syntaxhighlight lang="ecmascript">import "/trait" for Stepped
import "/fmt" for Fmt
import "/fmt" for Fmt
import "/ioutil" for Input, Output
import "/ioutil" for Input, Output