Skip to content

Commit

Permalink
Updated the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
programarivm committed Jun 14, 2024
1 parent 7e81eb1 commit a337728
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
13 changes: 8 additions & 5 deletions docs/chess-tutor.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use Chess\Tutor\FenEvaluation;

$board = FenToBoardFactory::create('8/5k2/4n3/8/8/1BK5/1B6/8 w - - 0 1');

$paragraph = (new FenEvaluation($board))->getParagraph();
$paragraph = (new FenEvaluation($board))->paragraph;

$text = implode(' ', $paragraph);

Expand All @@ -37,11 +37,13 @@ A heuristic evaluation is a quick numerical estimate of a chess position that su
use Chess\Play\SanPlay;
use Chess\Tutor\PgnEvaluation;

$pgn = 'd4';

$movetext = '1.Nf3 d5 2.g3 c5';

$board = (new SanPlay($movetext))->validate()->board;

$paragraph = (new PgnEvaluation('d4', $board))->getParagraph();
$paragraph = (new PgnEvaluation($pgn, $board))->paragraph;

$text = implode(' ', $paragraph);

Expand All @@ -68,14 +70,15 @@ use Chess\UciEngine\Details\Limit;

$movetext = '1.d4 d5 2.c4 Nc6 3.cxd5 Qxd5 4.e3 e5 5.Nc3 Bb4 6.Bd2 Bxc3 7.Bxc3 exd4 8.Ne2';

$limit = (new Limit())->setDepth(12);
$limit = new Limit();
$limit->depth = 12;
$stockfish = new UciEngine('/usr/games/stockfish');
$board = (new SanPlay($movetext))->validate()->board;

$goodPgnEvaluation = new GoodPgnEvaluation($limit, $stockfish, $board);

$pgn = $goodPgnEvaluation->getPgn();
$paragraph = implode(' ', $goodPgnEvaluation->getParagraph());
$pgn = $goodPgnEvaluation->pgn;
$paragraph = implode(' ', $goodPgnEvaluation->paragraph);

echo $pgn . PHP_EOL;
echo $paragraph . PHP_EOL;
Expand Down
16 changes: 11 additions & 5 deletions docs/play-chess.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $board = new Board();

for ($i = 0; $i < 50; $i++) {
if ($move = (new RandomMove($board))->move()) {
$board->play($board->turn, $move->pgn);
$board->play($board->turn, $move['pgn']);
}
}

Expand Down Expand Up @@ -46,7 +46,7 @@ print_r($gmMove);
```

```text
stdClass Object
Array
(
[pgn] => c5
[game] => Array
Expand Down Expand Up @@ -86,7 +86,9 @@ use Chess\Variant\Classical\Board;
$board = new Board();
$board->play('w', 'e4');

$limit = (new Limit())->setDepth(3);
$limit = new Limit();
$limit->depth = 3;

$stockfish = (new UciEngine('/usr/games/stockfish'))->setOption('Skill Level', 9);
$analysis = $stockfish->analysis($board, $limit);

Expand All @@ -108,7 +110,9 @@ use Chess\UciEngine\Details\Limit;

$board = FenToBoardFactory::create('4k2r/pp1b1pp1/8/3pPp1p/P2P1P2/1P3N2/1qr3PP/R3QR1K w k -');

$limit = (new Limit())->setDepth(12);
$limit = new Limit();
$limit->depth = 12;

$stockfish = (new UciEngine('/usr/games/stockfish'))->setOption('Skill Level', 20);
$analysis = $stockfish->analysis($board, $limit);

Expand All @@ -134,7 +138,9 @@ $movetext = '1.d4 Nf6 2.c4 c5 3.d5 e6 4.Nc3 exd5 5.cxd5 d6 6.e4 g6 7.Nf3 Bg7';

$board = (new SanPlay($movetext))->validate()->board;

$limit = (new Limit())->setDepth(12);
$limit = new Limit();
$limit->depth = 12;

$stockfish = (new UciEngine('/usr/games/stockfish'))->setOption('Skill Level', 20);
$analysis = $stockfish->analysis($board, $limit);

Expand Down
10 changes: 5 additions & 5 deletions docs/read-moves.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ $movetext = '1.e4 c5 2.Nf3 $1 d6 3.d4 cxd4 4.Nxd4 $48 Nf6 $113';

$sanPlay = (new SanPlay($movetext))->validate();

echo $sanPlay->getSanMovetext()->filtered();
echo $sanPlay->sanMovetext->filtered();
```

```text
Expand All @@ -173,7 +173,7 @@ echo $sanPlay->getSanMovetext()->filtered();
Comments and NAGs can be removed by passing the `false` value to the first and second arguments of the `filtered()` method.

```php
echo $sanPlay->getSanMovetext()->filtered($comments = true, $nags = false);
echo $sanPlay->sanMovetext->filtered($comments = true, $nags = false);
```

```text
Expand Down Expand Up @@ -337,13 +337,13 @@ Array
This is how to obtain the validated movetext.

```php
$movetext = $ravPlay->getRavMovetext()->getMovetext();
$movetext = $ravPlay->ravMovetext->movetext;
```

The `filtered()` method is to remove tabs and spaces.

```php
$movetext = $ravPlay->getRavMovetext()->filtered();
$movetext = $ravPlay->ravMovetext->filtered();

echo $movetext;
```
Expand All @@ -355,7 +355,7 @@ echo $movetext;
Comments and NAGs can be removed by passing the `false` value to the first and second arguments of the `filtered()` method.

```php
$movetext = $ravPlay->getRavMovetext()->filtered($comments = false);
$movetext = $ravPlay->ravMovetext->filtered($comments = false);

echo $movetext;
```
Expand Down

0 comments on commit a337728

Please sign in to comment.