1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:27:35 +00:00

Everywhere: Run clang-format

This commit is contained in:
Idan Horowitz 2022-04-01 20:58:27 +03:00 committed by Linus Groh
parent 0376c127f6
commit 086969277e
1665 changed files with 8479 additions and 8479 deletions

View file

@ -101,7 +101,7 @@ String Move::to_long_algebraic() const
return builder.build();
}
Move Move::from_algebraic(StringView algebraic, const Color turn, const Board& board)
Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& board)
{
String move_string = algebraic;
Move move({ 50, 50 }, { 50, 50 });
@ -143,7 +143,7 @@ Move Move::from_algebraic(StringView algebraic, const Color turn, const Board& b
move_string = move_string.substring(1, move_string.length() - 1);
}
Square::for_each([&](const Square& square) {
Square::for_each([&](Square const& square) {
if (!move_string.is_empty()) {
if (board.get_piece(square).type == move.piece.type && board.is_legal(Move(square, move.to), turn)) {
if (move_string.length() >= 2) {
@ -326,19 +326,19 @@ String Board::to_fen() const
return builder.to_string();
}
Piece Board::get_piece(const Square& square) const
Piece Board::get_piece(Square const& square) const
{
VERIFY(square.in_bounds());
return m_board[square.rank][square.file];
}
Piece Board::set_piece(const Square& square, const Piece& piece)
Piece Board::set_piece(Square const& square, Piece const& piece)
{
VERIFY(square.in_bounds());
return m_board[square.rank][square.file] = piece;
}
bool Board::is_legal_promotion(const Move& move, Color color) const
bool Board::is_legal_promotion(Move const& move, Color color) const
{
auto piece = get_piece(move.from);
@ -367,7 +367,7 @@ bool Board::is_legal_promotion(const Move& move, Color color) const
return true;
}
bool Board::is_legal(const Move& move, Color color) const
bool Board::is_legal(Move const& move, Color color) const
{
if (color == Color::None)
color = turn();
@ -409,7 +409,7 @@ bool Board::is_legal(const Move& move, Color color) const
return true;
}
bool Board::is_legal_no_check(const Move& move, Color color) const
bool Board::is_legal_no_check(Move const& move, Color color) const
{
auto piece = get_piece(move.from);
@ -536,7 +536,7 @@ bool Board::is_legal_no_check(const Move& move, Color color) const
bool Board::in_check(Color color) const
{
Square king_square = { 50, 50 };
Square::for_each([&](const Square& square) {
Square::for_each([&](Square const& square) {
if (get_piece(square) == Piece(color, Type::King)) {
king_square = square;
return IterationDecision::Break;
@ -545,7 +545,7 @@ bool Board::in_check(Color color) const
});
bool check = false;
Square::for_each([&](const Square& square) {
Square::for_each([&](Square const& square) {
if (is_legal_no_check({ square, king_square }, opposing_color(color))) {
check = true;
return IterationDecision::Break;
@ -556,7 +556,7 @@ bool Board::in_check(Color color) const
return check;
}
bool Board::apply_move(const Move& move, Color color)
bool Board::apply_move(Move const& move, Color color)
{
if (color == Color::None)
color = turn();
@ -569,7 +569,7 @@ bool Board::apply_move(const Move& move, Color color)
return apply_illegal_move(move, color);
}
bool Board::apply_illegal_move(const Move& move, Color color)
bool Board::apply_illegal_move(Move const& move, Color color)
{
auto state = Traits<Board>::hash(*this);
auto state_count = 0;
@ -826,7 +826,7 @@ int Board::material_imbalance() const
return imbalance;
}
bool Board::is_promotion_move(const Move& move, Color color) const
bool Board::is_promotion_move(Move const& move, Color color) const
{
if (color == Color::None)
color = turn();
@ -846,7 +846,7 @@ bool Board::is_promotion_move(const Move& move, Color color) const
return true;
}
bool Board::operator==(const Board& other) const
bool Board::operator==(Board const& other) const
{
bool equal_squares = true;
Square::for_each([&](Square sq) {

View file

@ -49,7 +49,7 @@ struct Piece {
}
Color color : 4;
Type type : 4;
bool operator==(const Piece& other) const { return color == other.color && type == other.type; }
bool operator==(Piece const& other) const { return color == other.color && type == other.type; }
};
constexpr Piece EmptyPiece = { Color::None, Type::None };
@ -58,12 +58,12 @@ struct Square {
i8 rank; // zero indexed;
i8 file;
Square(StringView name);
Square(const int& rank, const int& file)
Square(int const& rank, int const& file)
: rank(rank)
, file(file)
{
}
bool operator==(const Square& other) const { return rank == other.rank && file == other.file; }
bool operator==(Square const& other) const { return rank == other.rank && file == other.file; }
template<typename Callback>
static void for_each(Callback callback)
@ -94,15 +94,15 @@ struct Move {
bool is_ambiguous : 1 = false;
Square ambiguous { 50, 50 };
Move(StringView long_algebraic);
Move(const Square& from, const Square& to, const Type& promote_to = Type::None)
Move(Square const& from, Square const& to, Type const& promote_to = Type::None)
: from(from)
, to(to)
, promote_to(promote_to)
{
}
bool operator==(const Move& other) const { return from == other.from && to == other.to && promote_to == other.promote_to; }
bool operator==(Move const& other) const { return from == other.from && to == other.to && promote_to == other.promote_to; }
static Move from_algebraic(StringView algebraic, const Color turn, const Board& board);
static Move from_algebraic(StringView algebraic, const Color turn, Board const& board);
String to_long_algebraic() const;
String to_algebraic() const;
};
@ -111,16 +111,16 @@ class Board {
public:
Board();
Piece get_piece(const Square&) const;
Piece set_piece(const Square&, const Piece&);
Piece get_piece(Square const&) const;
Piece set_piece(Square const&, Piece const&);
bool is_legal(const Move&, Color color = Color::None) const;
bool is_legal(Move const&, Color color = Color::None) const;
bool in_check(Color color) const;
bool is_promotion_move(const Move&, Color color = Color::None) const;
bool is_promotion_move(Move const&, Color color = Color::None) const;
bool apply_move(const Move&, Color color = Color::None);
const Optional<Move>& last_move() const { return m_last_move; }
bool apply_move(Move const&, Color color = Color::None);
Optional<Move> const& last_move() const { return m_last_move; }
String to_fen() const;
@ -151,14 +151,14 @@ public:
int material_imbalance() const;
Color turn() const { return m_turn; }
const Vector<Move>& moves() const { return m_moves; }
Vector<Move> const& moves() const { return m_moves; }
bool operator==(const Board& other) const;
bool operator==(Board const& other) const;
private:
bool is_legal_no_check(const Move&, Color color) const;
bool is_legal_promotion(const Move&, Color color) const;
bool apply_illegal_move(const Move&, Color color);
bool is_legal_no_check(Move const&, Color color) const;
bool is_legal_promotion(Move const&, Color color) const;
bool apply_illegal_move(Move const&, Color color);
Piece m_board[8][8];
Optional<Move> m_last_move;

View file

@ -109,8 +109,8 @@ public:
virtual String to_string() const override;
const String& name() const { return m_name; }
const Optional<String>& value() const { return m_value; }
String const& name() const { return m_name; }
Optional<String> const& value() const { return m_value; }
private:
String m_name;
@ -119,7 +119,7 @@ private:
class PositionCommand : public Command {
public:
explicit PositionCommand(const Optional<String>& fen, const Vector<Chess::Move>& moves)
explicit PositionCommand(Optional<String> const& fen, Vector<Chess::Move> const& moves)
: Command(Command::Type::Position)
, m_fen(fen)
, m_moves(moves)
@ -130,8 +130,8 @@ public:
virtual String to_string() const override;
const Optional<String>& fen() const { return m_fen; }
const Vector<Chess::Move>& moves() const { return m_moves; }
Optional<String> const& fen() const { return m_fen; }
Vector<Chess::Move> const& moves() const { return m_moves; }
private:
Optional<String> m_fen;
@ -194,7 +194,7 @@ public:
virtual String to_string() const override;
Type field_type() const { return m_field_type; }
const String& value() const { return m_value; }
String const& value() const { return m_value; }
private:
Type m_field_type;
@ -227,7 +227,7 @@ public:
class BestMoveCommand : public Command {
public:
explicit BestMoveCommand(const Chess::Move& move)
explicit BestMoveCommand(Chess::Move const& move)
: Command(Command::Type::BestMove)
, m_move(move)
{

View file

@ -21,7 +21,7 @@ Endpoint::Endpoint(NonnullRefPtr<Core::IODevice> in, NonnullRefPtr<Core::IODevic
set_in_notifier();
}
void Endpoint::send_command(const Command& command)
void Endpoint::send_command(Command const& command)
{
dbgln_if(UCI_DEBUG, "{} Sent UCI Command: {}", class_name(), String(command.to_string().characters(), Chomp));
m_out->write(command.to_string());
@ -33,27 +33,27 @@ void Endpoint::event(Core::Event& event)
case Command::Type::UCI:
return handle_uci();
case Command::Type::Debug:
return handle_debug(static_cast<const DebugCommand&>(event));
return handle_debug(static_cast<DebugCommand const&>(event));
case Command::Type::IsReady:
return handle_uci();
case Command::Type::SetOption:
return handle_setoption(static_cast<const SetOptionCommand&>(event));
return handle_setoption(static_cast<SetOptionCommand const&>(event));
case Command::Type::Position:
return handle_position(static_cast<const PositionCommand&>(event));
return handle_position(static_cast<PositionCommand const&>(event));
case Command::Type::Go:
return handle_go(static_cast<const GoCommand&>(event));
return handle_go(static_cast<GoCommand const&>(event));
case Command::Type::Stop:
return handle_stop();
case Command::Type::Id:
return handle_id(static_cast<const IdCommand&>(event));
return handle_id(static_cast<IdCommand const&>(event));
case Command::Type::UCIOk:
return handle_uciok();
case Command::Type::ReadyOk:
return handle_readyok();
case Command::Type::BestMove:
return handle_bestmove(static_cast<const BestMoveCommand&>(event));
return handle_bestmove(static_cast<BestMoveCommand const&>(event));
case Command::Type::Info:
return handle_info(static_cast<const InfoCommand&>(event));
return handle_info(static_cast<InfoCommand const&>(event));
default:
break;
}

View file

@ -19,19 +19,19 @@ public:
virtual ~Endpoint() override = default;
virtual void handle_uci() { }
virtual void handle_debug(const DebugCommand&) { }
virtual void handle_debug(DebugCommand const&) { }
virtual void handle_isready() { }
virtual void handle_setoption(const SetOptionCommand&) { }
virtual void handle_position(const PositionCommand&) { }
virtual void handle_go(const GoCommand&) { }
virtual void handle_setoption(SetOptionCommand const&) { }
virtual void handle_position(PositionCommand const&) { }
virtual void handle_go(GoCommand const&) { }
virtual void handle_stop() { }
virtual void handle_id(const IdCommand&) { }
virtual void handle_id(IdCommand const&) { }
virtual void handle_uciok() { }
virtual void handle_readyok() { }
virtual void handle_bestmove(const BestMoveCommand&) { }
virtual void handle_info(const InfoCommand&) { }
virtual void handle_bestmove(BestMoveCommand const&) { }
virtual void handle_info(InfoCommand const&) { }
void send_command(const Command&);
void send_command(Command const&);
virtual void event(Core::Event&) override;