cvs: peardoc / global.ent /en/package structures.xml /en/package/structures games-chess.xml /en/package/structures/games-chess intro.xml
| From: | Greg Beaver | Date: | Sun, 19 Nov 2006 06:55:45 +0000 |
| Subject: | cvs: peardoc / global.ent /en/package structures.xml /en/package/structures games-chess.xml /en/package/structures/games-chess intro.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-8830@lists.php.net to get a copy of this message | ||
cellog Sun Nov 19 06:55:45 2006 UTC
Added files:
/peardoc/en/package/structures games-chess.xml
/peardoc/en/package/structures/games-chess intro.xml
Modified files:
/peardoc/en/package structures.xml
/peardoc global.ent
Log:
new documentation for Games_Chess package
http://cvs.php.net/viewvc.cgi/peardoc/en/package/structures.xml?r1=1.5&r2=1.6&diff_format=u Index: peardoc/en/package/structures.xml diff -u peardoc/en/package/structures.xml:1.5 peardoc/en/package/structures.xml:1.6 --- peardoc/en/package/structures.xml:1.5 Thu Jul 13 13:24:26 2006 +++ peardoc/en/package/structures.xml Sun Nov 19 06:55:45 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <chapter id="package.structures"> <title>Structures</title> @@ -11,6 +11,7 @@ &package.structures.structures-bibtex; &package.structures.structures-datagrid; + &package.structures.games-chess; &package.structures.structures-graph; &package.structures.structures-tree; http://cvs.php.net/viewvc.cgi/peardoc/global.ent?r1=1.68&r2=1.69&diff_format=u Index: peardoc/global.ent diff -u peardoc/global.ent:1.68 peardoc/global.ent:1.69 --- peardoc/global.ent:1.68 Tue Nov 14 12:51:28 2006 +++ peardoc/global.ent Sun Nov 19 06:55:45 2006 @@ -1,6 +1,6 @@ <!-- -*- SGML -*- - $Id: global.ent,v 1.68 2006/11/14 12:51:28 cweiske Exp $ + $Id: global.ent,v 1.69 2006/11/19 06:55:45 cellog Exp $ Contains global "macros" for all the XML documents. @@ -221,3 +221,4 @@ <!-- For links to the API documentation generated by phpdocumentor --> <!ENTITY phpdocbase.html-page2 "http://pear.php.net/package/HTML_Page2/docs/latest/HTML_Page2/HTML_Page2.html#method"> <!ENTITY phpdocbase.console-progressbar "http://pear.php.net/package/Console_ProgressBar/docs/latest/Console_ProgressBar/Console_ProgressBar.html#method"> +<!ENTITY phpdocbase.games-chess "http://pear.php.net/package/Games_Chess/docs/latest/Games_Chess/"> http://cvs.php.net/viewvc.cgi/peardoc/en/package/structures/games-chess.xml?view=markup&rev=1.1 Index: peardoc/en/package/structures/games-chess.xml +++ peardoc/en/package/structures/games-chess.xml <?xml version="1.0" encoding="iso-8859-1" ?> <!-- $Revision: 1.1 $ --> <sect1 id="package.structures.games-chess"> <title>Games_Chess</title> <para> Games_Chess is like a brilliant helper who can tell you anything you need to know about an abstract chess game. The only thing Games_Chess cannot do is play against you - it is not a chess engine. Games_Chess handles the logic a chessboard and parsing standard FEN (Forsyth-Edwards Notation) for describing a position as well as SAN (Standard Algebraic Notation) for describing individual moves. This package can be used as a backend driver for playing chess, or for validating and/or creating PGN files using the File_ChessPGN package (when it is completed) </para> &package.structures.games-chess.intro; </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/peardoc/en/package/structures/games-chess/intro.xml?view=markup&rev=1.1 Index: peardoc/en/package/structures/games-chess/intro.xml +++ peardoc/en/package/structures/games-chess/intro.xml <?xml version="1.0" encoding="iso-8859-1" ?> <!-- $Revision: 1.1 $ --> <refentry id="package.structures.games-chess.intro"> <refnamediv> <refname>Introduction</refname> <refpurpose> Basic usage of Games_Chess </refpurpose> </refnamediv> <refsect1> <title>What is Games_Chess?</title> <para> Games_Chess provides a basic interface for validating and playing chess. Games_Chess has facilities for calculating all of the important chess rules including check, checkmate, stalemate, basic draws such as bishop+king versus king, 50 move draw, en passant pawn captures, castling, double space first pawn move and basic piece movement. In addition, Games_Chess can set up a board to a position using the Forsyth-Edwards Notation (<literal>FEN</literal>) and can output a list of moves in Standard Algebraic Notation (<literal>SAN</literal>) as well as parse any valid SAN move, no matter how obscure (Qa3xf3, for instance), as well as simple "move the piece on a3 to h3" commands. </para> </refsect1> <refsect1 id="package.structures.games-chess.intro.how"> <title>How do I use Games_Chess?</title> <para> The Games_Chess package comes with a demonstration file, which has highlighted source at <ulink url="http://pear.php.net/package/Games_Chess/docs/latest/__filesource/fsource_Games_Chess__Games_Chess-1.0.0RC1examplesHTMLChess.php.html">This location</ulink>. </para> <para> The Games_Chess package provides three different drivers, one for playing a standard chess game, and two for playing interesting variant games that are popular on the <ulink url="http://www.chessclub.com">Internet Chess Club (ICC)</ulink>. <orderedlist> <listitem> <para> <ulink url="http://www.chessclub.com/help/Crazyhouse">Crazyhouse</ulink>. basic rules in Crazyhouse chess allow you to place pieces you have captured from your opponent on the board as new pieces for your own army. This is a wild and highly tactical game. </para> </listitem> <listitem> <para> <ulink url="http://www.chessclub.com/help/wild17">Loser's Chess</ulink>. Loser's chess is similar to checkers in that if a capture is possible, it must be executed. For this reason, most of the moves are forcing moves in this game, and it results in very fast games. </para> </listitem> </orderedlist> </para> <para> To use Games_Chess on the most basic level is simple. Here is a sample script showing the initialization of the three drivers: </para> <para> <programlisting role="php"> <![CDATA[ <?php require_once 'Games/Chess/Standard.php'; require_once 'Games/Chess/Crazyhouse.php'; require_once 'Games/Chess/Losers.php'; $standard = new Games_Chess_Standard; $crazyhouse = new Games_Chess_Crazyhouse; $losers = new Games_Chess_Losers; ?> ]]> </programlisting> By default, a Games_Chess driver is created with a blank board. To set up a new starting position, use this code: <programlisting role="php"> <![CDATA[ <?php require_once 'Games/Chess/Standard.php'; $standard = new Games_Chess_Standard; $standard->resetGame(); ?> ]]> </programlisting> If you wish to load a particular starting position in <ulink url="http://en.wikipedia.org/wiki/Forsyth-Edwards_notation">FEN</ulink> notation, pass the FEN string to <function>resetGame</function> like so: <programlisting role="php"> <![CDATA[ <?php require_once 'Games/Chess/Standard.php'; $standard = new Games_Chess_Standard; $standard->resetGame('rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2'); ?> ]]> </programlisting> </para> <refsect2 id="package.structures.games-chess.intro.how.move"> <title>How to move pieces with Games_Chess</title> <para> There are two basic methods for performing moves with Games_Chess, <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodmoveSAN">moveSAN</ulink> and <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodmoveSquare">moveSquare</ulink>. Both of these methods either return &true; or a <classname>PEAR_Error</classname> class upon error, so the proper way to handle for a return value is: <programlisting role="php"> <![CDATA[ <?php require_once 'Games/Chess/Standard.php'; $standard = new Games_Chess_Standard; $err = $standard->moveSAN('Nf9'); if ($standard->isError($err)) { echo $err->getMessage(); die; } ?> ]]> </programlisting> Note that <function>Games_Chess->isError</function> should be used as the <classname>PEAR_Error</classname> class is only loaded when needed, to help with efficiency. If this is not a concern (and it will only be for sites serving thousands of pages per second), it is simpler to set a PEAR_Error callback, which is demonstrated in the next example. </para> <para> The example below demonstrates the two ways that Games_Chess should be called to make moves on the chess board, including the way to represent a placement move in the Crazyhouse variant: <programlisting role="php"> <![CDATA[ <?php require_once 'PEAR.php'; // for the PEAR_Error class function showerror($err) { echo $err->getMessage(); exit; } require_once 'Games/Chess/Standard.php'; require_once 'Games/Chess/Crazyhouse.php'; PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'showerror'); $standard = new Games_Chess_Standard; $crazyhouse = new Games_Chess_Crazyhouse; $standard->resetGame(); $crazyhouse->resetGame(); $standard->moveSAN('e4'); // 'e2' to 'e4' if using moveSquare $standard->moveSquare('d7', 'd5'); // 'd5' if using moveSAN $standard->moveSAN('exd5'); $crazyhouse->moveSquare('e2', 'e4'); // same as moveSAN() above $crazyhouse->moveSAN('d5'); // save as moveSquare above $crazyhouse->moveSAN('exd5'); $crazyhouse->moveSAN('Qxd5'); $crazyhouse->moveSAN('P@d7'); // dumb move, but demonstrates piece placement ?> ]]> </programlisting> Note that if promoting a pawn, <function>moveSquare</function> requires that the newly promoted piece type be passed in. Options are <literal>Q</literal> for queen, <literal>R</literal> for rook, <literal>B</literal> for bishop and <literal>N</literal> for knight. <programlisting role="php"> <![CDATA[ <?php require_once 'PEAR.php'; // for the PEAR_Error class function showerror($err) { echo $err->getMessage(); exit; } require_once 'Games/Chess/Crazyhouse.php'; PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'showerror'); $crazyhouse = new Games_Chess_Crazyhouse; $crazyhouse->resetGame(); $crazyhouse->moveSAN('e4'); $crazyhouse->moveSAN('d5'); $crazyhouse->moveSAN('exd5'); $crazyhouse->moveSAN('Qxd5'); $crazyhouse->moveSAN('d3'); $crazyhouse->moveSAN('Kd7'); $crazyhouse->moveSAN('d4'); $crazyhouse->moveSAN('Ke6'); $crazyhouse->moveSAN('P@d7'); $crazyhouse->moveSAN('Qd6'); // $crazyhouse->moveSAN('d8=Q'); // normal way to do this $crazyhouse->moveSquare('d7', 'd8', 'Q'); // using moveSquare to do this // dumb moves, but demonstrates pawn promotion to queen ?> ]]> </programlisting> </para> </refsect2> <refsect2 id="package.structures.games-chess.intro.how.getinfo"> <title>Retrieving information on the game in progress</title> <para> To retrieve necessary information such as the current move list, current FEN, list of captured pieces (Crazyhouse only), determine whether the game is over and so on, you'll want to use one of the following methods: <itemizedlist> <listitem> <para> <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodgameOver"><function>gameOver</function></ulink>. This method can be used to determine if the game has concluded, and simply returns an abbreviation of <literal>W</literal> if the white pieces have won (checkmate), <literal>B</literal> if the black pieces have won (checkmate), <literal>D</literal> if there is a draw, or false if the game is still in progress. </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodrenderFen"><function>renderFen</function></ulink>. </para> <para> This method returns a Forsyth-Edwards Notation (<literal>FEN</literal>) representation of the current game state. Note that the FEN standard does not contain a way to represent captured pieces, and so cannot be used to exactly replicate a Crazyhouse game in progress, although it can be close. </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodtoArray"><function>toArray</function></ulink>. </para> <para> For the Standard and Loser's chess drivers, this returns an associative array of algebraic square name (<literal>a1</literal> to <literal>h8</literal>) mapped to its contents. If the square is unoccupied, it will contain its algebraic square name (<literal>a1</literal> will map to <literal>a1</literal>), otherwise it will contain the piece name, one of <literal>P</literal>, <literal>R</literal>, <literal>N</literal>, <literal>B</literal>, <literal>Q</literal> or <literal>K</literal>. If the piece is a white piece, it will be in upper case, like <literal>P</literal>, and if the piece is a black piece, it will be in lower case like <literal>p</literal>. </para> <para> For the Crazyhouse driver, this returns an associative array with two indices, <literal>board</literal> and <literal>captured</literal>. The <literal>board</literal> element is identical to the return for Standard/Loser's chess drivers described in the previous paragraph. The <literal>captured</literal> sub-array contains an array of this format: <programlisting role="php"> <![CDATA[ <?php $captured = array( 'W' => array( 'P' => 6, // 6 black pawns captured by white 'R' => 0, 'N' => 0, 'B' => 0, 'Q' => 0, ), 'B' => array( 'P' => 4, // 4 white pawns captured by black 'R' => 0, 'N' => 0, 'B' => 0, 'Q' => 0, ), ); ?> ]]> </programlisting> Each segment represents white's or black's pieces (W and B), and each sub-element represents the number of captured pieces of that type. In the example above, white can choose to place a pawn for up to the next 6 moves in a row, whereas black can choose to place a pawn for up to the next 4 moves in a row. </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodtoMove"><function>toMove</function></ulink>. </para> <para> This methods simply returns the color of the pieces that have the next move. <literal>W</literal> is returned for white, <literal>B</literal> is returned for black. </para> </listitem> </itemizedlist> </para> </refsect2> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
http://cvs.php.net/viewvc.cgi/peardoc/en/package/structures.xml?r1=1.5&r2=1.6&diff_format=u Index: peardoc/en/package/structures.xml diff -u peardoc/en/package/structures.xml:1.5 peardoc/en/package/structures.xml:1.6 --- peardoc/en/package/structures.xml:1.5 Thu Jul 13 13:24:26 2006 +++ peardoc/en/package/structures.xml Sun Nov 19 06:55:45 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <chapter id="package.structures"> <title>Structures</title> @@ -11,6 +11,7 @@ &package.structures.structures-bibtex; &package.structures.structures-datagrid; + &package.structures.games-chess; &package.structures.structures-graph; &package.structures.structures-tree; http://cvs.php.net/viewvc.cgi/peardoc/global.ent?r1=1.68&r2=1.69&diff_format=u Index: peardoc/global.ent diff -u peardoc/global.ent:1.68 peardoc/global.ent:1.69 --- peardoc/global.ent:1.68 Tue Nov 14 12:51:28 2006 +++ peardoc/global.ent Sun Nov 19 06:55:45 2006 @@ -1,6 +1,6 @@ <!-- -*- SGML -*- - $Id: global.ent,v 1.68 2006/11/14 12:51:28 cweiske Exp $ + $Id: global.ent,v 1.69 2006/11/19 06:55:45 cellog Exp $ Contains global "macros" for all the XML documents. @@ -221,3 +221,4 @@ <!-- For links to the API documentation generated by phpdocumentor --> <!ENTITY phpdocbase.html-page2 "http://pear.php.net/package/HTML_Page2/docs/latest/HTML_Page2/HTML_Page2.html#method"> <!ENTITY phpdocbase.console-progressbar "http://pear.php.net/package/Console_ProgressBar/docs/latest/Console_ProgressBar/Console_ProgressBar.html#method"> +<!ENTITY phpdocbase.games-chess "http://pear.php.net/package/Games_Chess/docs/latest/Games_Chess/"> http://cvs.php.net/viewvc.cgi/peardoc/en/package/structures/games-chess.xml?view=markup&rev=1.1 Index: peardoc/en/package/structures/games-chess.xml +++ peardoc/en/package/structures/games-chess.xml <?xml version="1.0" encoding="iso-8859-1" ?> <!-- $Revision: 1.1 $ --> <sect1 id="package.structures.games-chess"> <title>Games_Chess</title> <para> Games_Chess is like a brilliant helper who can tell you anything you need to know about an abstract chess game. The only thing Games_Chess cannot do is play against you - it is not a chess engine. Games_Chess handles the logic a chessboard and parsing standard FEN (Forsyth-Edwards Notation) for describing a position as well as SAN (Standard Algebraic Notation) for describing individual moves. This package can be used as a backend driver for playing chess, or for validating and/or creating PGN files using the File_ChessPGN package (when it is completed) </para> &package.structures.games-chess.intro; </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/peardoc/en/package/structures/games-chess/intro.xml?view=markup&rev=1.1 Index: peardoc/en/package/structures/games-chess/intro.xml +++ peardoc/en/package/structures/games-chess/intro.xml <?xml version="1.0" encoding="iso-8859-1" ?> <!-- $Revision: 1.1 $ --> <refentry id="package.structures.games-chess.intro"> <refnamediv> <refname>Introduction</refname> <refpurpose> Basic usage of Games_Chess </refpurpose> </refnamediv> <refsect1> <title>What is Games_Chess?</title> <para> Games_Chess provides a basic interface for validating and playing chess. Games_Chess has facilities for calculating all of the important chess rules including check, checkmate, stalemate, basic draws such as bishop+king versus king, 50 move draw, en passant pawn captures, castling, double space first pawn move and basic piece movement. In addition, Games_Chess can set up a board to a position using the Forsyth-Edwards Notation (<literal>FEN</literal>) and can output a list of moves in Standard Algebraic Notation (<literal>SAN</literal>) as well as parse any valid SAN move, no matter how obscure (Qa3xf3, for instance), as well as simple "move the piece on a3 to h3" commands. </para> </refsect1> <refsect1 id="package.structures.games-chess.intro.how"> <title>How do I use Games_Chess?</title> <para> The Games_Chess package comes with a demonstration file, which has highlighted source at <ulink url="http://pear.php.net/package/Games_Chess/docs/latest/__filesource/fsource_Games_Chess__Games_Chess-1.0.0RC1examplesHTMLChess.php.html">This location</ulink>. </para> <para> The Games_Chess package provides three different drivers, one for playing a standard chess game, and two for playing interesting variant games that are popular on the <ulink url="http://www.chessclub.com">Internet Chess Club (ICC)</ulink>. <orderedlist> <listitem> <para> <ulink url="http://www.chessclub.com/help/Crazyhouse">Crazyhouse</ulink>. basic rules in Crazyhouse chess allow you to place pieces you have captured from your opponent on the board as new pieces for your own army. This is a wild and highly tactical game. </para> </listitem> <listitem> <para> <ulink url="http://www.chessclub.com/help/wild17">Loser's Chess</ulink>. Loser's chess is similar to checkers in that if a capture is possible, it must be executed. For this reason, most of the moves are forcing moves in this game, and it results in very fast games. </para> </listitem> </orderedlist> </para> <para> To use Games_Chess on the most basic level is simple. Here is a sample script showing the initialization of the three drivers: </para> <para> <programlisting role="php"> <![CDATA[ <?php require_once 'Games/Chess/Standard.php'; require_once 'Games/Chess/Crazyhouse.php'; require_once 'Games/Chess/Losers.php'; $standard = new Games_Chess_Standard; $crazyhouse = new Games_Chess_Crazyhouse; $losers = new Games_Chess_Losers; ?> ]]> </programlisting> By default, a Games_Chess driver is created with a blank board. To set up a new starting position, use this code: <programlisting role="php"> <![CDATA[ <?php require_once 'Games/Chess/Standard.php'; $standard = new Games_Chess_Standard; $standard->resetGame(); ?> ]]> </programlisting> If you wish to load a particular starting position in <ulink url="http://en.wikipedia.org/wiki/Forsyth-Edwards_notation">FEN</ulink> notation, pass the FEN string to <function>resetGame</function> like so: <programlisting role="php"> <![CDATA[ <?php require_once 'Games/Chess/Standard.php'; $standard = new Games_Chess_Standard; $standard->resetGame('rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2'); ?> ]]> </programlisting> </para> <refsect2 id="package.structures.games-chess.intro.how.move"> <title>How to move pieces with Games_Chess</title> <para> There are two basic methods for performing moves with Games_Chess, <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodmoveSAN">moveSAN</ulink> and <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodmoveSquare">moveSquare</ulink>. Both of these methods either return &true; or a <classname>PEAR_Error</classname> class upon error, so the proper way to handle for a return value is: <programlisting role="php"> <![CDATA[ <?php require_once 'Games/Chess/Standard.php'; $standard = new Games_Chess_Standard; $err = $standard->moveSAN('Nf9'); if ($standard->isError($err)) { echo $err->getMessage(); die; } ?> ]]> </programlisting> Note that <function>Games_Chess->isError</function> should be used as the <classname>PEAR_Error</classname> class is only loaded when needed, to help with efficiency. If this is not a concern (and it will only be for sites serving thousands of pages per second), it is simpler to set a PEAR_Error callback, which is demonstrated in the next example. </para> <para> The example below demonstrates the two ways that Games_Chess should be called to make moves on the chess board, including the way to represent a placement move in the Crazyhouse variant: <programlisting role="php"> <![CDATA[ <?php require_once 'PEAR.php'; // for the PEAR_Error class function showerror($err) { echo $err->getMessage(); exit; } require_once 'Games/Chess/Standard.php'; require_once 'Games/Chess/Crazyhouse.php'; PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'showerror'); $standard = new Games_Chess_Standard; $crazyhouse = new Games_Chess_Crazyhouse; $standard->resetGame(); $crazyhouse->resetGame(); $standard->moveSAN('e4'); // 'e2' to 'e4' if using moveSquare $standard->moveSquare('d7', 'd5'); // 'd5' if using moveSAN $standard->moveSAN('exd5'); $crazyhouse->moveSquare('e2', 'e4'); // same as moveSAN() above $crazyhouse->moveSAN('d5'); // save as moveSquare above $crazyhouse->moveSAN('exd5'); $crazyhouse->moveSAN('Qxd5'); $crazyhouse->moveSAN('P@d7'); // dumb move, but demonstrates piece placement ?> ]]> </programlisting> Note that if promoting a pawn, <function>moveSquare</function> requires that the newly promoted piece type be passed in. Options are <literal>Q</literal> for queen, <literal>R</literal> for rook, <literal>B</literal> for bishop and <literal>N</literal> for knight. <programlisting role="php"> <![CDATA[ <?php require_once 'PEAR.php'; // for the PEAR_Error class function showerror($err) { echo $err->getMessage(); exit; } require_once 'Games/Chess/Crazyhouse.php'; PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'showerror'); $crazyhouse = new Games_Chess_Crazyhouse; $crazyhouse->resetGame(); $crazyhouse->moveSAN('e4'); $crazyhouse->moveSAN('d5'); $crazyhouse->moveSAN('exd5'); $crazyhouse->moveSAN('Qxd5'); $crazyhouse->moveSAN('d3'); $crazyhouse->moveSAN('Kd7'); $crazyhouse->moveSAN('d4'); $crazyhouse->moveSAN('Ke6'); $crazyhouse->moveSAN('P@d7'); $crazyhouse->moveSAN('Qd6'); // $crazyhouse->moveSAN('d8=Q'); // normal way to do this $crazyhouse->moveSquare('d7', 'd8', 'Q'); // using moveSquare to do this // dumb moves, but demonstrates pawn promotion to queen ?> ]]> </programlisting> </para> </refsect2> <refsect2 id="package.structures.games-chess.intro.how.getinfo"> <title>Retrieving information on the game in progress</title> <para> To retrieve necessary information such as the current move list, current FEN, list of captured pieces (Crazyhouse only), determine whether the game is over and so on, you'll want to use one of the following methods: <itemizedlist> <listitem> <para> <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodgameOver"><function>gameOver</function></ulink>. This method can be used to determine if the game has concluded, and simply returns an abbreviation of <literal>W</literal> if the white pieces have won (checkmate), <literal>B</literal> if the black pieces have won (checkmate), <literal>D</literal> if there is a draw, or false if the game is still in progress. </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodrenderFen"><function>renderFen</function></ulink>. </para> <para> This method returns a Forsyth-Edwards Notation (<literal>FEN</literal>) representation of the current game state. Note that the FEN standard does not contain a way to represent captured pieces, and so cannot be used to exactly replicate a Crazyhouse game in progress, although it can be close. </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodtoArray"><function>toArray</function></ulink>. </para> <para> For the Standard and Loser's chess drivers, this returns an associative array of algebraic square name (<literal>a1</literal> to <literal>h8</literal>) mapped to its contents. If the square is unoccupied, it will contain its algebraic square name (<literal>a1</literal> will map to <literal>a1</literal>), otherwise it will contain the piece name, one of <literal>P</literal>, <literal>R</literal>, <literal>N</literal>, <literal>B</literal>, <literal>Q</literal> or <literal>K</literal>. If the piece is a white piece, it will be in upper case, like <literal>P</literal>, and if the piece is a black piece, it will be in lower case like <literal>p</literal>. </para> <para> For the Crazyhouse driver, this returns an associative array with two indices, <literal>board</literal> and <literal>captured</literal>. The <literal>board</literal> element is identical to the return for Standard/Loser's chess drivers described in the previous paragraph. The <literal>captured</literal> sub-array contains an array of this format: <programlisting role="php"> <![CDATA[ <?php $captured = array( 'W' => array( 'P' => 6, // 6 black pawns captured by white 'R' => 0, 'N' => 0, 'B' => 0, 'Q' => 0, ), 'B' => array( 'P' => 4, // 4 white pawns captured by black 'R' => 0, 'N' => 0, 'B' => 0, 'Q' => 0, ), ); ?> ]]> </programlisting> Each segment represents white's or black's pieces (W and B), and each sub-element represents the number of captured pieces of that type. In the example above, white can choose to place a pawn for up to the next 6 moves in a row, whereas black can choose to place a pawn for up to the next 4 moves in a row. </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.games-chess;Games_Chess.html#methodtoMove"><function>toMove</function></ulink>. </para> <para> This methods simply returns the color of the pieces that have the next move. <literal>W</literal> is returned for white, <literal>B</literal> is returned for black. </para> </listitem> </itemizedlist> </para> </refsect2> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->