Skip to content

Commit

Permalink
readme: thank people
Browse files Browse the repository at this point in the history
Bench: 3873201
  • Loading branch information
Disservin committed Jul 19, 2023
1 parent c25d92b commit eb0f59c
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 59 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,34 @@ If you want maximum performance you should compile Smallbrain yourself.
.\smallbrain.exe -generate threads=30 depth=9 tb=H:/Chess/345
.\smallbrain.exe -generate threads=30 nodes=5000 tb=H:/Chess/345
```

## Acknowledgements

I'd also like to thank the following people for their help and support:

- A big thanks to Luecx for his amazing CudAd trainer and his help with the NNUE implementation.
- Andrew Grant for the OpenBench platform https://github.com/AndyGrant/OpenBench
- Morgan Houppin, author of Stash https://github.com/mhouppin/stash-bot for his debug sessions.
- Various other people from Stockfish discord for their help.
- [Chess.com](https://www.chess.com/computer-chess-championship) for their Smallbrain inclusion in the Computer Chess Championship (CCC)
- [TCEC](https://tcec-chess.com/) for their Smallbrain invitation.

### Engines

The following engines have tought me a lot about chess programming and I'd like to thank their authors for their work:

- [Stockfish](https://github.com/official-stockfish/Stockfish)
- [Koivisto](https://github.com/Luecx/Koivisto)
- [Weiss](https://github.com/TerjeKir/weiss)

### Tools

Included:
The following parts of the code are from other projects, I'd like to thank their authors for their work and their respective licenses remain the same:

- [Fathom](https://github.com/jdart1/Fathom) [MIT](https://github.com/jdart1/Fathom/blob/master/LICENSE)
- [Incbin](https://github.com/graphitemaster/incbin) [UNLICENSE](https://github.com/graphitemaster/incbin/blob/main/UNLICENSE)

External:

- [OpenBench](https://github.com/AndyGrant/OpenBench) [GPL-3.0](https://github.com/AndyGrant/OpenBench/blob/master/LICENSE)
119 changes: 60 additions & 59 deletions src/see.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,80 @@

namespace see {

[[nodiscard]] inline Bitboard attackersForSide(const Board &board, Color attacker_color, Square sq,
Bitboard occupied_bb) {
const Bitboard attacking_bishops = board.pieces(BISHOP, attacker_color);
const Bitboard attacking_rooks = board.pieces(ROOK, attacker_color);
const Bitboard attacking_queens = board.pieces(QUEEN, attacker_color);
const Bitboard attacking_knights = board.pieces(KNIGHT, attacker_color);
const Bitboard attacking_king = board.pieces(KING, attacker_color);
const Bitboard attacking_pawns = board.pieces(PAWN, attacker_color);
[[nodiscard]] inline Bitboard attackersForSide(const Board &board, Color attacker_color, Square sq,
Bitboard occupied_bb) {
const Bitboard attacking_bishops = board.pieces(BISHOP, attacker_color);
const Bitboard attacking_rooks = board.pieces(ROOK, attacker_color);
const Bitboard attacking_queens = board.pieces(QUEEN, attacker_color);
const Bitboard attacking_knights = board.pieces(KNIGHT, attacker_color);
const Bitboard attacking_king = board.pieces(KING, attacker_color);
const Bitboard attacking_pawns = board.pieces(PAWN, attacker_color);

const Bitboard inter_cardinal_rays = attacks::bishop(sq, occupied_bb);
const Bitboard cardinal_rays_rays = attacks::rook(sq, occupied_bb);
const Bitboard inter_cardinal_rays = attacks::bishop(sq, occupied_bb);
const Bitboard cardinal_rays_rays = attacks::rook(sq, occupied_bb);

Bitboard attackers = inter_cardinal_rays & (attacking_bishops | attacking_queens);
attackers |= cardinal_rays_rays & (attacking_rooks | attacking_queens);
attackers |= attacks::knight(sq) & attacking_knights;
attackers |= attacks::king(sq) & attacking_king;
attackers |= attacks::pawn(sq, ~attacker_color) & attacking_pawns;
return attackers;
}
Bitboard attackers = inter_cardinal_rays & (attacking_bishops | attacking_queens);
attackers |= cardinal_rays_rays & (attacking_rooks | attacking_queens);
attackers |= attacks::knight(sq) & attacking_knights;
attackers |= attacks::king(sq) & attacking_king;
attackers |= attacks::pawn(sq, ~attacker_color) & attacking_pawns;
return attackers;
}

[[nodiscard]] inline Bitboard allAttackers(const Board &board, Square sq, Bitboard occupied_bb) {
return attackersForSide(board, WHITE, sq, occupied_bb) |
attackersForSide(board, BLACK, sq, occupied_bb);
}
[[nodiscard]] inline Bitboard allAttackers(const Board &board, Square sq, Bitboard occupied_bb) {
return attackersForSide(board, WHITE, sq, occupied_bb) |
attackersForSide(board, BLACK, sq, occupied_bb);
}

/********************
* Static Exchange Evaluation, logical based on Weiss (https://github.com/TerjeKir/weiss)
*licensed under GPL-3.0
* Static Exchange Evaluation, logical based on Weiss
* (https://github.com/TerjeKir/weiss/blob/6772250059e82310c913a0d77a4c94b05d1e18e6/src/board.c#L310)
* licensed under GPL-3.0
*******************/
[[nodiscard]] inline bool see(const Board &board, Move move, int threshold) {
Square from_sq = from(move);
Square to_sq = to(move);
auto attacker = board.at<PieceType>(from_sq);
auto victim = board.at<PieceType>(to_sq);
int swap = PIECE_VALUES_CLASSICAL[victim] - threshold;
if (swap < 0) return false;
swap -= PIECE_VALUES_CLASSICAL[attacker];
if (swap >= 0) return true;
Bitboard occ = (board.all() ^ (1ULL << from_sq)) | (1ULL << to_sq);
Bitboard attackers = allAttackers(board, to_sq, occ) & occ;
[[nodiscard]] inline bool see(const Board &board, Move move, int threshold) {
Square from_sq = from(move);
Square to_sq = to(move);
auto attacker = board.at<PieceType>(from_sq);
auto victim = board.at<PieceType>(to_sq);
int swap = PIECE_VALUES_CLASSICAL[victim] - threshold;
if (swap < 0) return false;
swap -= PIECE_VALUES_CLASSICAL[attacker];
if (swap >= 0) return true;
Bitboard occ = (board.all() ^ (1ULL << from_sq)) | (1ULL << to_sq);
Bitboard attackers = allAttackers(board, to_sq, occ) & occ;

Bitboard queens = board.pieces(WHITEQUEEN) | board.pieces(BLACKQUEEN);
Bitboard queens = board.pieces(WHITEQUEEN) | board.pieces(BLACKQUEEN);

Bitboard bishops = board.pieces(WHITEBISHOP) | board.pieces(BLACKBISHOP) | queens;
Bitboard rooks = board.pieces(WHITEROOK) | board.pieces(BLACKROOK) | queens;
Bitboard bishops = board.pieces(WHITEBISHOP) | board.pieces(BLACKBISHOP) | queens;
Bitboard rooks = board.pieces(WHITEROOK) | board.pieces(BLACKROOK) | queens;

Color sT = ~board.colorOf(from_sq);
Color sT = ~board.colorOf(from_sq);

while (true) {
attackers &= occ;
Bitboard my_attackers = attackers & board.us(sT);
if (!my_attackers) break;
while (true) {
attackers &= occ;
Bitboard my_attackers = attackers & board.us(sT);
if (!my_attackers) break;

int pt;
for (pt = 0; pt <= 5; pt++) {
if (my_attackers &
(board.pieces(static_cast<Piece>(pt)) | board.pieces(static_cast<Piece>(pt + 6))))
break;
}
sT = ~sT;
if ((swap = -swap - 1 - PIECE_VALUES_TUNED[0][pt]) >= 0) {
if (pt == KING && (attackers & board.us(sT))) sT = ~sT;
int pt;
for (pt = 0; pt <= 5; pt++) {
if (my_attackers &
(board.pieces(static_cast<Piece>(pt)) | board.pieces(static_cast<Piece>(pt + 6))))
break;
}
}
sT = ~sT;
if ((swap = -swap - 1 - PIECE_VALUES_TUNED[0][pt]) >= 0) {
if (pt == KING && (attackers & board.us(sT))) sT = ~sT;
break;
}

occ ^= (1ULL << (builtin::lsb(my_attackers & (board.pieces(static_cast<Piece>(pt)) |
board.pieces(static_cast<Piece>(pt + 6))))));
occ ^= (1ULL << (builtin::lsb(my_attackers & (board.pieces(static_cast<Piece>(pt)) |
board.pieces(static_cast<Piece>(pt + 6))))));

if (pt == PAWN || pt == BISHOP || pt == QUEEN)
attackers |= attacks::bishop(to_sq, occ) & bishops;
if (pt == ROOK || pt == QUEEN) attackers |= attacks::rook(to_sq, occ) & rooks;
}
return sT != board.colorOf(from_sq);
if (pt == PAWN || pt == BISHOP || pt == QUEEN)
attackers |= attacks::bishop(to_sq, occ) & bishops;
if (pt == ROOK || pt == QUEEN) attackers |= attacks::rook(to_sq, occ) & rooks;
}
return sT != board.colorOf(from_sq);
}

} // namespace see

0 comments on commit eb0f59c

Please sign in to comment.