Skip to content

Commit

Permalink
Update position.h
Browse files Browse the repository at this point in the history
further programming of musketeer chess gating mechanics. ultimately commitGating should be renamed MusketeerGating
  • Loading branch information
musketeerchess authored Dec 19, 2023
1 parent b485cb3 commit 84fc0e5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct StateInfo {
bool pass;
Move move;
int repetition;
PieceType removedGatingType;

// Used by NNUE
Eval::NNUE::Accumulator accumulator;
Expand Down Expand Up @@ -180,6 +181,7 @@ class Position {
bool walling() const;
WallingRule walling_rule() const;
bool seirawan_gating() const;
bool commit_gates() const;
bool cambodian_moves() const;
Bitboard diagonal_lines() const;
bool pass(Color c) const;
Expand Down Expand Up @@ -367,12 +369,17 @@ class Position {
bool tsumeMode;
bool chess960;
int pieceCountInHand[COLOR_NB][PIECE_TYPE_NB];
PieceType committedGates[COLOR_NB][FILE_NB];
int virtualPieces;
Bitboard promotedPieces;
void add_to_hand(Piece pc);
void remove_from_hand(Piece pc);
void drop_piece(Piece pc_hand, Piece pc_drop, Square s);
void undrop_piece(Piece pc_hand, Square s);
void commit_piece(Piece pc, File fl);
void uncommit_piece(Color cl, File fl);
bool has_committed_piece(Color cl, File fl) const;
PieceType drop_committed_piece(Color cl, File fl);
Bitboard find_drop_region(Direction dir, Square s, Bitboard occupied) const;
};

Expand Down Expand Up @@ -802,6 +809,11 @@ inline bool Position::seirawan_gating() const {
return var->seirawanGating;
}

inline bool Position::commit_gates() const {
assert(var != nullptr);
return var->commitGates;
}

inline bool Position::cambodian_moves() const {
assert(var != nullptr);
return var->cambodianMoves;
Expand Down Expand Up @@ -1549,6 +1561,30 @@ inline bool Position::can_drop(Color c, PieceType pt) const {
return variant()->freeDrops || count_in_hand(c, pt) > 0;
}

inline void Position::commit_piece(Piece pc, File fl){
committedGates[color_of(pc)][fl] = type_of(pc);
}

inline void Position::uncommit_piece(Color cl, File fl){
//std::cout << "uncommit_piece\n";
committedGates[cl][fl] = NO_PIECE_TYPE;
}

inline bool Position::has_committed_piece(Color cl, File fl) const {
return committedGates[cl][fl] > NO_PIECE_TYPE;
}

inline PieceType Position::drop_committed_piece(Color cl, File fl){
if(has_committed_piece(cl, fl)){
Square dropSquare = make_square(fl, (cl == WHITE)? RANK_1 : max_rank());
PieceType committedPieceType = committedGates[cl][fl];
put_piece(make_piece(cl, committedPieceType), dropSquare, false, NO_PIECE);
uncommit_piece(cl, fl);
return committedPieceType;
}
else return NO_PIECE_TYPE;
}

} // namespace Stockfish

#endif // #ifndef POSITION_H_INCLUDED

0 comments on commit 84fc0e5

Please sign in to comment.