summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibChess
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibChess')
-rw-r--r--Userland/Libraries/LibChess/Chess.cpp24
-rw-r--r--Userland/Libraries/LibChess/UCICommand.cpp74
-rw-r--r--Userland/Libraries/LibChess/UCIEndpoint.cpp2
3 files changed, 50 insertions, 50 deletions
diff --git a/Userland/Libraries/LibChess/Chess.cpp b/Userland/Libraries/LibChess/Chess.cpp
index fae0c1e513..3bce22f647 100644
--- a/Userland/Libraries/LibChess/Chess.cpp
+++ b/Userland/Libraries/LibChess/Chess.cpp
@@ -79,7 +79,7 @@ Color opposing_color(Color color)
Square::Square(const StringView& name)
{
- ASSERT(name.length() == 2);
+ VERIFY(name.length() == 2);
char filec = name[0];
char rankc = name[1];
@@ -88,13 +88,13 @@ Square::Square(const StringView& name)
} else if (filec >= 'A' && filec <= 'H') {
file = filec - 'A';
} else {
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
if (rankc >= '1' && rankc <= '8') {
rank = rankc - '1';
} else {
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
}
@@ -312,7 +312,7 @@ String Board::to_fen() const
}
// 2. Active color
- ASSERT(m_turn != Color::None);
+ VERIFY(m_turn != Color::None);
builder.append(m_turn == Color::White ? " w " : " b ");
// 3. Castling availability
@@ -349,15 +349,15 @@ String Board::to_fen() const
Piece Board::get_piece(const Square& square) const
{
- ASSERT(square.rank < 8);
- ASSERT(square.file < 8);
+ VERIFY(square.rank < 8);
+ VERIFY(square.file < 8);
return m_board[square.rank][square.file];
}
Piece Board::set_piece(const Square& square, const Piece& piece)
{
- ASSERT(square.rank < 8);
- ASSERT(square.file < 8);
+ VERIFY(square.rank < 8);
+ VERIFY(square.file < 8);
return m_board[square.rank][square.file] = piece;
}
@@ -913,7 +913,7 @@ String Board::result_to_string(Result result, Color turn)
{
switch (result) {
case Result::CheckMate:
- ASSERT(turn != Chess::Color::None);
+ VERIFY(turn != Chess::Color::None);
return turn == Chess::Color::White ? "Black wins by Checkmate" : "White wins by Checkmate";
case Result::WhiteResign:
return "Black wins by Resignation";
@@ -934,7 +934,7 @@ String Board::result_to_string(Result result, Color turn)
case Chess::Board::Result::NotFinished:
return "Game not finished";
default:
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
}
@@ -942,7 +942,7 @@ String Board::result_to_points(Result result, Color turn)
{
switch (result) {
case Result::CheckMate:
- ASSERT(turn != Chess::Color::None);
+ VERIFY(turn != Chess::Color::None);
return turn == Chess::Color::White ? "0-1" : "1-0";
case Result::WhiteResign:
return "0-1";
@@ -963,7 +963,7 @@ String Board::result_to_points(Result result, Color turn)
case Chess::Board::Result::NotFinished:
return "*";
default:
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
}
diff --git a/Userland/Libraries/LibChess/UCICommand.cpp b/Userland/Libraries/LibChess/UCICommand.cpp
index af4294c8df..f84f71a639 100644
--- a/Userland/Libraries/LibChess/UCICommand.cpp
+++ b/Userland/Libraries/LibChess/UCICommand.cpp
@@ -32,8 +32,8 @@ namespace Chess::UCI {
UCICommand UCICommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens[0] == "uci");
- ASSERT(tokens.size() == 1);
+ VERIFY(tokens[0] == "uci");
+ VERIFY(tokens.size() == 1);
return UCICommand();
}
@@ -45,14 +45,14 @@ String UCICommand::to_string() const
DebugCommand DebugCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens[0] == "debug");
- ASSERT(tokens.size() == 2);
+ VERIFY(tokens[0] == "debug");
+ VERIFY(tokens.size() == 2);
if (tokens[1] == "on")
return DebugCommand(Flag::On);
if (tokens[1] == "off")
return DebugCommand(Flag::On);
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
String DebugCommand::to_string() const
@@ -67,8 +67,8 @@ String DebugCommand::to_string() const
IsReadyCommand IsReadyCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens[0] == "isready");
- ASSERT(tokens.size() == 1);
+ VERIFY(tokens[0] == "isready");
+ VERIFY(tokens.size() == 1);
return IsReadyCommand();
}
@@ -80,9 +80,9 @@ String IsReadyCommand::to_string() const
SetOptionCommand SetOptionCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens[0] == "setoption");
- ASSERT(tokens[1] == "name");
- ASSERT(tokens.size() > 2);
+ VERIFY(tokens[0] == "setoption");
+ VERIFY(tokens[1] == "name");
+ VERIFY(tokens.size() > 2);
StringBuilder name;
StringBuilder value;
@@ -110,7 +110,7 @@ SetOptionCommand SetOptionCommand::from_string(const StringView& command)
}
}
- ASSERT(!name.is_empty());
+ VERIFY(!name.is_empty());
return SetOptionCommand(name.to_string().trim_whitespace(), value.to_string().trim_whitespace());
}
@@ -131,9 +131,9 @@ String SetOptionCommand::to_string() const
PositionCommand PositionCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens.size() >= 3);
- ASSERT(tokens[0] == "position");
- ASSERT(tokens[2] == "moves");
+ VERIFY(tokens.size() >= 3);
+ VERIFY(tokens[0] == "position");
+ VERIFY(tokens[2] == "moves");
Optional<String> fen;
if (tokens[1] != "startpos")
@@ -167,40 +167,40 @@ String PositionCommand::to_string() const
GoCommand GoCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens[0] == "go");
+ VERIFY(tokens[0] == "go");
GoCommand go_command;
for (size_t i = 1; i < tokens.size(); ++i) {
if (tokens[i] == "searchmoves") {
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
} else if (tokens[i] == "ponder") {
go_command.ponder = true;
} else if (tokens[i] == "wtime") {
- ASSERT(i++ < tokens.size());
+ VERIFY(i++ < tokens.size());
go_command.wtime = tokens[i].to_int().value();
} else if (tokens[i] == "btime") {
- ASSERT(i++ < tokens.size());
+ VERIFY(i++ < tokens.size());
go_command.btime = tokens[i].to_int().value();
} else if (tokens[i] == "winc") {
- ASSERT(i++ < tokens.size());
+ VERIFY(i++ < tokens.size());
go_command.winc = tokens[i].to_int().value();
} else if (tokens[i] == "binc") {
- ASSERT(i++ < tokens.size());
+ VERIFY(i++ < tokens.size());
go_command.binc = tokens[i].to_int().value();
} else if (tokens[i] == "movestogo") {
- ASSERT(i++ < tokens.size());
+ VERIFY(i++ < tokens.size());
go_command.movestogo = tokens[i].to_int().value();
} else if (tokens[i] == "depth") {
- ASSERT(i++ < tokens.size());
+ VERIFY(i++ < tokens.size());
go_command.depth = tokens[i].to_int().value();
} else if (tokens[i] == "nodes") {
- ASSERT(i++ < tokens.size());
+ VERIFY(i++ < tokens.size());
go_command.nodes = tokens[i].to_int().value();
} else if (tokens[i] == "mate") {
- ASSERT(i++ < tokens.size());
+ VERIFY(i++ < tokens.size());
go_command.mate = tokens[i].to_int().value();
} else if (tokens[i] == "movetime") {
- ASSERT(i++ < tokens.size());
+ VERIFY(i++ < tokens.size());
go_command.movetime = tokens[i].to_int().value();
} else if (tokens[i] == "infinite") {
go_command.infinite = true;
@@ -253,8 +253,8 @@ String GoCommand::to_string() const
StopCommand StopCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens[0] == "stop");
- ASSERT(tokens.size() == 1);
+ VERIFY(tokens[0] == "stop");
+ VERIFY(tokens.size() == 1);
return StopCommand();
}
@@ -266,7 +266,7 @@ String StopCommand::to_string() const
IdCommand IdCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens[0] == "id");
+ VERIFY(tokens[0] == "id");
StringBuilder value;
for (size_t i = 2; i < tokens.size(); ++i) {
if (i != 2)
@@ -280,7 +280,7 @@ IdCommand IdCommand::from_string(const StringView& command)
} else if (tokens[1] == "author") {
return IdCommand(Type::Author, value.build());
}
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
String IdCommand::to_string() const
@@ -300,8 +300,8 @@ String IdCommand::to_string() const
UCIOkCommand UCIOkCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens[0] == "uciok");
- ASSERT(tokens.size() == 1);
+ VERIFY(tokens[0] == "uciok");
+ VERIFY(tokens.size() == 1);
return UCIOkCommand();
}
@@ -313,8 +313,8 @@ String UCIOkCommand::to_string() const
ReadyOkCommand ReadyOkCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens[0] == "readyok");
- ASSERT(tokens.size() == 1);
+ VERIFY(tokens[0] == "readyok");
+ VERIFY(tokens.size() == 1);
return ReadyOkCommand();
}
@@ -326,8 +326,8 @@ String ReadyOkCommand::to_string() const
BestMoveCommand BestMoveCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
- ASSERT(tokens[0] == "bestmove");
- ASSERT(tokens.size() == 2);
+ VERIFY(tokens[0] == "bestmove");
+ VERIFY(tokens.size() == 2);
return BestMoveCommand(Move(tokens[1]));
}
@@ -343,13 +343,13 @@ String BestMoveCommand::to_string() const
InfoCommand InfoCommand::from_string([[maybe_unused]] const StringView& command)
{
// FIXME: Implement this.
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
String InfoCommand::to_string() const
{
// FIXME: Implement this.
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
return "info";
}
diff --git a/Userland/Libraries/LibChess/UCIEndpoint.cpp b/Userland/Libraries/LibChess/UCIEndpoint.cpp
index 5e9066aacc..4c094b80fe 100644
--- a/Userland/Libraries/LibChess/UCIEndpoint.cpp
+++ b/Userland/Libraries/LibChess/UCIEndpoint.cpp
@@ -125,7 +125,7 @@ NonnullOwnPtr<Command> Endpoint::read_command()
}
dbgln("command line: {}", line);
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
};