From df1d3f59ae40b5060e455885a0d23ded0e68b015 Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Tue, 23 Jan 2018 02:13:50 +0100 Subject: [PATCH] Ui changes and numbers between 1-9 now --- bot.rb | 4 ++-- human.rb | 3 ++- ticcy.rb | 11 ++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bot.rb b/bot.rb index 0156461..ce2f242 100644 --- a/bot.rb +++ b/bot.rb @@ -8,8 +8,8 @@ class Bot end def move board - return "Game is done!" if board.is_full? - return "Someone won!" if board.any_winner? + return "\nGame is done!" if board.is_full? + return "\nSomeone won!" if board.any_winner? # move = @board.get_free.sample # @board.set " O ", move minmax board, @piece diff --git a/human.rb b/human.rb index 16011fe..ce1f9c3 100644 --- a/human.rb +++ b/human.rb @@ -11,11 +11,12 @@ class Human print "\nPick a move!\n" free_moves = @board.get_free idx = gets.strip.to_i + free_moves.map! {|i| i+1} if not free_moves.include? idx then print "Square is already taken, try again!" move else - @board.set @piece, idx + @board.set @piece, (idx - 1) end end end diff --git a/ticcy.rb b/ticcy.rb index 0675594..aa400c4 100644 --- a/ticcy.rb +++ b/ticcy.rb @@ -9,20 +9,20 @@ require './human' def play_game player, bot while true do - # system "clear" + system "clear" print @board.to_s player.move if @board.is_full? then print @board.to_s - print "Game is done!\n" + print "\nGame is done!\n" break end if @board.any_winner? then print @board.to_s - print "Someone won!\n" + print "\nSomeone won!\n" break end @@ -30,15 +30,16 @@ def play_game player, bot if @board.is_full? then print @board.to_s - print "Game is done!\n" + print "\nGame is done!\n" break end if @board.any_winner? then print @board.to_s - print "Someone won!\n" + print "\nSomeone won!\n" break end + system "clear" end end