berlin-ai 0.0.17 → 0.0.18
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.
- data/berlin-ai.gemspec +2 -12
- data/lib/ai/game.rb +5 -4
- data/lib/berlin-ai.rb +3 -0
- data/lib/version.rb +1 -1
- metadata +7 -13
data/berlin-ai.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
lib = File.expand_path('../lib/', __FILE__)
|
3
3
|
$:.unshift lib unless $:.include?(lib)
|
4
4
|
|
5
|
-
require 'lib/version'
|
5
|
+
require './lib/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "berlin-ai"
|
@@ -18,17 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_dependency 'yajl-ruby', '>=0.8.2'
|
19
19
|
s.add_dependency 'sinatra-reloader', '>=0.5.0'
|
20
20
|
|
21
|
-
s.files =
|
22
|
-
'LICENSE',
|
23
|
-
'README',
|
24
|
-
'berlin-ai.gemspec',
|
25
|
-
'lib/berlin-ai.rb',
|
26
|
-
'lib/version.rb',
|
27
|
-
'lib/ai/game.rb',
|
28
|
-
'lib/ai/map.rb',
|
29
|
-
'lib/ai/node.rb',
|
30
|
-
'lib/ai/player.rb',
|
31
|
-
'test/test_ai.rb']
|
21
|
+
s.files = `git ls-files`.split("\n")
|
32
22
|
|
33
23
|
s.require_paths = ['lib', 'test']
|
34
24
|
end
|
data/lib/ai/game.rb
CHANGED
@@ -2,7 +2,7 @@ module Berlin
|
|
2
2
|
module AI
|
3
3
|
# Game keeps track of current games played by the server, indexing them on their uniq id.
|
4
4
|
class Game
|
5
|
-
attr_reader :id, :map, :moves, :player_id, :number_of_players, :time_limit_per_turn
|
5
|
+
attr_reader :id, :map, :moves, :player_id, :current_turn, :number_of_players, :time_limit_per_turn
|
6
6
|
|
7
7
|
# Keep track of all current games
|
8
8
|
@@games = {}
|
@@ -50,9 +50,6 @@ module Berlin
|
|
50
50
|
# How many turns left?
|
51
51
|
@turns_left = @maximum_number_of_turns - @current_turn
|
52
52
|
|
53
|
-
# Keep track of the player moves
|
54
|
-
@moves = []
|
55
|
-
|
56
53
|
# Create the map
|
57
54
|
@map = Berlin::AI::Map.new map, infos
|
58
55
|
end
|
@@ -64,6 +61,10 @@ module Berlin
|
|
64
61
|
def update state
|
65
62
|
@map.update state
|
66
63
|
end
|
64
|
+
|
65
|
+
def clear_moves
|
66
|
+
@moves = []
|
67
|
+
end
|
67
68
|
end
|
68
69
|
end
|
69
70
|
end
|
data/lib/berlin-ai.rb
CHANGED
@@ -56,6 +56,9 @@ post '/' do
|
|
56
56
|
game = Berlin::AI::Game.create_or_update params[:action], params[:infos], params[:map], params[:state]
|
57
57
|
|
58
58
|
if ['ping', 'turn'].include? params[:action]
|
59
|
+
# Clear old moves
|
60
|
+
game.clear_moves
|
61
|
+
|
59
62
|
# Let the player decides his moves
|
60
63
|
Berlin::AI::Player.on_turn( game )
|
61
64
|
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berlin-ai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 18
|
9
|
+
version: 0.0.18
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Christian Blais
|
@@ -17,7 +16,7 @@ autorequire:
|
|
17
16
|
bindir: bin
|
18
17
|
cert_chain: []
|
19
18
|
|
20
|
-
date: 2011-
|
19
|
+
date: 2011-07-02 00:00:00 -04:00
|
21
20
|
default_executable:
|
22
21
|
dependencies:
|
23
22
|
- !ruby/object:Gem::Dependency
|
@@ -28,7 +27,6 @@ dependencies:
|
|
28
27
|
requirements:
|
29
28
|
- - ">="
|
30
29
|
- !ruby/object:Gem::Version
|
31
|
-
hash: 19
|
32
30
|
segments:
|
33
31
|
- 1
|
34
32
|
- 2
|
@@ -44,7 +42,6 @@ dependencies:
|
|
44
42
|
requirements:
|
45
43
|
- - ">="
|
46
44
|
- !ruby/object:Gem::Version
|
47
|
-
hash: 59
|
48
45
|
segments:
|
49
46
|
- 0
|
50
47
|
- 8
|
@@ -60,7 +57,6 @@ dependencies:
|
|
60
57
|
requirements:
|
61
58
|
- - ">="
|
62
59
|
- !ruby/object:Gem::Version
|
63
|
-
hash: 11
|
64
60
|
segments:
|
65
61
|
- 0
|
66
62
|
- 5
|
@@ -83,12 +79,12 @@ files:
|
|
83
79
|
- LICENSE
|
84
80
|
- README
|
85
81
|
- berlin-ai.gemspec
|
86
|
-
- lib/berlin-ai.rb
|
87
|
-
- lib/version.rb
|
88
82
|
- lib/ai/game.rb
|
89
83
|
- lib/ai/map.rb
|
90
84
|
- lib/ai/node.rb
|
91
85
|
- lib/ai/player.rb
|
86
|
+
- lib/berlin-ai.rb
|
87
|
+
- lib/version.rb
|
92
88
|
- test/test_ai.rb
|
93
89
|
has_rdoc: true
|
94
90
|
homepage: http://github.com/christianblais/berlin-ai
|
@@ -105,7 +101,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
101
|
requirements:
|
106
102
|
- - ">="
|
107
103
|
- !ruby/object:Gem::Version
|
108
|
-
hash: 3
|
109
104
|
segments:
|
110
105
|
- 0
|
111
106
|
version: "0"
|
@@ -114,14 +109,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
109
|
requirements:
|
115
110
|
- - ">="
|
116
111
|
- !ruby/object:Gem::Version
|
117
|
-
hash: 3
|
118
112
|
segments:
|
119
113
|
- 0
|
120
114
|
version: "0"
|
121
115
|
requirements: []
|
122
116
|
|
123
117
|
rubyforge_project:
|
124
|
-
rubygems_version: 1.
|
118
|
+
rubygems_version: 1.3.7
|
125
119
|
signing_key:
|
126
120
|
specification_version: 3
|
127
121
|
summary: Berlin Artificial Intelligence
|