-
intro XX
-
get player info XX
-
create computer XX
-
set computer token XX
-
Create new Game XX
-
set @player XX
-
set @opponent XX
-
determine who's turn it is XX
-
initiate new board XX
update board print the board
- check for wins XXX
- check for ties XX
issues
- square 1 wins
- computer isnt winning with 3 in a row
- wrong numbers when selecting a square
- create play again feature
- end of each game return player's updated record
example 1 @turn_count = 0 human makes move if @turn_count % 2 == 0 computer makes move if @turn_count % 2 == 1
def current_move if @turn_count.even? @player else @computer end end
example 2
def switch_players @current_player, @other_player = @other_player, @current_player end
@board = [ [X, O, X] @board[0][0], @board[0][1], @board[0][2] [O, X, O], @board[1][0], @board[0][1], @board[0][2] [X, O, X] @board[2][0], @board[0][1], @board[0][2] ]
def human_move_translate(human_move) input_coords = { "1" => [0, 0], "2" => [0, 1], "3" => [0, 2], "4" => [1, 0], "5" => [1, 1], "6" => [1, 2], "7" => [2, 0], "8" => [2, 1], "9" => [2, 2] } return input_coords[human_move] end