Advertisement
Guest User

Untitled

a guest
Apr 18th, 2022
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. extern crate enum_map;
  2.  
  3. use enum_map::{enum_map, EnumMap};
  4.  
  5. enum CellStatus{
  6. Empty,
  7. Cross,
  8. Circle,
  9. }
  10.  
  11. enum GameStatus {
  12. Playing,
  13. CrossWin,
  14. CircleWin,
  15. Draw,
  16. }
  17.  
  18. enum PlayerTurn {
  19. Cross,
  20. Circle,
  21. }
  22.  
  23.  
  24. fn print_board(board: &[CellStatus], celldict: &EnumMap<&CellStatus, &str>){
  25. for cell in board{
  26. println!("{}", celldict[cell]);
  27.  
  28. }
  29. }
  30.  
  31.  
  32. fn main() {
  33.  
  34.  
  35. let cell_repr = enum_map! {
  36. CellStatus::Empty => " _ ".to_string(),
  37. CellStatus::Cross => " X ".to_string(),
  38. CellStatus::Circle => " O ".to_string(),
  39. };
  40.  
  41.  
  42. let mut board = [CellStatus::Empty, CellStatus::Empty, CellStatus::Empty,
  43. CellStatus::Empty, CellStatus::Empty, CellStatus::Empty,
  44. CellStatus::Empty, CellStatus::Empty, CellStatus::Empty];
  45.  
  46.  
  47.  
  48. let mut status = GameStatus::Playing;
  49. let mut turn = PlayerTurn::Cross;
  50.  
  51. print_board(&board, &cell_repr);
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement