@@ -114,18 +114,18 @@ impl Board {
114
114
115
115
pub fn set_fen ( & mut self , fen : & str ) {
116
116
let parts: Vec < & str > = fen. split_whitespace ( ) . collect ( ) ;
117
- let mut rank = 7 ;
118
- let mut file = 0 ;
117
+ let mut row = 7 ;
118
+ let mut col = 0 ;
119
119
120
120
for c in parts[ 0 ] . chars ( ) {
121
121
match c {
122
122
'/' => {
123
- rank -= 1 ;
124
- file = 0 ;
123
+ row -= 1 ;
124
+ col = 0 ;
125
125
}
126
126
'1' ..='8' => {
127
127
let offset = c. to_digit ( 10 ) . unwrap ( ) as usize ;
128
- file += offset;
128
+ col += offset;
129
129
}
130
130
_ => {
131
131
let color = if c. is_uppercase ( ) {
@@ -144,8 +144,8 @@ impl Board {
144
144
_ => panic ! ( "Invalid FEN" ) ,
145
145
} ;
146
146
147
- self . add_piece ( color, piece, rank * BOARD_WIDTH + file ) ;
148
- file += 1 ;
147
+ self . add_piece ( color, piece, row * BOARD_WIDTH + col ) ;
148
+ col += 1 ;
149
149
}
150
150
}
151
151
}
@@ -235,15 +235,15 @@ impl Board {
235
235
}
236
236
237
237
fn square_to_index ( square : & str ) -> usize {
238
- let file = square. chars ( ) . nth ( 0 ) . unwrap ( ) as usize - 'a' as usize ;
239
- let rank = square. chars ( ) . nth ( 1 ) . unwrap ( ) as usize - '1' as usize ;
240
- rank * BOARD_WIDTH + file
238
+ let col = square. chars ( ) . nth ( 0 ) . unwrap ( ) as usize - 'a' as usize ;
239
+ let row = square. chars ( ) . nth ( 1 ) . unwrap ( ) as usize - '1' as usize ;
240
+ row * BOARD_WIDTH + col
241
241
}
242
242
243
243
fn index_to_square ( index : usize ) -> String {
244
- let file = ( index % BOARD_WIDTH ) as u8 + b'a' ;
245
- let rank = ( index / BOARD_WIDTH ) as u8 + b'1' ;
246
- format ! ( "{}{}" , file as char , rank as char )
244
+ let col = ( index % BOARD_WIDTH ) as u8 + b'a' ;
245
+ let row = ( index / BOARD_WIDTH ) as u8 + b'1' ;
246
+ format ! ( "{}{}" , col as char , row as char )
247
247
}
248
248
249
249
fn is_square_empty ( & self , index : usize ) -> bool {
@@ -255,9 +255,9 @@ impl Board {
255
255
}
256
256
257
257
pub fn print ( & self ) {
258
- for rank in ( 0 ..BOARD_WIDTH ) . rev ( ) {
259
- for file in 0 ..BOARD_WIDTH {
260
- let index = rank * BOARD_WIDTH + file ;
258
+ for row in ( 0 ..BOARD_WIDTH ) . rev ( ) {
259
+ for col in 0 ..BOARD_WIDTH {
260
+ let index = row * BOARD_WIDTH + col ;
261
261
let piece = if self . white_pieces . pawns . is_set ( index) {
262
262
'P'
263
263
} else if self . white_pieces . knights . is_set ( index) {
@@ -438,8 +438,8 @@ impl Board {
438
438
439
439
// EN PASSANT
440
440
if let Some ( ep) = self . en_passant_square {
441
- let left = ep - 1 ;
442
- let right = ep + 1 ;
441
+ let left = ( to as i32 + MOVE_LEFT ) as usize ;
442
+ let right = ( to as i32 + MOVE_RIGHT ) as usize ;
443
443
if left == ep {
444
444
moves. push ( Move {
445
445
from,
0 commit comments