Skip to content

Instantly share code, notes, and snippets.

@mindplace
Created January 14, 2016 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindplace/985c898e41940ebb1ba8 to your computer and use it in GitHub Desktop.
Save mindplace/985c898e41940ebb1ba8 to your computer and use it in GitHub Desktop.
human player for tic tac toe
class HumanPlayer
def initialize(name, mark=0)
@name = name
@mark = mark
end
def name
@name
end
def mark
@mark
end
def display(board)
board = board.grid
puts "#{board[0][0]} #{board[0][1]} #{board[0][2]}"
puts "#{board[1][0]} #{board[1][1]} #{board[1][2]}"
puts "#{board[2][0]} #{board[2][1]} #{board[2][2]}"
end
def get_move
puts "where"
move = gets.chomp
[move[0].to_i, move[3].to_i]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment