@@ -62,7 +62,7 @@ int backward(U64 whitePawns, U64 blackPawns) {
6262inline U64 getBlockedPawns (U64 pawns, U64 enemyPieces, bool isWhite) {
6363 return isWhite ? north (pawns) & enemyPieces : south (pawns) & enemyPieces;
6464}
65- int blockage (chess::Board board){
65+ int blockage (chess::Board& board){
6666 return POPCOUNT64 (getBlockedPawns (board.pieces (chess::PieceType::underlying::PAWN,board.sideToMove ()).getBits (),board.them (board.sideToMove ()).getBits (),(int )board.sideToMove ()))*5 ;
6767}
6868
@@ -73,7 +73,7 @@ inline U64 getHangingPawns(U64 pawns, U64 friendlyPieces) {
7373 return pawns & ~defended;
7474}
7575
76- int pawnIslands (chess::Board board){
76+ int pawnIslands (chess::Board& board){
7777
7878 int islands = 0 ;
7979 U64 remaining = board.pieces (chess::PieceType::underlying::PAWN, board.sideToMove ()).getBits ();
@@ -97,22 +97,22 @@ inline U64 getDoublyIsolatedPawns(U64 pawns) {
9797 U64 isolated = getIsolatedPawns (pawns);
9898 return isolated & (isolated - 1 ); // More than one isolated pawn in a file
9999}
100- int isolated (chess::Board board){
100+ int isolated (chess::Board& board){
101101 return POPCOUNT64 (getIsolatedPawns (board.pieces (chess::PieceType::underlying::PAWN,board.sideToMove ()).getBits ()))*5 ;
102102}
103- int dblisolated (chess::Board board){
103+ int dblisolated (chess::Board& board){
104104 return POPCOUNT64 (getDoublyIsolatedPawns (board.pieces (chess::PieceType::underlying::PAWN,board.sideToMove ()).getBits ()))*10 ;
105105}
106106// **2. Holes** (Uncontested squares that cannot be controlled by pawns)
107107inline U64 getHoles (U64 whitePawns, U64 blackPawns) {
108108 U64 pawnControl = north (whitePawns) | south (blackPawns);
109109 return ~pawnControl; // Holes are squares not controlled by any pawn
110110}
111- int holes (chess::Board board){
111+ int holes (chess::Board& board){
112112 return POPCOUNT64 (getHoles (board.pieces (chess::PieceType::underlying::PAWN,chess::Color::underlying::WHITE).getBits (),board.pieces (chess::PieceType::underlying::PAWN,chess::Color::underlying::BLACK).getBits ()))*5 ;
113113}
114114
115- int pawnRace (chess::Board board) {
115+ int pawnRace (chess::Board& board) {
116116 U64 myPawns = board.pieces (chess::PieceType::PAWN, board.sideToMove ()).getBits ();
117117 int minDistance = 8 ; // Maximum distance to promotion
118118 while (myPawns) {
@@ -131,7 +131,7 @@ inline U64 getWeakPawns(U64 pawns, U64 enemyPawns) {
131131 U64 backward = (north (pawns) & enemyPawns) | (south (pawns) & enemyPawns);
132132 return isolated | backward; // Any pawn that is weak
133133}
134- int weaks (chess::Board board){
134+ int weaks (chess::Board& board){
135135 return POPCOUNT64 (getWeakPawns (board.pieces (chess::PieceType::underlying::PAWN,board.sideToMove ()).getBits (),board.pieces (chess::PieceType::underlying::PAWN,~board.sideToMove ()).getBits ()))*6 ;
136136}
137137inline U64 getKingMobility (U64 king, U64 enemyPieces) {
@@ -170,7 +170,7 @@ inline bool shouldUnderpromote(U64 pawn, U64 enemyKing, bool isWhite, U64 enemyP
170170
171171 return false ; // Default: Queen promotion is optimal
172172}
173- int underpromote (chess::Board board) {
173+ int underpromote (chess::Board& board) {
174174 if (board.move_stack .empty ()) return 0 ; // No moves to undo → no underpromotion
175175 chess::Move move = board.pop ();
176176
@@ -217,14 +217,14 @@ int underpromote(chess::Board board) {
217217inline U64 getColorWeakness (U64 pawns) {
218218 return ~((pawns & DARK_SQUARES) | (pawns & LIGHT_SQUARES)); // Weak squares
219219}
220- int weakness (chess::Board board){
220+ int weakness (chess::Board& board){
221221 return POPCOUNT64 (getColorWeakness (board.pieces (chess::PieceType::underlying::PAWN,board.sideToMove ()).getBits ()))*10 ;
222222}
223223// **5. Pawn Shield (King Protection by Pawns)**
224224inline U64 getPawnShield (U64 king, U64 pawns, bool isWhite) {
225225 return isWhite ? (north (king) & pawns) : (south (king) & pawns);
226226}
227- int pawnShield (chess::Board board){
227+ int pawnShield (chess::Board& board){
228228 return POPCOUNT64 (getPawnShield (1ULL <<board.kingSq (board.sideToMove ()).index (),board.pieces (chess::PieceType::underlying::PAWN,board.sideToMove ()).getBits (),(int )board.sideToMove ()))*5 ;
229229}
230230
@@ -258,37 +258,37 @@ inline U64 getOpenPawns(U64 pawns, U64 enemyPawns) {
258258 return pawns & ~(north (pawns) & enemyPawns); // No enemy directly in front
259259}
260260
261- int pawnStorm (chess::Board board) {
261+ int pawnStorm (chess::Board& board) {
262262 U64 myPawns = board.pieces (chess::PieceType::PAWN, board.sideToMove ()).getBits ();
263263 U64 storm = board.sideToMove () ? north (myPawns) | north (north (myPawns))
264264 : south (myPawns) | south (south (myPawns));
265265 return POPCOUNT64 (storm) * 5 ; // Bonus for aggressive pawn pushes
266266}
267267
268- int pawnLevers (chess::Board board) {
268+ int pawnLevers (chess::Board& board) {
269269 U64 myPawns = board.pieces (chess::PieceType::PAWN, board.sideToMove ()).getBits ();
270270 U64 enemyPawns = board.pieces (chess::PieceType::PAWN, ~board.sideToMove ()).getBits ();
271271 return POPCOUNT64 (getPawnLevers (myPawns, enemyPawns)) * 5 ; // Bonus for break opportunities
272272}
273273
274- int outpost (chess::Board board) {
274+ int outpost (chess::Board& board) {
275275 U64 myKnights = board.pieces (chess::PieceType::KNIGHT, board.sideToMove ()).getBits ();
276276 U64 myPawns = board.pieces (chess::PieceType::PAWN, board.sideToMove ()).getBits ();
277277 return POPCOUNT64 (getOutposts (myKnights, myPawns, board.sideToMove ())) * 10 ; // Reward strong knights
278278}
279- int evaluatePawnRams (chess::Board board) {
279+ int evaluatePawnRams (chess::Board& board) {
280280 return POPCOUNT64 (getPawnRams (
281281 board.pieces (chess::PieceType::PAWN, board.sideToMove ()).getBits (),
282282 board.pieces (chess::PieceType::PAWN, ~board.sideToMove ()).getBits ())) * 5 ;
283283}
284284
285- int evaluateUnfreePawns (chess::Board board) {
285+ int evaluateUnfreePawns (chess::Board& board) {
286286 return POPCOUNT64 (getUnfreePawns (
287287 board.pieces (chess::PieceType::PAWN, board.sideToMove ()).getBits (),
288288 board.pieces (chess::PieceType::PAWN, ~board.sideToMove ()).getBits ())) * 7 ;
289289}
290290
291- int evaluateOpenPawns (chess::Board board) {
291+ int evaluateOpenPawns (chess::Board& board) {
292292 return POPCOUNT64 (getOpenPawns (
293293 board.pieces (chess::PieceType::PAWN, board.sideToMove ()).getBits (),
294294 board.pieces (chess::PieceType::PAWN, ~board.sideToMove ()).getBits ())) * 3 ;
0 commit comments