Skip to content

Instantly share code, notes, and snippets.

@JaiSuryaPrabu
Created August 20, 2024 15:28
Show Gist options
  • Save JaiSuryaPrabu/d0a5e95cb6dc3b05076ad689b1c595e2 to your computer and use it in GitHub Desktop.
Save JaiSuryaPrabu/d0a5e95cb6dc3b05076ad689b1c595e2 to your computer and use it in GitHub Desktop.
Tic Tac Toe function for plotting player mark in the board
fn plot_player(player : &String, board : &mut Vec<String>, index : &usize) -> (bool,bool) {
let mut is_won = false;
let mut is_valid = true;
if board[index-1] != String::from("X") && board[index-1] != String::from("O") && !is_won {
board[index-1] = player.to_string();
is_won = check_win(player.to_string(),board.to_vec());
} else {
is_valid = false;
}
return (is_valid,is_won);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment