Skip to content

Instantly share code, notes, and snippets.

View programarivm's full-sized avatar

Jordi Bassagana programarivm

View GitHub Profile
@programarivm
programarivm / Square.php
Created July 29, 2022 16:17
Chess\PGN\AN\Square
<?php
namespace Chess\PGN\AN;
use Chess\Exception\UnknownNotationException;
use Chess\PGN\AbstractNotation;
use Chess\PGN\ValidationInterface;
/**
* Square.
@programarivm
programarivm / TwoBishopsRandomizer.php
Created July 29, 2022 15:58
Chess\Randomizer\Checkmate\TwoBishopsRandomizer
<?php
namespace Chess\Randomizer\Checkmate;
use Chess\PGN\AN\Square;
use Chess\Randomizer\Randomizer;
class TwoBishopsRandomizer extends Randomizer
{
public function __construct(string $turn)
@programarivm
programarivm / RandomizerTest.php
Created July 29, 2022 15:32
Chess\Tests\Unit\RandomizerTest
<?php
namespace Chess\Tests\Unit;
use Chess\Randomizer;
use Chess\FEN\BoardToStr;
use Chess\PGN\AN\Color;
use Chess\Tests\AbstractUnitTestCase;
class RandomizerTest extends AbstractUnitTestCase
@programarivm
programarivm / Randomizer.php
Created July 29, 2022 15:28
Chess\Randomizer
<?php
namespace Chess;
use Chess\PGN\AN\Color;
use Chess\Piece\K;
use Chess\Piece\RType;
/**
* Randomizer.
@programarivm
programarivm / hi-stockfish.php
Created July 25, 2022 12:37
Tries to respond with a grandmaster move first, if found in the file.
<?php
$game = new Game(Game::MODE_STOCKFISH, __DIR__.'/../data/players.json');
$game->play('w', 'e4');
$ai = $game->ai(['Skill Level' => 9], ['depth' => 3]);
print_r($ai);
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Chess\Game;
$game = new Game(Game::MODE_STOCKFISH);
$game->play('w', 'e4');
echo $game->getBoard()->toAsciiString() . PHP_EOL;
@programarivm
programarivm / stockfish-interface.txt
Created July 18, 2022 12:52
Description of the universal chess interface (UCI)
COPIED FROM https://build.opensuse.org/package/view_file/games/stockfish/stockfish-interface.txt?expand=1
Description of the universal chess interface (UCI) April 2006
=================================================================
* The specification is independent of the operating system. For Windows,
the engine is a normal exe file, either a console or "real" windows application.
* all communication is done via standard input and output with text commands,
@programarivm
programarivm / AbstractPiece.php
Created July 4, 2022 16:43
Chess\Piece\AbstractPiece
<?php
namespace Chess\Piece;
use Chess\Board;
use Chess\Exception\UnknownNotationException;
use Chess\PGN\AN\Color;
use Chess\PGN\AN\Piece;
use Chess\PGN\AN\Square;
@programarivm
programarivm / Board.php
Last active November 3, 2022 20:14
Chess\Board
<?php
namespace Chess;
use Chess\Array\AsciiArray;
use Chess\Eval\DefenseEval;
use Chess\Eval\PressureEval;
use Chess\Eval\SpaceEval;
use Chess\Eval\SqEval;
use Chess\Exception\BoardException;
@programarivm
programarivm / PieceObserverBoardTrait.php
Last active July 5, 2022 13:10
Chess\Piece\PieceObserverBoardTrait
<?php
namespace Chess\Piece;
use Chess\Board;
trait PieceObserverBoardTrait
{
public function setBoard(Board $board): void
{