Skip to content

Commit 8c9c8c7

Browse files
authored
Use u128 variable for pieces
1 parent f6bb684 commit 8c9c8c7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

dataparser/src/position.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#[derive(Debug, Clone, Copy, PartialEq, Default)]
44
pub struct Position {
55
occupancy: u64,
6-
pieces: [u8; 16],
6+
pieces: u128,
77
score: i16,
88
result: u8,
99
stm_king: u8,
@@ -24,16 +24,15 @@ impl Position {
2424
F: FnMut(i16, i16),
2525
{
2626
let mut occupancy = self.occupancy;
27-
let mut index = 0;
27+
let mut pieces = self.pieces;
2828
const PIECE_MIRROR: [i16; 12] = [384, 448, 512, 576, 640, 704, 0, 64, 128, 192, 256, 320];
2929

3030
while occupancy != 0 {
3131
let square = occupancy.trailing_zeros() as i16;
32-
let shifts = [1, 16];
33-
let piece = ((self.pieces[index / 2] / shifts[index % 2]) & 0b1111) as i16;
32+
let piece = (pieces & 0b1111) as i16;
3433

3534
occupancy &= occupancy - 1;
36-
index += 1;
35+
pieces >>= 4;
3736

3837
let stm_feature = piece * 64 + square;
3938
let nstm_feature = PIECE_MIRROR[piece as usize] + square ^ 56;

0 commit comments

Comments
 (0)