-
Notifications
You must be signed in to change notification settings - Fork 0
/
tictactoe.rb
81 lines (61 loc) · 1.9 KB
/
tictactoe.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#initialize board and set up the 2 players and general rules/menu
#set up 1st player turn phase
#set up comp turn phase
#check winning conditions
#keep track of score and print
# define new board
def board_new
@board1 = [1, 2, 3]
@board2 = [4, 5, 6]
@board3 = [7, 8, 9]
@board_index = [@board1, @board2, @board3]
puts "| #{@board_index [0] [0]} | #{@board_index [1] [0]} | #{@board_index [2] [0]} |"
puts "| #{@board_index [0] [1]} | #{@board_index [1] [1]} | #{@board_index [2] [1]} |"
puts "| #{@board_index [0] [2]} | #{@board_index [1] [2]} | #{@board_index [2] [2]} |"
return @board_index
end
#player turn who goes first
#player choice 1-9
#loops that will fill the chosen array position with X
def player board_new
puts "Player turn: \n
Please Select a board option 1-9"
answer_player = gets.chomp
while true
if answer_player == "1"
# key = @board_index[0][0]
# puts @board_index[0][0]
# puts key
trash = @board_index.at(0).at(0)
delete_if(trash.include?(1))
# delete.at(0).insert(0, "X")
# @board_index.insert(key, "X")
# @board_index.insert(0 0, "X")
@board1
puts "| #{@board_index [0] [0]} | #{@board_index [1] [0]} | #{@board_index [2] [0]} |"
puts "| #{@board_index [0] [1]} | #{@board_index [1] [1]} | #{@board_index [2] [1]} |"
puts "| #{@board_index [0] [2]} | #{@board_index [1] [2]} | #{@board_index [2] [2]} |"
break
elsif answer_player == "2"
elsif answer_player == "3"
elsif answer_player == "4"
elsif answer_player == "5"
elsif answer_player == "6"
elsif answer_player == "7"
elsif answer_player == "8"
elsif answer_player == "9"
else
puts "That is not a valid option"
end
end
end
#pass in updated array
#comp will randomly choose empty array position and fill it with x
def comp
end
#loop player/comp until winning conditions are met.
def menu
end
#winning conditions with 8?/ 16? winning conditions
def win_condition
end