connect_four_cli 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/connect_four_cli/board.rb +121 -77
- data/lib/connect_four_cli/checker.rb +4 -0
- data/lib/connect_four_cli/computer.rb +25 -0
- data/lib/connect_four_cli/game.rb +71 -0
- data/lib/connect_four_cli/renderer.rb +25 -15
- data/lib/connect_four_cli/version.rb +1 -1
- data/lib/connect_four_cli.rb +8 -1
- data/tags +29 -9
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e383eeebc386889101e48df138e30282065b0a4f
|
4
|
+
data.tar.gz: 80990019b62309eddfab5db83dd44c73c249ee0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc6dac5c95180cf7320a402e8af6a3f304aa7dd59f2908adb2aec14fc963bfadbddc6ffbc4c3fd2a39365d0ff9daf047dfa0ab0806687ceaaafc5033cfac6307
|
7
|
+
data.tar.gz: de8a70dbdce4a128e5c56674f45fef15d8c932848ebd92fb1044e825770b14c9c5ba9c63b2e4669e96aa4e206155dfbff4929611ae75203b9496f723d9788525
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module ConnectFourCli
|
2
2
|
class Board
|
3
|
-
attr_reader :size, :grid
|
3
|
+
attr_reader :size, :grid
|
4
4
|
|
5
5
|
def initialize(size)
|
6
6
|
@size = size
|
7
|
-
@turn = :red
|
8
7
|
build_grid
|
9
8
|
end
|
10
9
|
|
@@ -12,26 +11,6 @@ module ConnectFourCli
|
|
12
11
|
@grid = Array.new(size) { Array.new(size) { NoChecker.new } }
|
13
12
|
end
|
14
13
|
|
15
|
-
def next_turn
|
16
|
-
if @winner
|
17
|
-
@turn = @winner
|
18
|
-
else
|
19
|
-
@turn = (@turn == :red ? :yellow : :red)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def place_turn_checker(position)
|
24
|
-
return if column_full?(position)
|
25
|
-
checker = Checker.new(@turn)
|
26
|
-
place_checker(checker, at: position)
|
27
|
-
next_turn
|
28
|
-
end
|
29
|
-
|
30
|
-
def place_checker(checker, at:)
|
31
|
-
row = free_position(at)
|
32
|
-
grid[row][at] = checker
|
33
|
-
end
|
34
|
-
|
35
14
|
def column_full?(number)
|
36
15
|
column_count(number) == 6
|
37
16
|
end
|
@@ -45,22 +24,18 @@ module ConnectFourCli
|
|
45
24
|
end
|
46
25
|
|
47
26
|
def red_locations
|
48
|
-
|
49
|
-
grid.transpose.each_with_index do |row, y|
|
50
|
-
row.each_with_index do |checker, x|
|
51
|
-
if checker.color == :red
|
52
|
-
output << [x,y]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
output
|
27
|
+
locations_for(:red)
|
57
28
|
end
|
58
29
|
|
59
30
|
def yellow_locations
|
31
|
+
locations_for(:yellow)
|
32
|
+
end
|
33
|
+
|
34
|
+
def locations_for(color)
|
60
35
|
output = []
|
61
36
|
grid.transpose.each_with_index do |row, y|
|
62
37
|
row.each_with_index do |checker, x|
|
63
|
-
if checker.color ==
|
38
|
+
if checker.color == color
|
64
39
|
output << [x,y]
|
65
40
|
end
|
66
41
|
end
|
@@ -68,7 +43,6 @@ module ConnectFourCli
|
|
68
43
|
output
|
69
44
|
end
|
70
45
|
|
71
|
-
|
72
46
|
def column(number)
|
73
47
|
grid.transpose[number]
|
74
48
|
end
|
@@ -82,20 +56,13 @@ module ConnectFourCli
|
|
82
56
|
end
|
83
57
|
output << line
|
84
58
|
end
|
85
|
-
output.transpose.map{ |row| row.join(" ")}.join("\n")
|
86
|
-
"\n " + game_state
|
87
|
-
end
|
88
|
-
|
89
|
-
def red_four_in_a_row?
|
90
|
-
return true if each_row(:red)
|
91
|
-
return true if each_col(:red)
|
92
|
-
return true if each_diag(:red)
|
59
|
+
output.transpose.map{ |row| row.join(" ")}.join("\n")
|
93
60
|
end
|
94
61
|
|
95
|
-
def
|
96
|
-
|
97
|
-
|
98
|
-
|
62
|
+
def four_in_a_row?(color)
|
63
|
+
if each_row(color) || each_col(color) || each_diag(color)
|
64
|
+
return true
|
65
|
+
end
|
99
66
|
end
|
100
67
|
|
101
68
|
def each_col(color)
|
@@ -107,33 +74,113 @@ module ConnectFourCli
|
|
107
74
|
false
|
108
75
|
end
|
109
76
|
|
110
|
-
def
|
111
|
-
|
112
|
-
|
113
|
-
|
77
|
+
def terrible_moves
|
78
|
+
moves = []
|
79
|
+
possible_moves.each do |possible_move|
|
80
|
+
all_directions_from(1,possible_move.reverse).each do |ray|
|
81
|
+
if ray.all? { |checker| checker.checker? && checker.color == :yellow }
|
82
|
+
moves << possible_move
|
83
|
+
end
|
114
84
|
end
|
115
|
-
|
116
|
-
|
85
|
+
end
|
86
|
+
moves
|
87
|
+
end
|
88
|
+
|
89
|
+
def decent_moves
|
90
|
+
moves = []
|
91
|
+
possible_moves.each do |possible_move|
|
92
|
+
all_directions_from(2,possible_move.reverse).each do |ray|
|
93
|
+
if ray.all? { |checker| checker.checker? && checker.color == :yellow }
|
94
|
+
moves << possible_move
|
95
|
+
end
|
117
96
|
end
|
118
97
|
end
|
119
|
-
|
98
|
+
moves
|
120
99
|
end
|
121
100
|
|
122
|
-
def
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
101
|
+
def winning_moves
|
102
|
+
moves = []
|
103
|
+
possible_moves.each do |possible_move|
|
104
|
+
all_directions_from(3,possible_move.reverse).each do |ray|
|
105
|
+
color = ray[0].color
|
106
|
+
if ray.all? { |checker| checker.checker? && checker.color == color }
|
107
|
+
moves << possible_move
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
moves
|
112
|
+
end
|
113
|
+
|
114
|
+
def all_directions_from(distance, coord)
|
115
|
+
directions = []
|
116
|
+
[:+,:-].repeated_permutation(2) do |first, second|
|
117
|
+
direction = []
|
118
|
+
x, y = coord
|
119
|
+
distance.times do
|
120
|
+
x = x.send(first, 1)
|
121
|
+
y = y.send(second, 1)
|
122
|
+
next if x > 5 || x < 0 || y > 6 || y < 0
|
123
|
+
direction << [x,y]
|
124
|
+
end
|
125
|
+
directions << direction
|
126
|
+
|
127
|
+
x, y = coord
|
128
|
+
directionx = []
|
129
|
+
directiony = []
|
130
|
+
distance.times do
|
131
|
+
x = x.send(first, 1)
|
132
|
+
y = y.send(second, 1)
|
133
|
+
directionx << [x,coord[1]] unless x > 5 || x < 0
|
134
|
+
directiony << [coord[0], y] unless y > 5 || y < 0
|
135
|
+
end
|
136
|
+
directions << directiony
|
137
|
+
directions << directionx
|
138
|
+
end
|
139
|
+
directions = directions.reject { |direction| direction.length < distance}.uniq
|
127
140
|
|
128
|
-
|
129
|
-
|
141
|
+
directions.map do |direction|
|
142
|
+
direction.map do |x,y|
|
143
|
+
grid[x][y]
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
130
147
|
|
131
|
-
|
132
|
-
|
148
|
+
def possible_moves
|
149
|
+
(0...size).map do |row|
|
150
|
+
position = free_position(row)
|
151
|
+
[row, position] unless column_full?(row)
|
152
|
+
end.compact
|
153
|
+
end
|
133
154
|
|
134
|
-
|
135
|
-
|
136
|
-
|
155
|
+
def each_diag(color)
|
156
|
+
all_diagonals.each do |diagonal|
|
157
|
+
diagonal.each_cons(4) do |winning_diag|
|
158
|
+
return true if winning_diag.all? do |x, y|
|
159
|
+
grid[x][y].color == color
|
160
|
+
end
|
161
|
+
return true if winning_diag.all? do |x, y|
|
162
|
+
grid[y][5-x].color == color
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
false
|
167
|
+
end
|
168
|
+
|
169
|
+
def all_diagonals
|
170
|
+
diagonals = []
|
171
|
+
(grid.length).times do |i|
|
172
|
+
x = i
|
173
|
+
y = 0
|
174
|
+
set = []
|
175
|
+
until x == grid.length || y == grid.length
|
176
|
+
set << [x, y]
|
177
|
+
x += 1
|
178
|
+
y += 1
|
179
|
+
end
|
180
|
+
diagonals << set
|
181
|
+
end
|
182
|
+
|
183
|
+
diagonals.map { |diag| [diag, diag.map(&:reverse) ] }.flatten(1).uniq.select { |diag| diag.length >= 4}
|
137
184
|
end
|
138
185
|
|
139
186
|
def each_row(color)
|
@@ -145,19 +192,16 @@ module ConnectFourCli
|
|
145
192
|
false
|
146
193
|
end
|
147
194
|
|
148
|
-
def
|
149
|
-
|
150
|
-
if yellow_four_in_a_row?
|
151
|
-
@winner = :yellow
|
152
|
-
@turn = :yellow
|
153
|
-
"Yellow wins! Press q to quit."
|
154
|
-
elsif red_four_in_a_row?
|
155
|
-
@winner = :red
|
156
|
-
@turn = :red
|
157
|
-
"Red wins! Press q to quit."
|
158
|
-
else
|
159
|
-
"#{@turn.capitalize}'s turn."
|
160
|
-
end
|
195
|
+
def full?
|
196
|
+
@grid.flatten.all?(&:checker?)
|
161
197
|
end
|
198
|
+
|
199
|
+
def place_checker(checker, at:)
|
200
|
+
return false if column_full?(at)
|
201
|
+
row = free_position(at)
|
202
|
+
grid[row][at] = checker
|
203
|
+
true
|
204
|
+
end
|
205
|
+
|
162
206
|
end
|
163
207
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ConnectFourCli
|
2
|
+
class Computer
|
3
|
+
attr_reader :board, :checker
|
4
|
+
|
5
|
+
def initialize(board)
|
6
|
+
@board = board
|
7
|
+
@checker = Checker.new(:yellow)
|
8
|
+
end
|
9
|
+
|
10
|
+
def random_move
|
11
|
+
(0...board.size).map do |i|
|
12
|
+
board.column_full?(i) ? nil : i
|
13
|
+
end.compact.sample
|
14
|
+
end
|
15
|
+
|
16
|
+
def make_move
|
17
|
+
if board.winning_moves.length > 0
|
18
|
+
move = board.winning_moves.sample[0]
|
19
|
+
else
|
20
|
+
move = random_move
|
21
|
+
end
|
22
|
+
board.place_checker(checker, at: move)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module ConnectFourCli
|
2
|
+
class Game
|
3
|
+
attr_reader :board, :turn, :winner
|
4
|
+
|
5
|
+
def initialize(size, computer = false)
|
6
|
+
@turn = :red
|
7
|
+
@board = Board.new(size)
|
8
|
+
@computer = Computer.new(board) if computer
|
9
|
+
end
|
10
|
+
|
11
|
+
def next_turn
|
12
|
+
if @winner
|
13
|
+
@turn = @winner
|
14
|
+
else
|
15
|
+
@turn = (@turn == :red ? :yellow : :red)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def computer_move
|
20
|
+
@computer.make_move
|
21
|
+
next_turn
|
22
|
+
end
|
23
|
+
|
24
|
+
def computer_turn?
|
25
|
+
!!@computer && @turn == :yellow
|
26
|
+
end
|
27
|
+
|
28
|
+
def place_turn_checker(position)
|
29
|
+
checker = Checker.new(@turn)
|
30
|
+
if board.place_checker(checker, at: position)
|
31
|
+
next_turn
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def red_locations
|
36
|
+
board.red_locations
|
37
|
+
end
|
38
|
+
|
39
|
+
def yellow_locations
|
40
|
+
board.yellow_locations
|
41
|
+
end
|
42
|
+
|
43
|
+
def display
|
44
|
+
output = []
|
45
|
+
output << board.display
|
46
|
+
output << game_state
|
47
|
+
output.join("\n\n")
|
48
|
+
end
|
49
|
+
|
50
|
+
def game_state
|
51
|
+
if board.four_in_a_row?(:yellow)
|
52
|
+
@winner = :yellow
|
53
|
+
@turn = :yellow
|
54
|
+
"Yellow wins! Press q to quit."
|
55
|
+
elsif board.four_in_a_row?(:red)
|
56
|
+
@winner = :red
|
57
|
+
@turn = :red
|
58
|
+
"Red wins! Press q to quit."
|
59
|
+
elsif board.full?
|
60
|
+
@winner = :draw
|
61
|
+
"It's a draw! Press q to quit"
|
62
|
+
else
|
63
|
+
if computer_turn?
|
64
|
+
"Computer's turn."
|
65
|
+
else
|
66
|
+
"#{@turn.capitalize}'s turn."
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -10,36 +10,37 @@ module ConnectFourCli
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.highlight_column(
|
13
|
+
def self.highlight_column(game, column)
|
14
14
|
map = Dispel::StyleMap.new(6) # number of lines
|
15
|
-
|
16
|
-
|
15
|
+
unless game.computer_turn?
|
16
|
+
(0..5).each do |row|
|
17
|
+
map.add(turn_color(game.turn), row, column..column)
|
18
|
+
map.add(turn_color(game.turn), 0, column..column)
|
19
|
+
end
|
17
20
|
end
|
18
|
-
|
21
|
+
game.red_locations.each do |location|
|
19
22
|
map.add(["#ff0000", "#000000"], location[0], location[1]*2..location[1]*2 + 1)
|
20
23
|
end
|
21
|
-
|
24
|
+
game.yellow_locations.each do |location|
|
22
25
|
map.add(["#ffff00", "#000000"], location[0], location[1]*2..location[1]*2 + 1)
|
23
26
|
end
|
24
|
-
map.add(turn_color(board.turn), 0, column..column)
|
25
27
|
map
|
26
28
|
end
|
27
29
|
|
28
|
-
def self.start
|
30
|
+
def self.start(game)
|
29
31
|
::Dispel::Screen.open(colors: true) do |screen|
|
30
32
|
Curses.curs_set 0
|
31
33
|
|
32
|
-
|
33
|
-
content = board.display
|
34
|
+
content = game.display
|
34
35
|
|
35
36
|
x = 0
|
36
37
|
y = 0
|
37
38
|
|
38
|
-
map = self.highlight_column(
|
39
|
+
map = self.highlight_column(game, x)
|
39
40
|
screen.draw content, map, [y,x]
|
40
41
|
|
41
|
-
Dispel::Keyboard.output do |key|
|
42
|
-
if
|
42
|
+
Dispel::Keyboard.output timeout: 0.5 do |key|
|
43
|
+
if game.winner
|
43
44
|
Dispel::Keyboard.output do |key|
|
44
45
|
case key
|
45
46
|
when "q" then break
|
@@ -48,6 +49,14 @@ module ConnectFourCli
|
|
48
49
|
break
|
49
50
|
end
|
50
51
|
|
52
|
+
if game.computer_turn?
|
53
|
+
sleep 0.5
|
54
|
+
game.computer_move
|
55
|
+
map = self.highlight_column(game, x)
|
56
|
+
content = game.display
|
57
|
+
screen.draw content, map, [y,x]
|
58
|
+
end
|
59
|
+
|
51
60
|
case key
|
52
61
|
when :right
|
53
62
|
next if x + 2 >= 12
|
@@ -56,13 +65,14 @@ module ConnectFourCli
|
|
56
65
|
next if x - 2 < 0
|
57
66
|
x-= 2
|
58
67
|
when " "
|
59
|
-
|
68
|
+
game.place_turn_checker(x / 2)
|
60
69
|
when "q" then break
|
61
70
|
|
62
71
|
end
|
63
|
-
map = self.highlight_column(
|
64
|
-
content =
|
72
|
+
map = self.highlight_column(game, x)
|
73
|
+
content = game.display
|
65
74
|
screen.draw content, map, [y,x]
|
75
|
+
|
66
76
|
end
|
67
77
|
end
|
68
78
|
end
|
data/lib/connect_four_cli.rb
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
require "connect_four_cli/version"
|
2
2
|
require "connect_four_cli/checker"
|
3
|
+
require "connect_four_cli/game"
|
3
4
|
require "connect_four_cli/board"
|
5
|
+
require "connect_four_cli/computer"
|
4
6
|
require "connect_four_cli/renderer"
|
5
7
|
|
6
8
|
module ConnectFourCli
|
7
9
|
def self.start
|
8
|
-
|
10
|
+
if ARGV[0] == "--two" || ARGV[0] == "-2"
|
11
|
+
game = Game.new(6)
|
12
|
+
else
|
13
|
+
game = Game.new(6, true)
|
14
|
+
end
|
15
|
+
Renderer.start(game)
|
9
16
|
end
|
10
17
|
end
|
data/tags
CHANGED
@@ -5,15 +5,22 @@
|
|
5
5
|
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
6
6
|
!_TAG_PROGRAM_VERSION 5.8 //
|
7
7
|
== /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/checker.rb /^ def ==(other_checker)$/;" f class:ConnectFourCli.Checker
|
8
|
+
== /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/checker.rb /^ def ==(other_checker)$/;" f class:ConnectFourCli.NoChecker
|
8
9
|
Board /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ class Board$/;" c class:ConnectFourCli
|
9
10
|
Checker /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/checker.rb /^class Checker$/;" c class:ConnectFourCli
|
11
|
+
Computer /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/computer.rb /^ class Computer$/;" c class:ConnectFourCli
|
10
12
|
ConnectFourCli /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli.rb /^module ConnectFourCli$/;" m
|
11
13
|
ConnectFourCli /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^module ConnectFourCli$/;" m
|
12
14
|
ConnectFourCli /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/checker.rb /^module ConnectFourCli$/;" m
|
15
|
+
ConnectFourCli /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/computer.rb /^module ConnectFourCli$/;" m
|
16
|
+
ConnectFourCli /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^module ConnectFourCli$/;" m
|
13
17
|
ConnectFourCli /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/renderer.rb /^module ConnectFourCli$/;" m
|
14
18
|
ConnectFourCli /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/version.rb /^module ConnectFourCli$/;" m
|
19
|
+
Game /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^ class Game$/;" c class:ConnectFourCli
|
15
20
|
NoChecker /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/checker.rb /^class NoChecker < Checker$/;" c class:ConnectFourCli
|
16
21
|
Renderer /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/renderer.rb /^ class Renderer$/;" c class:ConnectFourCli
|
22
|
+
all_diagonals /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def all_diagonals$/;" f class:ConnectFourCli.Board.possible_moves
|
23
|
+
all_directions_from /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def all_directions_from(distance, coord)$/;" f class:ConnectFourCli.Board
|
17
24
|
build_board /Users/kitlangton/Viking/Unit4/connect_four_cli/spec/connect_four_cli/board_spec.rb /^ def build_board$/;" f
|
18
25
|
build_grid /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def build_grid$/;" f class:ConnectFourCli.Board
|
19
26
|
checker? /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/checker.rb /^ def checker?$/;" f class:ConnectFourCli.Checker
|
@@ -21,30 +28,43 @@ checker? /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/ch
|
|
21
28
|
column /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def column(number)$/;" f class:ConnectFourCli.Board
|
22
29
|
column_count /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def column_count(number)$/;" f class:ConnectFourCli.Board
|
23
30
|
column_full? /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def column_full?(number)$/;" f class:ConnectFourCli.Board
|
24
|
-
|
31
|
+
computer_move /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^ def computer_move$/;" f class:ConnectFourCli.Game
|
32
|
+
computer_turn? /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^ def computer_turn?$/;" f class:ConnectFourCli.Game
|
33
|
+
decent_moves /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def decent_moves$/;" f class:ConnectFourCli.Board
|
25
34
|
display /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def display$/;" f class:ConnectFourCli.Board
|
26
35
|
display /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/checker.rb /^ def display$/;" f class:ConnectFourCli.Checker
|
27
36
|
display /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/checker.rb /^ def display$/;" f class:ConnectFourCli.NoChecker
|
37
|
+
display /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^ def display$/;" f class:ConnectFourCli.Game
|
28
38
|
each_col /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def each_col(color)$/;" f class:ConnectFourCli.Board
|
29
|
-
each_diag /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def each_diag(color)$/;" f class:ConnectFourCli.Board
|
39
|
+
each_diag /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def each_diag(color)$/;" f class:ConnectFourCli.Board.possible_moves
|
30
40
|
each_row /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def each_row(color)$/;" f class:ConnectFourCli.Board
|
41
|
+
four_in_a_row? /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def four_in_a_row?(color)$/;" f class:ConnectFourCli.Board
|
31
42
|
free_position /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def free_position(number)$/;" f class:ConnectFourCli.Board
|
32
|
-
|
33
|
-
|
43
|
+
full? /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def full?$/;" f class:ConnectFourCli.Board
|
44
|
+
game_state /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^ def game_state$/;" f class:ConnectFourCli.Game
|
45
|
+
highlight_column /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/renderer.rb /^ def self.highlight_column(game, column)$/;" F class:ConnectFourCli.Renderer
|
34
46
|
initialize /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def initialize(size)$/;" f class:ConnectFourCli.Board
|
35
47
|
initialize /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/checker.rb /^ def initialize$/;" f class:ConnectFourCli.NoChecker
|
36
48
|
initialize /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/checker.rb /^ def initialize(color)$/;" f class:ConnectFourCli.Checker
|
37
|
-
|
49
|
+
initialize /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/computer.rb /^ def initialize(board)$/;" f class:ConnectFourCli.Computer
|
50
|
+
initialize /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^ def initialize(size, computer = false)$/;" f class:ConnectFourCli.Game
|
51
|
+
locations_for /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def locations_for(color)$/;" f class:ConnectFourCli.Board
|
52
|
+
make_move /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/computer.rb /^ def make_move$/;" f class:ConnectFourCli.Computer.random_move
|
53
|
+
next_turn /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^ def next_turn$/;" f class:ConnectFourCli.Game
|
38
54
|
place_checker /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def place_checker(checker, at:)$/;" f class:ConnectFourCli.Board
|
39
|
-
place_turn_checker /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/
|
55
|
+
place_turn_checker /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^ def place_turn_checker(position)$/;" f class:ConnectFourCli.Game
|
56
|
+
possible_moves /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def possible_moves$/;" f class:ConnectFourCli.Board
|
57
|
+
random_move /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/computer.rb /^ def random_move$/;" f class:ConnectFourCli.Computer
|
40
58
|
red_checker /Users/kitlangton/Viking/Unit4/connect_four_cli/spec/connect_four_cli/board_spec.rb /^ def red_checker$/;" f
|
41
59
|
red_checker /Users/kitlangton/Viking/Unit4/connect_four_cli/spec/connect_four_cli/checker_spec.rb /^ def red_checker$/;" f
|
42
|
-
red_four_in_a_row? /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def red_four_in_a_row?$/;" f class:ConnectFourCli.Board
|
43
60
|
red_locations /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def red_locations$/;" f class:ConnectFourCli.Board
|
61
|
+
red_locations /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^ def red_locations$/;" f class:ConnectFourCli.Game
|
44
62
|
start /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli.rb /^ def self.start$/;" F class:ConnectFourCli
|
45
|
-
start /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/renderer.rb /^ def self.start$/;" F class:ConnectFourCli.Renderer
|
63
|
+
start /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/renderer.rb /^ def self.start(game)$/;" F class:ConnectFourCli.Renderer
|
64
|
+
terrible_moves /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def terrible_moves$/;" f class:ConnectFourCli.Board
|
46
65
|
turn_color /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/renderer.rb /^ def self.turn_color(turn)$/;" F class:ConnectFourCli.Renderer
|
66
|
+
winning_moves /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def winning_moves$/;" f class:ConnectFourCli.Board
|
47
67
|
yellow_checker /Users/kitlangton/Viking/Unit4/connect_four_cli/spec/connect_four_cli/board_spec.rb /^ def yellow_checker$/;" f
|
48
68
|
yellow_checker /Users/kitlangton/Viking/Unit4/connect_four_cli/spec/connect_four_cli/checker_spec.rb /^ def yellow_checker$/;" f
|
49
|
-
yellow_four_in_a_row? /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def yellow_four_in_a_row?$/;" f class:ConnectFourCli.Board
|
50
69
|
yellow_locations /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/board.rb /^ def yellow_locations$/;" f class:ConnectFourCli.Board
|
70
|
+
yellow_locations /Users/kitlangton/Viking/Unit4/connect_four_cli/lib/connect_four_cli/game.rb /^ def yellow_locations$/;" f class:ConnectFourCli.Game
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: connect_four_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kit Langton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,6 +117,8 @@ files:
|
|
117
117
|
- lib/connect_four_cli.rb
|
118
118
|
- lib/connect_four_cli/board.rb
|
119
119
|
- lib/connect_four_cli/checker.rb
|
120
|
+
- lib/connect_four_cli/computer.rb
|
121
|
+
- lib/connect_four_cli/game.rb
|
120
122
|
- lib/connect_four_cli/renderer.rb
|
121
123
|
- lib/connect_four_cli/version.rb
|
122
124
|
- tags
|