Skip to content

Commit

Permalink
Deleted the Capablanca variants
Browse files Browse the repository at this point in the history
  • Loading branch information
programarivm committed May 30, 2024
1 parent af9b76a commit 15d9b80
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 97 deletions.
7 changes: 0 additions & 7 deletions src/Command/RestartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace ChessServer\Command;

use Chess\Variant\CapablancaFischer\FEN\StrToBoard as CapablancaFischerFenStrToBoard;
use Chess\Variant\Chess960\FEN\StrToBoard as Chess960FenStrToBoard;
use Chess\Variant\Classical\PGN\AN\Color;
use ChessServer\Game\Game;
Expand Down Expand Up @@ -36,12 +35,6 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id)
$startPos = str_split($decoded->startPos);
$board = (new Chess960FenStrToBoard($decoded->fen, $startPos))->create();
$game = (new Game($decoded->variant, Game::MODE_PLAY))->setBoard($board);
} elseif ($decoded->variant === Game::VARIANT_CAPABLANCA) {
$game = new Game($decoded->variant, Game::MODE_PLAY);
} elseif ($decoded->variant === Game::VARIANT_CAPABLANCA_FISCHER) {
$startPos = str_split($decoded->startPos);
$board = (new CapablancaFischerFenStrToBoard($decoded->fen, $startPos))->create();
$game = (new Game($decoded->variant, Game::MODE_PLAY))->setBoard($board);
} else {
$game = new Game($decoded->variant, Game::MODE_PLAY);
}
Expand Down
63 changes: 0 additions & 63 deletions src/Command/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

use Chess\FenToBoardFactory;
use Chess\Play\SanPlay;
use Chess\Variant\Capablanca\Board as CapablancaBoard;
use Chess\Variant\Capablanca\FEN\StrToBoard as CapablancaFenStrToBoard;
use Chess\Variant\CapablancaFischer\Board as CapablancaFischerBoard;
use Chess\Variant\CapablancaFischer\StartPosition as CapablancaFischerStartPosition;
use Chess\Variant\CapablancaFischer\FEN\StrToBoard as CapablancaFischerFenStrToBoard;
use Chess\Variant\Chess960\Board as Chess960Board;
use Chess\Variant\Chess960\StartPosition as Chess960StartPosition;
use Chess\Variant\Chess960\FEN\StrToBoard as Chess960FenStrToBoard;
Expand All @@ -33,8 +28,6 @@ public function __construct()
// mandatory param
'variant' => [
Game::VARIANT_960,
Game::VARIANT_CAPABLANCA,
Game::VARIANT_CAPABLANCA_FISCHER,
Game::VARIANT_CLASSICAL,
],
// mandatory param
Expand Down Expand Up @@ -98,21 +91,6 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id)
$startPos = (new Chess960StartPosition())->create();
$board = new Chess960Board($startPos);
}
} elseif ($argv[1] === Game::VARIANT_CAPABLANCA) {
if (isset($settings->fen)) {
$board = (new CapablancaFenStrToBoard($settings->fen))->create();
} else {
$board = new CapablancaBoard();
}
} elseif ($argv[1] === Game::VARIANT_CAPABLANCA_FISCHER) {
if (isset($settings->fen) && isset($settings->startPos)) {
$startPos = str_split($settings->startPos);
$board = (new CapablancaFischerFenStrToBoard($settings->fen, $startPos))
->create();
} else {
$startPos = (new CapablancaFischerStartPosition())->create();
$board = new CapablancaFischerBoard($startPos);
}
} else {
if (isset($settings->fen)) {
$board = (new ClassicalFenStrToBoard($settings->fen))->create();
Expand All @@ -136,10 +114,6 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id)
? ['startPos' => implode('', $startPos)]
: []
),
...($argv[1] === Game::VARIANT_CAPABLANCA_FISCHER
? ['startPos' => implode('', $startPos)]
: []
),
],
]);
} catch (\Throwable $e) {
Expand All @@ -161,19 +135,6 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id)
$board = FenToBoardFactory::create($settings->fen, $board);
}
$sanPlay = new SanPlay($settings->movetext, $board);
} elseif ($argv[1] === Game::VARIANT_CAPABLANCA) {
$board = new CapablancaBoard();
if (isset($settings->fen)) {
$board = FenToBoardFactory::create($settings->fen, $board);
}
$sanPlay = new SanPlay($settings->movetext, $board);
} elseif ($argv[1] === Game::VARIANT_CAPABLANCA_FISCHER) {
$startPos = str_split($settings->startPos);
$board = new CapablancaFischerBoard($startPos);
if (isset($settings->fen)) {
$board = FenToBoardFactory::create($settings->fen, $board);
}
$sanPlay = new SanPlay($settings->movetext, $board);
} else {
$board = new ClassicalBoard();
if (isset($settings->fen)) {
Expand All @@ -198,10 +159,6 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id)
? ['startPos' => $settings->startPos]
: []
),
...($argv[1] === Game::VARIANT_CAPABLANCA_FISCHER
? ['startPos' => $settings->startPos]
: []
),
],
]);
} catch (\Throwable $e) {
Expand All @@ -221,13 +178,6 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id)
$startPos = str_split($settings->startPos);
$board = (new Chess960FenStrToBoard($settings->fen, $startPos))
->create();
} elseif ($argv[1] === Game::VARIANT_CAPABLANCA) {
$board = (new CapablancaFenStrToBoard($settings->fen))
->create();
} elseif ($argv[1] === Game::VARIANT_CAPABLANCA_FISCHER) {
$startPos = str_split($settings->startPos);
$board = (new CapablancaFischerBoard($settings->fen, $startPos))
->create();
} else {
$board = (new ClassicalFenStrToBoard($settings->fen))
->create();
Expand All @@ -245,11 +195,6 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id)
if ($argv[1] === Game::VARIANT_960) {
$startPos = (new Chess960StartPosition())->create();
$board = new Chess960Board($startPos);
} elseif ($argv[1] === Game::VARIANT_CAPABLANCA) {
$board = new CapablancaBoard();
} elseif ($argv[1] === Game::VARIANT_CAPABLANCA_FISCHER) {
$startPos = (new CapablancaFischerStartPosition())->create();
$board = new CapablancaFischerBoard($startPos);
} else {
$board = new ClassicalBoard();
}
Expand All @@ -269,10 +214,6 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id)
? ['startPos' => implode('', $game->getBoard()->getStartPos())]
: []
),
...($argv[1] === Game::VARIANT_CAPABLANCA_FISCHER
? ['startPos' => implode('', $game->getBoard()->getStartPos())]
: []
),
...(isset($settings->fen)
? ['fen' => $settings->fen]
: []
Expand Down Expand Up @@ -300,10 +241,6 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id)
? ['startPos' => implode('', $game->getBoard()->getStartPos())]
: []
),
...($argv[1] === Game::VARIANT_CAPABLANCA_FISCHER
? ['startPos' => implode('', $game->getBoard()->getStartPos())]
: []
),
],
]);
} elseif (StockfishMode::NAME === $argv[2]) {
Expand Down
19 changes: 2 additions & 17 deletions src/Game/AbstractMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Chess\Heuristics\FenHeuristics;
use Chess\Movetext\NagMovetext;
use Chess\Tutor\FenEvaluation;
use Chess\Variant\Capablanca\Board as CapablancaBoard;
use Chess\Variant\Chess960\Board as Chess960Board;
use Chess\Variant\Classical\Board as ClassicalBoard;
use ChessServer\Game\Game;
Expand Down Expand Up @@ -65,14 +64,7 @@ public function res($argv, $cmd)
{
switch (get_class($cmd)) {
case HeuristicsCommand::class:
if (
$argv[2] === Game::VARIANT_CAPABLANCA ||
$argv[2] === Game::VARIANT_CAPABLANCA_FISCHER
) {
$board = FenToBoardFactory::create($argv[1], new CapablancaBoard());
} else {
$board = FenToBoardFactory::create($argv[1], new ClassicalBoard());
}
$board = FenToBoardFactory::create($argv[1], new ClassicalBoard());
return [
$cmd->name => [
'names' => (new StandardFunction())->names(),
Expand Down Expand Up @@ -112,14 +104,7 @@ public function res($argv, $cmd)
];

case TutorFenCommand::class:
if (
$argv[2] === Game::VARIANT_CAPABLANCA ||
$argv[2] === Game::VARIANT_CAPABLANCA_FISCHER
) {
$board = FenToBoardFactory::create($argv[1], new CapablancaBoard());
} else {
$board = FenToBoardFactory::create($argv[1], new ClassicalBoard());
}
$board = FenToBoardFactory::create($argv[1], new ClassicalBoard());
$paragraph = (new FenEvaluation($board))->getParagraph();
return [
$cmd->name => implode(' ', $paragraph),
Expand Down
10 changes: 0 additions & 10 deletions src/Game/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use Chess\Computer\GrandmasterMove;
use Chess\UciEngine\UciEngine;
use Chess\UciEngine\Details\Limit;
use Chess\Variant\Capablanca\Board as CapablancaBoard;
use Chess\Variant\CapablancaFischer\Board as CapablancaFischerBoard;
use Chess\Variant\CapablancaFischer\StartPosition as CapablancaFischerStartPosition;
use Chess\Variant\Chess960\Board as Chess960Board;
use Chess\Variant\Chess960\StartPosition as Chess960StartPosition;
use Chess\Variant\Classical\Board as ClassicalBoard;
Expand All @@ -21,8 +18,6 @@
class Game
{
const VARIANT_960 = Chess960Board::VARIANT;
const VARIANT_CAPABLANCA = CapablancaBoard::VARIANT;
const VARIANT_CAPABLANCA_FISCHER = CapablancaFischerBoard::VARIANT;
const VARIANT_CLASSICAL = ClassicalBoard::VARIANT;

const MODE_FEN = 'fen';
Expand Down Expand Up @@ -77,11 +72,6 @@ public function __construct(
if ($this->variant === self::VARIANT_960) {
$startPos = (new Chess960StartPosition())->create();
$this->board = new Chess960Board($startPos);
} elseif ($this->variant === self::VARIANT_CAPABLANCA) {
$this->board = new CapablancaBoard();
} elseif ($this->variant === self::VARIANT_CAPABLANCA_FISCHER) {
$startPos = (new CapablancaFischerStartPosition())->create();
$this->board = new CapablancaFischerBoard($startPos);
} elseif ($this->variant === self::VARIANT_CLASSICAL) {
$this->board = new ClassicalBoard();
}
Expand Down

0 comments on commit 15d9b80

Please sign in to comment.