-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHoofdstuk4.rb
More file actions
73 lines (57 loc) · 1.12 KB
/
Hoofdstuk4.rb
File metadata and controls
73 lines (57 loc) · 1.12 KB
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
class Game
attr_accessor :current_player
def initialize
@board = Board.new
@current_player = "X"
start_game
end
def start_game
while over? == false
# play(move)...
end
end
def play(move)
end
def over?
# to check verticals:
@board.rows_occupied?(@board.verticals)
end
end
class Board
def initialize
@board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
end
def get_square(n)
end
def put_square(player, n)
end
def rows_occupied?(rows)
for row in rows
if row[0] == row[1] && row[1] == row[2] && row.include?(" ") == false
return true
end
end
return false
end
def verticals
return [
[@board[0], @board[3], @board[6]],
[@board[1], @board[4], @board[7]],
[@board[2], @board[5], @board[8]]
]
end
def horizontals
end
def diagonals
end
def full?
end
def draw
output = []
for i in [0, 3, 6]
output.push(" #{@board[i]} | #{@board[i + 1]} | #{@board[i + 2]} #{i} | #{i + 1} | #{i + 2} ")
end
puts output.join("\n---|---|--- ---|---|---\n")
end
end
Game.new