use GameState::{ComputerWin, Draw, PlayerWin, Playing};

use rand::prelude::*;

#[derive(PartialEq, Debug)]
enum GameState {
    PlayerWin,
    ComputerWin,
    Draw,
    Playing,
}

type Board = [[char; 3]; 3];

fn main() {
    let mut rng = StdRng::from_entropy();

    let mut board: Board = [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']];

    draw_board(board);
    loop {
        player_turn(&mut board);
        if check_win(board)!= Playing {
            break;
        }
        computer_turn(&mut rng, &mut board);
        if check_win(board)!= Playing {
            break;
        }
        draw_board(board);
    }

    draw_board(board);
    let announcement = match check_win(board) {
        PlayerWin => "The Player has won!",
        ComputerWin => "The Computer has won!",
        Draw => "Draw!",
        Playing => unreachable!(),
    };
    println!("{}", announcement);
}

fn is_empty(cell: &char) -> bool {
    *cell!= 'X' && *cell!= 'O'
}

fn check_win(board: Board) -> GameState {