bottom left is (0, 0)

This commit is contained in:
Simon Gardling 2025-04-03 15:46:29 -04:00
parent 18213278fd
commit a50ca2c1b1
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 30 additions and 30 deletions

View File

@ -713,24 +713,24 @@ mod tests {
// replay of a test I did // replay of a test I did
// TODO! make this as small of a test as possible // TODO! make this as small of a test as possible
let moves = vec![ let moves = vec![
(Some((5, 4)), Piece::Black), (Some((5, 3)), Piece::Black),
(Some((5, 5)), Piece::White), (Some((5, 2)), Piece::White),
(Some((5, 6)), Piece::Black), (Some((5, 1)), Piece::Black),
(Some((6, 4)), Piece::White), (Some((6, 3)), Piece::White),
(Some((7, 3)), Piece::Black), (Some((7, 4)), Piece::Black),
(Some((7, 4)), Piece::White), (Some((7, 3)), Piece::White),
(Some((7, 5)), Piece::Black), (Some((7, 2)), Piece::Black),
(Some((2, 4)), Piece::White), (Some((2, 3)), Piece::White),
(Some((1, 4)), Piece::Black), (Some((1, 3)), Piece::Black),
(Some((1, 5)), Piece::White), (Some((1, 2)), Piece::White),
(Some((1, 6)), Piece::Black), (Some((1, 1)), Piece::Black),
(Some((0, 6)), Piece::White), (Some((0, 1)), Piece::White),
(Some((3, 2)), Piece::Black), (Some((3, 5)), Piece::Black),
(Some((1, 7)), Piece::White), (Some((1, 0)), Piece::White),
(None, Piece::Black), // black skips a move (None, Piece::Black), // black skips a move
(Some((0, 4)), Piece::White), (Some((0, 3)), Piece::White),
(None, Piece::Black), // black skips a move (None, Piece::Black), // black skips a move
(Some((4, 2)), Piece::White), (Some((4, 5)), Piece::White),
]; ];
for (i, (coords, color)) in moves.into_iter().enumerate() { for (i, (coords, color)) in moves.into_iter().enumerate() {
@ -775,10 +775,10 @@ mod tests {
let mut b = Board::STARTING_POSITION; let mut b = Board::STARTING_POSITION;
futm.update_from_board(&b); futm.update_from_board(&b);
b.place((4, 2).into(), Piece::White).unwrap(); b.place((4, 5).into(), Piece::White).unwrap();
futm.arena.push(Move::new( futm.arena.push(Move::new(
Some((4, 2).into()), Some((4, 5).into()),
b, b,
Piece::White, Piece::White,
Piece::White, Piece::White,
@ -788,14 +788,14 @@ mod tests {
assert_eq!( assert_eq!(
futm.move_history(1), futm.move_history(1),
Some(vec![(Some((4, 2).into()), Piece::White)]), Some(vec![(Some((4, 5).into()), Piece::White)]),
); );
assert_eq!(futm.get_board_from_idx(1), Some(b)); assert_eq!(futm.get_board_from_idx(1), Some(b));
b.place((5, 4).into(), Piece::Black).unwrap(); b.place((5, 3).into(), Piece::Black).unwrap();
futm.arena.push(Move::new( futm.arena.push(Move::new(
Some((5, 4).into()), Some((5, 3).into()),
b, b,
Piece::Black, Piece::Black,
Piece::White, Piece::White,
@ -805,8 +805,8 @@ mod tests {
assert_eq!( assert_eq!(
futm.move_history(2), futm.move_history(2),
Some(vec![ Some(vec![
(Some((4, 2).into()), Piece::White), (Some((4, 5).into()), Piece::White),
(Some((5, 4).into()), Piece::Black) (Some((5, 3).into()), Piece::Black)
]), ]),
); );
assert_eq!(futm.get_board_from_idx(2), Some(b)); assert_eq!(futm.get_board_from_idx(2), Some(b));

View File

@ -66,7 +66,7 @@ impl fmt::Display for Board {
// Print numbers at top so the board can be read more easier // Print numbers at top so the board can be read more easier
write!(f, "{}", SPACE_PADDING)?; write!(f, "{}", SPACE_PADDING)?;
for j in (0..Self::SIZE).rev() { for j in 0..Self::SIZE {
write!(f, " {:0PADDING$}", j)?; write!(f, " {:0PADDING$}", j)?;
} }
writeln!(f)?; writeln!(f)?;
@ -75,7 +75,7 @@ impl fmt::Display for Board {
writeln!(f, "{}{}", SPACE_PADDING, HORIZ_SEP_LINE)?; writeln!(f, "{}{}", SPACE_PADDING, HORIZ_SEP_LINE)?;
write!(f, "{:0PADDING$}|", i)?; write!(f, "{:0PADDING$}|", i)?;
for j in (0..Self::SIZE).rev() { for j in 0..Self::SIZE {
write!( write!(
f, f,
"{}|", "{}|",
@ -138,11 +138,11 @@ impl Board {
let mut new = Self::new(); let mut new = Self::new();
let hf = Self::SIZE / 2; let hf = Self::SIZE / 2;
new.place_unchecked(CoordPair::from_axes(hf - 1, hf - 1), Piece::White); new.place_unchecked(CoordPair::from_axes(hf - 1, hf - 1), Piece::Black);
new.place_unchecked(CoordPair::from_axes(hf, hf - 1), Piece::Black); new.place_unchecked(CoordPair::from_axes(hf, hf - 1), Piece::White);
new.place_unchecked(CoordPair::from_axes(hf - 1, hf), Piece::Black); new.place_unchecked(CoordPair::from_axes(hf - 1, hf), Piece::White);
new.place_unchecked(CoordPair::from_axes(hf, hf), Piece::White); new.place_unchecked(CoordPair::from_axes(hf, hf), Piece::Black);
new new
}; };
@ -498,7 +498,7 @@ mod test {
fn format_test() { fn format_test() {
assert_eq!( assert_eq!(
Board::STARTING_POSITION.to_string().as_str(), Board::STARTING_POSITION.to_string().as_str(),
" 7 6 5 4 3 2 1 0 " 0 1 2 3 4 5 6 7
----------------- -----------------
7| | | | | | | | | 7| | | | | | | | |
----------------- -----------------