Skip to content

Instantly share code, notes, and snippets.

@pumpkincouture
Created July 18, 2014 21:57
Show Gist options
  • Save pumpkincouture/98b4876b9401427e3a82 to your computer and use it in GitHub Desktop.
Save pumpkincouture/98b4876b9401427e3a82 to your computer and use it in GitHub Desktop.
class Game
def initialize(play_game=false)
@no_space=8
@board={"1"=>"1", "2"=>"2", "3"=>"3", "4"=>"4", "5"=>"5",
"6"=>"6", "7"=>"7", "8"=>"8", "9"=>"9"}
def display_board
puts "#{@board["1"]} | #{@board["2"]} | #{@board["3"]}"
puts "---------"
puts "#{@board["4"]} | #{@board["5"]} | #{@board["6"]}"
puts "---------"
puts "#{@board["7"]} | #{@board["8"]} | #{@board["9"]}"
end
puts "Welcome to a Simpler Tic Tac Toe. The computer will go first."
@board["5"]="X"
puts "The computer chose space number 5."
display_board
@no_space -= 1
end
def game_over?
@no_space<=0
end
def play_game
return "Game over" if game_over?
user_turn
computer_turn
# count_spaces
end
######computer and user methods########
new_game=Game.new(true)
until new_game.game_over?
new_game.play_game
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment