Created
March 30, 2018 00:42
-
-
Save rust-play/ed91e42c85f9614968519d483694dc93 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
#[derive(Clone, Copy, Debug, PartialEq)] | |
enum Piece { | |
Pawn(Color), | |
Rook(Color), | |
Knight(Color), | |
Queen(Color), | |
King(Color), | |
Bishop(Color), | |
} | |
#[derive(Debug, Clone, Copy, PartialEq)] | |
enum Color { | |
White, | |
Black, | |
} | |
let mut chessboard: [Option<Piece>; 64] = [None; 64]; | |
for i in 0..64 { | |
let (row, col) = (i%8, i/8); | |
chessboard[i] = match (row, col) { | |
(_, 2) => Some(Piece::Pawn(Color::Black)), | |
(_, 6) => Some(Piece::Pawn(Color::White)), | |
_ => None, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment