Closed programarivm closed 6 months ago
https://chessboardjs.com/examples#5002
I meant something like that.
Let me elaborate on this one a bit. It seems as if an algorithm needs to be designed for this purpose. Here is how to make a random move from the start position.
$board = new Board();
$legal = [];
foreach ($board->getPieces($board->getTurn()) as $piece) {
if ($sqs = $piece->sqs()) {
$legal[$piece->getSq()] = $sqs;
}
}
$from = array_rand($legal);
shuffle($legal[$from]);
$to = $legal[$from][0];
echo "{$from}{$to}";
d2d4
Originally posted by @EarlyEdition in https://github.com/chesslablab/php-chess/issues/488#issuecomment-2079966404