tic_tac_toe_nhu 0.0.11 → 0.1.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/bin/tic_tac_toe +2 -2
- data/coverage/.resultset.json +52 -65
- data/lib/tic_tac_toe/board.rb +1 -1
- data/lib/tic_tac_toe/game.rb +21 -19
- data/lib/tic_tac_toe/game_factory.rb +11 -33
- data/lib/tic_tac_toe/player.rb +2 -2
- data/lib/tic_tac_toe/player_factory.rb +19 -4
- data/lib/tic_tac_toe/rules.rb +1 -1
- data/lib/tic_tac_toe/runner.rb +27 -20
- data/lib/tic_tac_toe/strategy/console_user.rb +1 -1
- data/lib/tic_tac_toe/strategy/minimax.rb +18 -16
- data/lib/tic_tac_toe/ui/console.rb +2 -2
- data/lib/tic_tac_toe/values.rb +10 -0
- data/spec/{integration → acceptance}/tictactoe/unbeatable_computer_spec.rb +8 -6
- data/spec/mocks/game.rb +2 -2
- data/spec/mocks/game_factory.rb +1 -1
- data/spec/mocks/player.rb +16 -0
- data/spec/mocks/player_factory.rb +3 -2
- data/spec/mocks/strategy/dynamic.rb +1 -1
- data/spec/tic_tac_toe/game_factory_spec.rb +31 -50
- data/spec/tic_tac_toe/game_spec.rb +53 -62
- data/spec/tic_tac_toe/player_factory_spec.rb +21 -28
- data/spec/tic_tac_toe/player_spec.rb +12 -17
- data/spec/tic_tac_toe/runner_spec.rb +49 -56
- data/spec/tic_tac_toe/strategy/console_user_spec.rb +1 -1
- data/spec/tic_tac_toe/strategy/minimax_spec.rb +65 -64
- data/spec/tic_tac_toe/ui/console_spec.rb +2 -2
- data/spec/tic_tac_toe/values_spec.rb +17 -0
- data/tic_tac_toe_nhu.gemspec +2 -1
- metadata +7 -4
- data/spec/tic_tac_toe/player_factory_mock.rb +0 -10
@@ -50,7 +50,7 @@ describe TicTacToe::Console do
|
|
50
50
|
|
51
51
|
context "reading user input for game type" do
|
52
52
|
it "displays a list of game type" do
|
53
|
-
expected_display = "1 - Human vs
|
53
|
+
expected_display = "1 - Human vs Human\n2 - Human vs Computer\n3 - Computer vs Human\n4 - Computer vs Computer"
|
54
54
|
@input.string = "1"
|
55
55
|
@console.game_type
|
56
56
|
@output.string.should match expected_display
|
@@ -79,7 +79,7 @@ describe TicTacToe::Console do
|
|
79
79
|
it "displays winner" do
|
80
80
|
player = TicTacToe::Player.new("Todd", "X", nil)
|
81
81
|
@console.display_winner(player)
|
82
|
-
@output.string.should == "Todd(X)
|
82
|
+
@output.string.should == "Todd(X) wins!\n"
|
83
83
|
end
|
84
84
|
|
85
85
|
it "display tied game" do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'tic_tac_toe/values'
|
2
|
+
|
3
|
+
describe "Values" do
|
4
|
+
VALUES = ["X", "O"]
|
5
|
+
|
6
|
+
it "has X and O values" do
|
7
|
+
TicTacToe::VALUES.should == VALUES
|
8
|
+
end
|
9
|
+
|
10
|
+
it "gets opponent for X" do
|
11
|
+
TicTacToe::Values.opponent(VALUES[0]).should == VALUES[1]
|
12
|
+
end
|
13
|
+
|
14
|
+
it "gets opponent for O" do
|
15
|
+
TicTacToe::Values.opponent(VALUES[1]).should == VALUES[0]
|
16
|
+
end
|
17
|
+
end
|
data/tic_tac_toe_nhu.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'tic_tac_toe_nhu'
|
3
|
-
s.version = '0.0
|
3
|
+
s.version = '0.1.0'
|
4
4
|
s.date = '2013-06-11'
|
5
5
|
s.summary = "Tic Tac Toe"
|
6
6
|
s.description = "A simple tic tac toe game with AI"
|
@@ -8,4 +8,5 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.email = 'nhu313@gmail.com'
|
9
9
|
s.files = `git ls-files`.split("\n")
|
10
10
|
s.homepage = 'http://rubygems.org/gems/tic_tac_toe_nhu'
|
11
|
+
s.executables << 'tic_tac_toe'
|
11
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tic_tac_toe_nhu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nhu Nguyen
|
@@ -12,7 +12,8 @@ date: 2013-06-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
13
13
|
description: A simple tic tac toe game with AI
|
14
14
|
email: nhu313@gmail.com
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- tic_tac_toe
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
@@ -39,9 +40,11 @@ files:
|
|
39
40
|
- lib/tic_tac_toe/strategy/console_user.rb
|
40
41
|
- lib/tic_tac_toe/strategy/minimax.rb
|
41
42
|
- lib/tic_tac_toe/ui/console.rb
|
42
|
-
-
|
43
|
+
- lib/tic_tac_toe/values.rb
|
44
|
+
- spec/acceptance/tictactoe/unbeatable_computer_spec.rb
|
43
45
|
- spec/mocks/game.rb
|
44
46
|
- spec/mocks/game_factory.rb
|
47
|
+
- spec/mocks/player.rb
|
45
48
|
- spec/mocks/player_factory.rb
|
46
49
|
- spec/mocks/rules.rb
|
47
50
|
- spec/mocks/strategy/dynamic.rb
|
@@ -49,7 +52,6 @@ files:
|
|
49
52
|
- spec/tic_tac_toe/board_spec.rb
|
50
53
|
- spec/tic_tac_toe/game_factory_spec.rb
|
51
54
|
- spec/tic_tac_toe/game_spec.rb
|
52
|
-
- spec/tic_tac_toe/player_factory_mock.rb
|
53
55
|
- spec/tic_tac_toe/player_factory_spec.rb
|
54
56
|
- spec/tic_tac_toe/player_spec.rb
|
55
57
|
- spec/tic_tac_toe/rules_spec.rb
|
@@ -58,6 +60,7 @@ files:
|
|
58
60
|
- spec/tic_tac_toe/strategy/console_user_spec.rb
|
59
61
|
- spec/tic_tac_toe/strategy/minimax_spec.rb
|
60
62
|
- spec/tic_tac_toe/ui/console_spec.rb
|
63
|
+
- spec/tic_tac_toe/values_spec.rb
|
61
64
|
- tic_tac_toe_nhu.gemspec
|
62
65
|
homepage: http://rubygems.org/gems/tic_tac_toe_nhu
|
63
66
|
licenses: []
|