@@ -376,24 +376,6 @@ public static void UpdateCastleStatus(this ref BoardStateData board, CastleRight
376
376
board . Hash ^= Zobrist . BlackQueenSideCastlingRights ;
377
377
}
378
378
}
379
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
380
- public static void UpdateMirrorStatus ( this ref BoardStateData board , byte piece , bool fromMirroredSide , bool toMirroredSide )
381
- {
382
- if ( fromMirroredSide == toMirroredSide )
383
- {
384
- return ;
385
- }
386
-
387
- if ( piece == Constants . WhiteKing )
388
- {
389
- board . ShouldWhiteMirrored = toMirroredSide ;
390
- }
391
-
392
- if ( piece == Constants . BlackKing )
393
- {
394
- board . ShouldBlackMirrored = toMirroredSide ;
395
- }
396
- }
397
379
398
380
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
399
381
public static unsafe void FinishApply ( this ref BoardStateData board , VectorShort * whiteAcc , VectorShort * blackAcc , ulong * hashHistory , uint m ,
@@ -404,6 +386,15 @@ public static unsafe void FinishApply(this ref BoardStateData board, VectorShort
404
386
405
387
var ( movedPiece , fromSquare , toSquare , capturedPiece , moveType ) = m . Deconstruct ( ) ;
406
388
389
+ if ( movedPiece == Constants . WhiteKing )
390
+ {
391
+ board . WhiteNeedsRefresh |= board . WhiteMirrored != toSquare . IsMirroredSide ( ) || board . WhiteInputBucket != NnueEvaluator . GetKingBucket ( toSquare ) ;
392
+ }
393
+ else if ( movedPiece == Constants . BlackKing )
394
+ {
395
+ board . BlackNeedsRefresh |= board . BlackMirrored != toSquare . IsMirroredSide ( ) || board . BlackInputBucket != NnueEvaluator . GetKingBucket ( ( byte ) ( toSquare ^ 0x38 ) ) ;
396
+ }
397
+
407
398
if ( moveType == 0 )
408
399
{
409
400
board . Replace ( whiteAcc , blackAcc , movedPiece , fromSquare , toSquare ) ;
@@ -427,8 +418,8 @@ public static unsafe void FinishApply(this ref BoardStateData board, VectorShort
427
418
// Castle move
428
419
if ( toSquare == 62 )
429
420
{
430
- board . Replace ( whiteAcc , blackAcc , Constants . BlackRook , 63 , 61 ) ;
431
- board . Replace ( whiteAcc , blackAcc , Constants . BlackKing , fromSquare , toSquare ) ;
421
+ board . Replace ( whiteAcc , blackAcc , Constants . BlackRook , 63 , 61 ) ;
422
+ board . Replace ( whiteAcc , blackAcc , Constants . BlackKing , fromSquare , toSquare ) ;
432
423
board . Hash ^= Zobrist . PiecesArray [ Constants . BlackKing * 64 + fromSquare ] ^
433
424
Zobrist . PiecesArray [ Constants . BlackKing * 64 + toSquare ] ^
434
425
Zobrist . PiecesArray [ Constants . BlackRook * 64 + 63 ] ^
@@ -514,7 +505,6 @@ public static unsafe void FinishApply(this ref BoardStateData board, VectorShort
514
505
}
515
506
516
507
board . UpdateCastleStatus ( prevCastle ) ;
517
- board . UpdateMirrorStatus ( movedPiece , fromSquare . IsMirroredSide ( ) , toSquare . IsMirroredSide ( ) ) ;
518
508
519
509
hashHistory [ board . TurnCount - 1 ] = board . Hash ;
520
510
}
0 commit comments