Swap file and rank in Position

Because the chess positions read as "file-rank"
This commit is contained in:
2025-02-20 21:00:53 +01:00
parent 5108b4a6e2
commit 01ccb65b64
2 changed files with 5 additions and 5 deletions

View File

@@ -29,15 +29,15 @@ impl Color {
#[derive(PartialEq, Eq, Hash, Clone)]
pub struct Position {
pub rank: Rank,
pub file: File,
pub rank: Rank,
}
impl Position {
pub fn new(rank: Rank, file: File) -> Position {
pub fn new(file: File, rank: Rank) -> Position {
Position {
rank,
file,
rank,
}
}
fn delta(
@@ -190,7 +190,7 @@ impl PieceType {
piece_type: self.clone(),
color: color.clone(),
},
Position::new(color.get_pawn_rank(), file),
Position::new(file, color.get_pawn_rank()),
)
})
})

View File

@@ -103,7 +103,7 @@ impl board::Position {
let file = board::File::parse(chars.next().ok_or(())?)?;
let rank = board::Rank::parse(chars.next().ok_or(())?)?;
if chars.next().is_none() {
Ok(board::Position::new(rank, file))
Ok(board::Position::new(file, rank))
} else {
Err(())
}