Beispiel #1
0
 public override Bits[] Apply(Bits[] position, Game g)
 {
     var result = new Bits[position.Length];
     Array.Copy (position, result, position.Length);
     // Remove the piece from initial position
     var pI = g.PieceIndex (c, movedIndex);
     result[pI] ^= square;
     // Put it on new position, possibly promoting
     if (promo) {
         var pPI = g.PromotedIndex (c, movedIndex);
         result [pPI] ^= move;
     }
     else
         result [g.PieceIndex (c, movedIndex)] ^= move;
     // If a piece is captured update hand and enemy piece
     if (capturedIndex >= 0) {
         // Get the correct indices
         var pEI = g.PieceIndex (c^1, capturedIndex);
         var hI = g.HandIndex (c);
         // Update the bitboards
         result [pEI] ^= (move);
         var mask = g.handMask[g.demote[capturedIndex]];
         B.PushMasked(ref result[hI], mask);
     }
     return result;
 }
Beispiel #2
0
        public override Bits[] Apply(Bits[] position, Game g)
        {
            //Create a new set of bits
            var result = new Bits[position.Length];
            Array.Copy (position, result, position.Length);

            // Drop the piece in question by setting the location bit
            result [g.PieceIndex  (c, dropIndex)] |= location;

            // Remove the piece from the player's hand
            Bits mask = g.handMask[dropIndex];
            var handIndex = g.HandIndex (c);
            result[handIndex] = result[handIndex];
            B.PopMasked(ref result[handIndex], mask);

            return result;
        }