adjust othello board coordinate system to project requirements
This commit is contained in:
parent
3e3649369f
commit
3376fc1e5b
24
src/board.rs
24
src/board.rs
@ -92,12 +92,12 @@ impl fmt::Display for Board {
|
||||
|
||||
// Print numbers at top so the board can be read more easier
|
||||
write!(f, "{} ", space_padding)?;
|
||||
for j in 0..BOARD_SIZE {
|
||||
for j in (0..BOARD_SIZE).rev() {
|
||||
write!(f, "{:0PADDING$} ", j)?;
|
||||
}
|
||||
writeln!(f)?;
|
||||
|
||||
for i in 0..BOARD_SIZE {
|
||||
for i in (0..BOARD_SIZE).rev() {
|
||||
writeln!(f, "{}{}", space_padding, horiz_sep_line)?;
|
||||
|
||||
write!(f, "{:0PADDING$}|", i)?;
|
||||
@ -142,10 +142,10 @@ impl Board {
|
||||
|
||||
/// Starting position
|
||||
pub fn starting_pos(mut self) -> Self {
|
||||
self.place_unchecked((BOARD_SIZE / 2) - 1, (BOARD_SIZE / 2) - 1, Piece::White);
|
||||
self.place_unchecked(BOARD_SIZE / 2, (BOARD_SIZE / 2) - 1, Piece::Black);
|
||||
self.place_unchecked((BOARD_SIZE / 2) - 1, BOARD_SIZE / 2, Piece::Black);
|
||||
self.place_unchecked(BOARD_SIZE / 2, BOARD_SIZE / 2, Piece::White);
|
||||
self.place_unchecked((BOARD_SIZE / 2) - 1, (BOARD_SIZE / 2) - 1, Piece::Black);
|
||||
self.place_unchecked(BOARD_SIZE / 2, (BOARD_SIZE / 2) - 1, Piece::White);
|
||||
self.place_unchecked((BOARD_SIZE / 2) - 1, BOARD_SIZE / 2, Piece::White);
|
||||
self.place_unchecked(BOARD_SIZE / 2, BOARD_SIZE / 2, Piece::Black);
|
||||
self
|
||||
}
|
||||
|
||||
@ -381,18 +381,6 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diag_capture() {
|
||||
let mut board = Board::new().starting_pos();
|
||||
|
||||
assert_eq!(board.place(2, 4, Piece::White), Ok(()), "{}", board);
|
||||
assert_eq!(board.place(2, 3, Piece::Black), Ok(()), "{}", board);
|
||||
|
||||
assert_eq!(board.place(2, 2, Piece::White), Ok(()), "{}", board);
|
||||
|
||||
assert_eq!(board.place(2, 5, Piece::Black), Ok(()), "{}", board);
|
||||
}
|
||||
|
||||
// Test corner capture from top-left corner
|
||||
#[test]
|
||||
fn corner_capture_top_left() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user