Sha256: 4a97b9d5ffe57044c33c0d4cb9a3cc49d9f50524a7408209d27dd2e20ce185f9
Contents?: true
Size: 638 Bytes
Versions: 2
Compression:
Stored size: 638 Bytes
Contents
module TresRaya class HumanPlayer < Player def move( board ) print board moves = board.moves print "Your move? (format: b3) " move = $stdin.gets until moves.include?(move.chomp.downcase) print "Invalid move. Try again. " move = $stdin.gets end move.chomp end def finish( final_board ) print final_board if final_board.won? == @mark print "Congratulations, you win.\n\n" elsif final_board.won? == " " print "Tie game.\n\n" else print "You lost tic-tac-toe?!\n\n" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tres-raya-0.0.3 | lib/tres_raya/human_player.rb |
tres-raya-0.0.2 | lib/tres_raya/human_player.rb |