tictactoe/ticcy.rb

48 lines
748 B
Ruby

# coding: utf-8
require './board'
require './bot'
require './human'
@board = Board.new
def play_game player, bot
while true do
# system "clear"
print @board.to_s
player.move
if @board.is_full? then
print @board.to_s
print "Game is done!\n"
break
end
if @board.any_winner? then
print @board.to_s
print "Someone won!\n"
break
end
bot.move @board
if @board.is_full? then
print @board.to_s
print "Game is done!\n"
break
end
if @board.any_winner? then
print @board.to_s
print "Someone won!\n"
break
end
end
end
player = Human.new @board, " X "
bot = Bot.new @board, " O "
play_game player, bot