Skip to content

Instantly share code, notes, and snippets.

@marklocklear
Created April 30, 2013 18:52
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 marklocklear/5491002 to your computer and use it in GitHub Desktop.
Save marklocklear/5491002 to your computer and use it in GitHub Desktop.
#include.rb
def show_board
count = 0
@board.each { |key, value|
print "#{value}" + " | "
if count == 2 or count == 5 then print "\n______________\n" end
count += 1
}
print "\n"
end
def check_for_winner
#check for O's
if @board["ul"] == "O" and @board["um"] == "O" and @board["ur"] == "O" then
@active = false
puts "Player 1(O's) wins"
end
if @board["ml"] == "O" and @board["mm"] == "O" and @board["mr"] == "O" then
@active = false
puts "Player 1(O's) wins"
end
if @board["bl"] == "O" and @board["bm"] == "O" and @board["br"] == "O" then
@active = false
puts "Player 1(O's) wins"
end
if @board["ul"] == "O" and @board["mm"] == "O" and @board["br"] == "O" then
@active = false
puts "Player 1(O's) wins"
end
if @board["bl"] == "O" and @board["mm"] == "O" and @board["ur"] == "O" then
@active = false
puts "Player 1(O's) wins"
end
#check for X's
if @board["ul"] == "X" and @board["um"] == "X" and @board["ur"] == "X" then
@active = false
puts "Player 2(X's) wins"
end
if @board["ml"] == "X" and @board["mm"] == "X" and @board["mr"] == "X" then
@active = false
puts "Player 2(X's) wins"
end
if @board["bl"] == "X" and @board["bm"] == "X" and @board["br"] == "X" then
@active = false
puts "Player 2(X's) wins"
end
if @board["ul"] == "X" and @board["mm"] == "X" and @board["br"] == "X" then
@active = false
puts "Player 2(X's) wins"
end
if @board["bl"] == "X" and @board["mm"] == "X" and @board["ur"] == "X" then
@active = false
puts "Player 2(X's) wins"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment