ttt_gem_8thlight 0.0.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ttt/ai/unbeatable_ai.rb +3 -2
- data/spec/game_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1625205d2bc9baf4691081f008f67d70cd16ebbf
|
4
|
+
data.tar.gz: 8dfc22e281888841f64416521741623df4f3b75d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5e0f74353940d7dd15024e6a043196a7e39357c96454ee915eee3bc51d085ca62775ef22f5dd4e4d7e06bc434b3c98fd714556c10e187e497575a2f857c7954
|
7
|
+
data.tar.gz: e36fb8446d906b0662acbd76873130563105b935be965425ec44663ddfb1eec8514f5c9495fc9692a5d407b331340d7eeb38baa6e32a14dda4aaf3e7c37e5c1f
|
data/lib/ttt/ai/unbeatable_ai.rb
CHANGED
@@ -30,15 +30,16 @@ module TicTacToe
|
|
30
30
|
if max_player
|
31
31
|
board.empty_spaces.each do |spaces|
|
32
32
|
board.place_move(mark, spaces)
|
33
|
-
score_min = [score_min, minimax(board, opponent_mark, depth + 1,
|
33
|
+
score_min = [score_min, minimax(board, opponent_mark, depth + 1, score_min, score_max, !(max_player), -color)].max
|
34
34
|
board.undo_move(spaces)
|
35
35
|
break if score_min >= score_max
|
36
36
|
end
|
37
37
|
return score_min
|
38
38
|
else
|
39
|
+
|
39
40
|
board.empty_spaces.each do |spaces|
|
40
41
|
board.place_move(mark, spaces)
|
41
|
-
score_max = [score_max, minimax(board, opponent_mark, depth + 1,
|
42
|
+
score_max = [score_max, minimax(board, opponent_mark, depth + 1, score_min, score_max, !(max_player), -color)].min
|
42
43
|
board.undo_move(spaces)
|
43
44
|
break if score_min >= score_max
|
44
45
|
end
|
data/spec/game_spec.rb
CHANGED
@@ -221,7 +221,7 @@ describe TicTacToe::Game do
|
|
221
221
|
config[:player_two] = :ai
|
222
222
|
config[:game_board] = "12X456789"
|
223
223
|
new_game = described_class.play_game(ui, config)
|
224
|
-
new_game.board.to_s.should == "
|
224
|
+
new_game.board.to_s.should == "12X4O6789"
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ttt_gem_8thlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Meagan Waller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|