Readme doc updates
This commit is contained in:
20
README.md
20
README.md
@@ -299,3 +299,23 @@ $parser->move("g1f3");
|
|||||||
$notation = $parser->getNotation(); // returns Nf3
|
$notation = $parser->getNotation(); // returns Nf3
|
||||||
$fen = $parser->getFen();
|
$fen = $parser->getFen();
|
||||||
// $fen = rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R b KQkq - 1 1
|
// $fen = rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R b KQkq - 1 1
|
||||||
|
|
||||||
|
######4) Get valid moves
|
||||||
|
|
||||||
|
```PHP
|
||||||
|
$parser = new FenParser0x88('6k1/6p1/4n3/8/8/8/B7/6K1 b - - 0 1');
|
||||||
|
$validBlackMoves = $parser->getValidMovesBoardCoordinates("black");
|
||||||
|
echo json_encode($validBlackMoves);
|
||||||
|
```
|
||||||
|
|
||||||
|
which outputs
|
||||||
|
|
||||||
|
```JSON
|
||||||
|
{"g8":["f7","h7","f8","h8"],"g7":["g6","g5"],"e6":[]}
|
||||||
|
```
|
||||||
|
|
||||||
|
where key, example "g8" is from square and ["f7","h7","f8","h8"] are all the valid moves
|
||||||
|
for the king on "g8".
|
||||||
|
|
||||||
|
In this example, there's a king on e6. However, it cannot move because it is pinned by a white
|
||||||
|
bishop on a2.
|
@@ -994,6 +994,9 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1';
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
$validBlackMoves = $parser->getValidMovesBoardCoordinates("black");
|
$validBlackMoves = $parser->getValidMovesBoardCoordinates("black");
|
||||||
|
|
||||||
|
echo json_encode($validBlackMoves);
|
||||||
|
|
||||||
$validKingMoves = $validBlackMoves["g8"];
|
$validKingMoves = $validBlackMoves["g8"];
|
||||||
// then
|
// then
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user