Skip to content

Commit 22b4782

Browse files
committed
Format
1 parent c1cf92f commit 22b4782

28 files changed

+175
-159
lines changed

src/chess/bitboard.h

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,47 @@
66
#include <immintrin.h>
77
#endif
88

9-
namespace chess{
9+
namespace chess {
1010

1111
/**
1212
* toggles the bit
1313
* @param number number to manipulate
1414
* @param index index of bit starting at the LST
1515
* @return the manipulated number
1616
*/
17-
inline void toggle(BB& number, Square index) { number ^= (1ULL << index); }
17+
inline void toggle(BB& number, Square index) {
18+
number ^= (1ULL << index);
19+
}
1820

1921
/**
2022
* set the bit
2123
* @param number number to manipulate
2224
* @param index index of bit starting at the LST
2325
* @return the manipulated number
2426
*/
25-
inline void set(BB& number, Square index) { number |= (1ULL << index); }
27+
inline void set(BB& number, Square index) {
28+
number |= (1ULL << index);
29+
}
2630

2731
/**
2832
* unset the bit
2933
* @param number number to manipulate
3034
* @param index index of bit starting at the LST
3135
* @return the manipulated number
3236
*/
33-
inline void unset(BB& number, Square index) { number &= ~(1ULL << index); }
37+
inline void unset(BB& number, Square index) {
38+
number &= ~(1ULL << index);
39+
}
3440

3541
/**
3642
* get the bit
3743
* @param number number to manipulate
3844
* @param index index of bit starting at the LST
3945
* @return the manipulated number
4046
*/
41-
inline bool has(BB number, Square index) { return ((number >> index) & 1ULL) == 1; }
47+
inline bool has(BB number, Square index) {
48+
return ((number >> index) & 1ULL) == 1;
49+
}
4250

4351
/**
4452
* returns the index of the LSB
@@ -92,7 +100,9 @@ inline Square nlsb(BB bb, Square n) {
92100
* @param bb
93101
* @return
94102
*/
95-
inline int popcount(BB bb) { return __builtin_popcountll(bb); }
103+
inline int popcount(BB bb) {
104+
return __builtin_popcountll(bb);
105+
}
96106

97107
/**
98108
* counts the ones inside the bitboard before the given index
@@ -107,7 +117,9 @@ inline int popcount(BB bb, int pos) {
107117
* @param number
108118
* @return
109119
*/
110-
inline BB lsb_reset(BB number) { return number & (number - 1); }
120+
inline BB lsb_reset(BB number) {
121+
return number & (number - 1);
122+
}
111123

112124
/**
113125
* find fully set groups of 4
@@ -175,5 +187,4 @@ inline T mask() {
175187
return (T) (((T) 1 << N) - 1);
176188
}
177189

178-
}
179-
190+
} // namespace chess

src/chess/defs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22
#include <stdint.h>
3-
namespace chess{
3+
namespace chess {
44

55
typedef uint64_t BB;
66
typedef int8_t Square;
@@ -14,4 +14,4 @@ typedef int8_t Piece;
1414
typedef int8_t PieceType;
1515
typedef bool Side;
1616
typedef bool Color;
17-
}
17+
} // namespace chess

src/chess/fenparsing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <sstream>
1111
#include <string>
1212

13-
namespace chess{
13+
namespace chess {
1414

1515
struct FenCharacter {
1616
char character {0};
@@ -250,4 +250,4 @@ inline std::string write_fen(const Position& position, bool write_score = false)
250250

251251
return ss.str();
252252
}
253-
}
253+
} // namespace chess

src/chess/piece.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22
#include "defs.h"
33

4-
namespace chess{
4+
namespace chess {
55

66
enum Colors { WHITE = false, BLACK = true, N_COLORS = 2 };
77

@@ -37,11 +37,16 @@ enum Pieces {
3737
constexpr char
3838
piece_identifier[] {'P', 'N', 'B', 'R', 'Q', 'K', ' ', ' ', 'p', 'n', 'b', 'r', 'q', 'k'};
3939

40-
inline Color color_of(Piece p) { return p & 0x8; }
41-
42-
inline PieceType type_of(Piece p) { return p & 0x7; }
40+
inline Color color_of(Piece p) {
41+
return p & 0x8;
42+
}
4343

44-
inline Piece piece(Color c, PieceType pt) { return c * 8 + pt; }
44+
inline PieceType type_of(Piece p) {
45+
return p & 0x7;
46+
}
4547

48+
inline Piece piece(Color c, PieceType pt) {
49+
return c * 8 + pt;
4650
}
4751

52+
} // namespace chess

src/chess/piecelist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ struct PieceList {
7979
return (lsb(mask_upper) >> 2) + PIECES_PER_BUCKET;
8080
}
8181
};
82-
}
82+
} // namespace chess

src/chess/positionmeta.h

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#pragma once
22

3-
43
#include "bitboard.h"
54
#include "square.h"
65

7-
namespace chess{
6+
namespace chess {
87

98
struct PositionMetaInformation {
109

@@ -13,21 +12,27 @@ struct PositionMetaInformation {
1312
uint8_t m_castling_and_active_player {};
1413
Square m_en_passant_square {N_SQUARES};
1514

16-
Color stm() const { return has(m_castling_and_active_player, 7); }
15+
Color stm() const {
16+
return has(m_castling_and_active_player, 7);
17+
}
1718

18-
void set_stm(Color color) {
19+
void set_stm(Color color) {
1920
if (color) {
2021
m_castling_and_active_player |= (1 << 7);
2122
} else {
2223
m_castling_and_active_player &= ~(1 << 7);
2324
}
2425
}
2526

26-
Square ep_square() const { return m_en_passant_square; }
27+
Square ep_square() const {
28+
return m_en_passant_square;
29+
}
2730

28-
void set_ep_square(Square ep_square) { m_en_passant_square = ep_square; }
31+
void set_ep_square(Square ep_square) {
32+
m_en_passant_square = ep_square;
33+
}
2934

30-
bool can_castle(Color player, Side side) const {
35+
bool can_castle(Color player, Side side) const {
3136
return m_castling_and_active_player & (1 << (player * 2 + side));
3237
}
3338

@@ -38,12 +43,19 @@ struct PositionMetaInformation {
3843
m_castling_and_active_player &= ~(1 << (player * 2 + side));
3944
}
4045

41-
uint8_t fifty_mr() const { return m_fifty_move_rule; }
42-
void set_fifty_mr(uint8_t p_fifty_move_rule) { m_fifty_move_rule = p_fifty_move_rule; }
46+
uint8_t fifty_mr() const {
47+
return m_fifty_move_rule;
48+
}
49+
void set_fifty_mr(uint8_t p_fifty_move_rule) {
50+
m_fifty_move_rule = p_fifty_move_rule;
51+
}
4352

44-
uint8_t move_count() const { return m_move_count; }
45-
void set_move_count(uint8_t p_move_count) { m_move_count = p_move_count; }
53+
uint8_t move_count() const {
54+
return m_move_count;
55+
}
56+
void set_move_count(uint8_t p_move_count) {
57+
m_move_count = p_move_count;
58+
}
4659
};
4760

48-
}
49-
61+
} // namespace chess

src/chess/result.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
namespace chess{
3+
namespace chess {
44

55
enum GameResult { WIN = 1, DRAW = 0, LOSS = -1 };
66

@@ -9,4 +9,4 @@ struct Result {
99
int8_t wdl;
1010
};
1111

12-
}
12+
} // namespace chess

src/chess/square.h

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
namespace chess{
3+
namespace chess {
44

55
// clang-format off
66
enum Squares {
@@ -23,7 +23,9 @@ constexpr char const* square_identifier[] {
2323
};
2424

2525
// clang-format on
26-
inline Square square_index(Rank rank, File file) { return 8 * rank + file; }
26+
inline Square square_index(Rank rank, File file) {
27+
return 8 * rank + file;
28+
}
2729

2830
inline Square square_index(std::string& str) {
2931

@@ -33,20 +35,27 @@ inline Square square_index(std::string& str) {
3335
return square_index(r, f);
3436
}
3537

36-
inline Rank rank_index(Square square_index) { return square_index >> 3; }
38+
inline Rank rank_index(Square square_index) {
39+
return square_index >> 3;
40+
}
3741

38-
inline File file_index(Square square_index) { return square_index & 7; }
42+
inline File file_index(Square square_index) {
43+
return square_index & 7;
44+
}
3945

40-
inline Square mirror_ver(Square square) { return square ^ 56; }
46+
inline Square mirror_ver(Square square) {
47+
return square ^ 56;
48+
}
4149

42-
inline Square mirror_hor(Square square) { return square ^ 7; }
50+
inline Square mirror_hor(Square square) {
51+
return square ^ 7;
52+
}
4353

44-
inline Color square_color(Square square) {
54+
inline Color square_color(Square square) {
4555
constexpr BB white_squares {0x55AA55AA55AA55AAULL};
4656
if (has(white_squares, square))
4757
return WHITE;
4858
return BLACK;
4959
}
5060

51-
}
52-
61+
} // namespace chess

src/data/array.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,3 @@ struct GPUArray : Array<Type> {
117117
};
118118

119119
} // namespace data
120-

src/data/device.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ constexpr inline bool is_gpu(Device dev) {
2222
return dev & GPU;
2323
}
2424
} // namespace data
25-

0 commit comments

Comments
 (0)