// Check if player wins game, if true returns true
// triggering game_state to quit game and announce winner
Check if player wins game, if true returns true
triggering game_state to quit game and announce winner
Check if player wins game if true returns true triggering game_state to quit game and announce winner
fn check_for_win_state(player: bool, cells: &mut [char; 9]) -> bool {
    let current_player;
    let mut win_state = false;
    if player {
        current_player = 'X';
    } else {
        current_player = 'O';
    }
    // Check for wine states
    // Only 8 possible win states, no reason not to hard-code
    if cells[0] == current_player && cells[1] == current_player && cells[2] == current_player {
        println!("Player {0} has won the game!", current_player);
        win_state = true;
    } else if cells[3] == current_player && cells[4] == current_player && cells[5] == current_player {
        println!("Player {0} has won the game!", current_player);
        win_state = true;
    } else if cells[6] == current_player && cells[7] == current_player && cells[8] == current_player {
        println!("Player {0} has won the game!", current_player);
        win_state = true;
    } else if cells[0] == current_player && cells[3] == current_player && cells[6] == current_player {
        println!("Player {0} has won the game!", current_player);
        win_state = true;
    } else if cells[1] == current_player && cells[4] == current_player && cells[7] == current_player {
        println!("Player {0} has won the game!", current_player);
        win_state = true;
    } else if cells[2] == current_player && cells[5] == current_player && cells[8] == current_player {
        println!("Player {0} has won the game!", current_player);
        win_state = true;
    } else if cells[0] == current_player && cells[4] == current_player && cells[8] == current_player {
        println!("Player {0} has won the game!", current_player);
        win_state = true;
    } else if cells[2] == current_player && cells[4] == current_player && cells[6] == current_player {
        println!("Player {0} has won the game!", current_player);
        win_state = true;
    }
    win_state
}
fn check_for_win_state ( player : bool , cells : & mut [ char ; 9 ] ) -> bool { let current_player ; let mut win_state = false ; if player { current_player = 'X' ; } else { current_player = 'O' ; } // Check for wine states // Only 8 possible win states, no reason not to hard-code if cells [ 0 ] == current_player && cells [ 1 ] == current_player && cells [ 2 ] == current_player { println ! ( " " current_player ) ; win_state = true ; } else if cells [ 3 ] == current_player && cells [ 4 ] == current_player && cells [ 5 ] == current_player { println ! ( " " current_player ) ; win_state = true ; } else if cells [ 6 ] == current_player && cells [ 7 ] == current_player && cells [ 8 ] == current_player { println ! ( " " current_player ) ; win_state = true ; } else if cells [ 0 ] == current_player && cells [ 3 ] == current_player && cells [ 6 ] == current_player { println ! ( " " current_player ) ; win_state = true ; } else if cells [ 1 ] == current_player && cells [ 4 ] == current_player && cells [ 7 ] == current_player { println ! ( " " current_player ) ; win_state = true ; } else if cells [ 2 ] == current_player && cells [ 5 ] == current_player && cells [ 8 ] == current_player { println ! ( " " current_player ) ; win_state = true ; } else if cells [ 0 ] == current_player && cells [ 4 ] == current_player && cells [ 8 ] == current_player { println ! ( " " current_player ) ; win_state = true ; } else if cells [ 2 ] == current_player && cells [ 4 ] == current_player && cells [ 6 ] == current_player { println ! ( " " current_player ) ; win_state = true ; } win_state }
Check if player wins game, if true returns true
triggering game_state to quit game and announce winner
Check if player wins game if true returns true triggering game_state to quit game and announce winner
player
bool
cells
&mut [char; 9]