Skip to content

Commit 9640f78

Browse files
committed
Move old dataparser into different directory
1 parent b2e1963 commit 9640f78

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
// BulletFormat
2-
#[repr(C)]
3-
#[derive(Debug, Clone, Copy, PartialEq, Default)]
4-
pub struct Position {
5-
occupancy: u64,
6-
pieces: u128,
7-
score: i16,
8-
result: u8,
9-
stm_king: u8,
10-
nstm_king: u8,
11-
}
12-
13-
impl Position {
14-
pub fn get_score(&self) -> f32 {
15-
self.score as f32
16-
}
17-
18-
pub fn get_result(&self) -> f32 {
19-
self.result as f32 / 2.0
20-
}
21-
22-
pub fn process_features<F>(&self, mut features: F)
23-
where
24-
F: FnMut(i16, i16),
25-
{
26-
let mut occupancy = self.occupancy;
27-
let mut pieces = self.pieces;
28-
const PIECE_VALUES: [i16; 14] = [ 0, 64, 128, 192, 256, 320, 0, 0, 384, 448, 512, 576, 640, 704, ];
29-
30-
while occupancy != 0 {
31-
let square = occupancy.trailing_zeros() as i16;
32-
let colored_piece = (pieces & 0b1111) as i16;
33-
34-
occupancy &= occupancy - 1;
35-
pieces >>= 4;
36-
37-
let stm_feature = PIECE_VALUES[colored_piece as usize] + square;
38-
let nstm_feature = PIECE_VALUES[(colored_piece ^ 8) as usize] + (square ^ 56);
39-
40-
features(stm_feature, nstm_feature);
41-
}
42-
}
43-
}
1+
// BulletFormat
2+
#[repr(C)]
3+
#[derive(Debug, Clone, Copy, PartialEq, Default)]
4+
pub struct Position {
5+
occupancy: u64,
6+
pieces: u128,
7+
score: i16,
8+
result: u8,
9+
stm_king: u8,
10+
nstm_king: u8,
11+
}
12+
13+
impl Position {
14+
pub fn get_score(&self) -> f32 {
15+
self.score as f32
16+
}
17+
18+
pub fn get_result(&self) -> f32 {
19+
self.result as f32 / 2.0
20+
}
21+
22+
pub fn process_features<F>(&self, mut features: F)
23+
where
24+
F: FnMut(i16, i16),
25+
{
26+
let mut occupancy = self.occupancy;
27+
let mut pieces = self.pieces;
28+
const PIECE_VALUES: [i16; 14] = [ 0, 64, 128, 192, 256, 320, 0, 0, 384, 448, 512, 576, 640, 704, ];
29+
30+
while occupancy != 0 {
31+
let square = occupancy.trailing_zeros() as i16;
32+
let colored_piece = (pieces & 0b1111) as i16;
33+
34+
occupancy &= occupancy - 1;
35+
pieces >>= 4;
36+
37+
let stm_feature = PIECE_VALUES[colored_piece as usize] + square;
38+
let nstm_feature = PIECE_VALUES[(colored_piece ^ 8) as usize] + (square ^ 56);
39+
40+
features(stm_feature, nstm_feature);
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)