Ui changes and numbers between 1-9 now
This commit is contained in:
parent
33d73dbf7b
commit
df1d3f59ae
4
bot.rb
4
bot.rb
|
@ -8,8 +8,8 @@ class Bot
|
||||||
end
|
end
|
||||||
|
|
||||||
def move board
|
def move board
|
||||||
return "Game is done!" if board.is_full?
|
return "\nGame is done!" if board.is_full?
|
||||||
return "Someone won!" if board.any_winner?
|
return "\nSomeone won!" if board.any_winner?
|
||||||
# move = @board.get_free.sample
|
# move = @board.get_free.sample
|
||||||
# @board.set " O ", move
|
# @board.set " O ", move
|
||||||
minmax board, @piece
|
minmax board, @piece
|
||||||
|
|
3
human.rb
3
human.rb
|
@ -11,11 +11,12 @@ class Human
|
||||||
print "\nPick a move!\n"
|
print "\nPick a move!\n"
|
||||||
free_moves = @board.get_free
|
free_moves = @board.get_free
|
||||||
idx = gets.strip.to_i
|
idx = gets.strip.to_i
|
||||||
|
free_moves.map! {|i| i+1}
|
||||||
if not free_moves.include? idx then
|
if not free_moves.include? idx then
|
||||||
print "Square is already taken, try again!"
|
print "Square is already taken, try again!"
|
||||||
move
|
move
|
||||||
else
|
else
|
||||||
@board.set @piece, idx
|
@board.set @piece, (idx - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
11
ticcy.rb
11
ticcy.rb
|
@ -9,20 +9,20 @@ require './human'
|
||||||
|
|
||||||
def play_game player, bot
|
def play_game player, bot
|
||||||
while true do
|
while true do
|
||||||
# system "clear"
|
system "clear"
|
||||||
|
|
||||||
print @board.to_s
|
print @board.to_s
|
||||||
player.move
|
player.move
|
||||||
|
|
||||||
if @board.is_full? then
|
if @board.is_full? then
|
||||||
print @board.to_s
|
print @board.to_s
|
||||||
print "Game is done!\n"
|
print "\nGame is done!\n"
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
if @board.any_winner? then
|
if @board.any_winner? then
|
||||||
print @board.to_s
|
print @board.to_s
|
||||||
print "Someone won!\n"
|
print "\nSomeone won!\n"
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,15 +30,16 @@ def play_game player, bot
|
||||||
|
|
||||||
if @board.is_full? then
|
if @board.is_full? then
|
||||||
print @board.to_s
|
print @board.to_s
|
||||||
print "Game is done!\n"
|
print "\nGame is done!\n"
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
if @board.any_winner? then
|
if @board.any_winner? then
|
||||||
print @board.to_s
|
print @board.to_s
|
||||||
print "Someone won!\n"
|
print "\nSomeone won!\n"
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
system "clear"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user