berlin-ai 0.0.37 → 0.0.38

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjhmMTFhMzAxZTcyYWY5NTQ0NjUwODE0ZGRlYmU5YzJhMTdjNzhiMQ==
5
+ data.tar.gz: !binary |-
6
+ NTM4MTYxM2FlOTM2YTNlMDljNTlkYTk3MmNkOGQ1Zjg1ZGExOGNlZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OTAxMTc4YjdjYjA3YzdmOGEzOTQ2MzU3MGYyM2QxMmY4ZTY0YTIxYTVhMGQ1
10
+ NDdhY2I5ZWY0MDZlMTQ3NzE3MzM3ZWY1Y2FmNDhlM2E4MjFhZTNiMTJjN2My
11
+ ZjAxYmU5NWM0ZWVmOTg3OTQyN2IyMmQ0NTQ5NmFhNDFiZmY1ZTU=
12
+ data.tar.gz: !binary |-
13
+ MTNmYjljODRkODA5OTdkOGI1NTFlNTE0NjAwZjhhMDc5YzhkMzNiMWI1NGY0
14
+ MjZmZmRhZmE2MThkZWRkNzg1N2FmYzEyYTI3OWNiMDIzZDk0MmE3NTIwNThj
15
+ MGQyYzBlYjFhZjExZjNjYjQ5ZTFlNGFmYmFmYTY3MWU5NDNlMjM=
data/CHANGELOG ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ #### Version 0.38
4
+
5
+ *Only few changes in this version. `node.owned?` was change to be more in line with `map.owned_nodes`, plus a few bug fixes.*
6
+
7
+ * `node.owned?` used to return true if owned by any player. It's now an alias of `node.mine?`, which return true if you personnaly own the node.
8
+ * `node.foreign?` has been added. Returns true if you don't own the node.
9
+ * Creation of this file, CHANGELOG.
10
+ * Few bug fixes.
11
+
12
+ #### Version 0.37
13
+
14
+ *Few helper methods. Nothing more.*
15
+
16
+ * `node.enemy?` has been added. Returns true if owned by another player.
17
+ * Few bug fixes.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- berlin-ai (0.0.33)
4
+ berlin-ai (0.0.37)
5
5
  rainbow (~> 1.1.4)
6
6
  sinatra (= 1.4.3)
7
7
  sinatra-contrib (= 1.4.1)
@@ -11,7 +11,7 @@ PATH
11
11
  GEM
12
12
  remote: http://www.rubygems.org/
13
13
  specs:
14
- backports (3.3.3)
14
+ backports (3.3.4)
15
15
  coderay (1.0.9)
16
16
  daemons (1.1.9)
17
17
  eventmachine (1.0.3)
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Berlin-Ai is a gem to quickly ramp up on the [Berlin](http://www.berlin-ai.com) game.
4
4
 
5
+ ## Changelog
6
+
7
+ [See changelog for recent changes](https://github.com/thirdside/berlin-ai/blob/master/LICENSE)
8
+
5
9
  ## Usage
6
10
 
7
11
  Create your AI in a simple `.rb` file:
data/lib/ai/map.rb CHANGED
@@ -30,7 +30,7 @@ module Berlin
30
30
 
31
31
  # Returns an array of all nodes that we don't owned
32
32
  def foreign_nodes
33
- nodes.reject{ |n| n.mine? }
33
+ nodes.select{ |n| n.foreign? }
34
34
  end
35
35
 
36
36
  # We can now loop on our owned nodes in order to find our controlled nodes.
data/lib/ai/node.rb CHANGED
@@ -19,24 +19,25 @@ module Berlin
19
19
  @number_of_soldiers > 0
20
20
  end
21
21
 
22
- # Returns true if owned by any player
23
- def owned?
24
- !!@player_id
25
- end
26
-
27
22
  # Returns true if yours
28
23
  def mine?
29
24
  owned_by?(@map.player_id)
30
25
  end
26
+ alias_method :owned?, :mine?
31
27
 
32
28
  # Returns true if owned by somebody else than you
33
29
  def enemy?
34
- owned? && !mine?
30
+ !free? && !mine?
31
+ end
32
+
33
+ # Returns true if owned by somebody else than you
34
+ def foreign?
35
+ !mine?
35
36
  end
36
37
 
37
38
  # Returns true if no one on the node
38
39
  def free?
39
- !owned?
40
+ @player_id.nil?
40
41
  end
41
42
 
42
43
  # Returns true if node owned by provided player id
data/lib/version.rb CHANGED
@@ -2,7 +2,7 @@ module Berlin
2
2
  module AI
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- BUILD = 37
5
+ BUILD = 38
6
6
 
7
7
  VERSION = "#{MAJOR}.#{MINOR}.#{BUILD}"
8
8
  end
data/test/node_test.rb CHANGED
@@ -4,6 +4,8 @@ require_relative '../lib/ai/node'
4
4
  require "test/unit"
5
5
 
6
6
  class NodeTest < Test::Unit::TestCase
7
+
8
+ Struct.new('Map', :player_id)
7
9
 
8
10
  def test_equals_returns_true_if_two_nodes_have_the_same_id
9
11
  node1 = Berlin::AI::Node.new(:id => 1)
@@ -56,37 +58,44 @@ class NodeTest < Test::Unit::TestCase
56
58
  assert !node.free?
57
59
  end
58
60
 
59
- def test_owned_by_returns_true_if_owned_by_the_provided_player
61
+ def test_foreign_returns_true_you_do_not_own_the_node
60
62
  node = Berlin::AI::Node.new
61
63
 
62
- assert !node.owned_by?(1)
64
+ node.map = Struct::Map.new(1)
65
+
66
+ assert node.foreign?
63
67
 
64
68
  node.player_id = 1
65
69
 
66
- assert node.owned_by?(1)
70
+ assert !node.foreign?
71
+
72
+ node.player_id = 2
73
+
74
+ assert node.foreign?
67
75
  end
68
76
 
69
- def test_owned_returns_true_if_owned_by_a_player
77
+ def test_owned_by_returns_true_if_owned_by_the_provided_player
70
78
  node = Berlin::AI::Node.new
71
79
 
72
- assert !node.owned?
80
+ assert !node.owned_by?(1)
73
81
 
74
82
  node.player_id = 1
75
83
 
76
- assert node.owned?
84
+ assert node.owned_by?(1)
77
85
  end
78
86
 
79
87
  def test_mine_returns_true_if_owned_by_current_player
80
- Struct.new('Map', :player_id)
81
88
  node = Berlin::AI::Node.new
82
89
 
83
90
  node.map = Struct::Map.new(1)
84
91
 
85
92
  assert !node.mine?
93
+ assert !node.owned?
86
94
 
87
95
  node.player_id = 1
88
96
 
89
97
  assert node.mine?
98
+ assert node.owned?
90
99
  end
91
100
 
92
101
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berlin-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.37
5
- prerelease:
4
+ version: 0.0.38
6
5
  platform: ruby
7
6
  authors:
8
7
  - Christian Blais
@@ -11,12 +10,11 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2013-09-17 00:00:00.000000000 Z
13
+ date: 2013-10-04 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: sinatra
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
19
  - - '='
22
20
  - !ruby/object:Gem::Version
@@ -24,7 +22,6 @@ dependencies:
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
26
  - - '='
30
27
  - !ruby/object:Gem::Version
@@ -32,7 +29,6 @@ dependencies:
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: yajl-ruby
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
33
  - - '='
38
34
  - !ruby/object:Gem::Version
@@ -40,7 +36,6 @@ dependencies:
40
36
  type: :runtime
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
40
  - - '='
46
41
  - !ruby/object:Gem::Version
@@ -48,7 +43,6 @@ dependencies:
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: sinatra-contrib
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
47
  - - '='
54
48
  - !ruby/object:Gem::Version
@@ -56,7 +50,6 @@ dependencies:
56
50
  type: :runtime
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
54
  - - '='
62
55
  - !ruby/object:Gem::Version
@@ -64,7 +57,6 @@ dependencies:
64
57
  - !ruby/object:Gem::Dependency
65
58
  name: rainbow
66
59
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
60
  requirements:
69
61
  - - ~>
70
62
  - !ruby/object:Gem::Version
@@ -72,7 +64,6 @@ dependencies:
72
64
  type: :runtime
73
65
  prerelease: false
74
66
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
67
  requirements:
77
68
  - - ~>
78
69
  - !ruby/object:Gem::Version
@@ -80,7 +71,6 @@ dependencies:
80
71
  - !ruby/object:Gem::Dependency
81
72
  name: thin
82
73
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
74
  requirements:
85
75
  - - '='
86
76
  - !ruby/object:Gem::Version
@@ -88,7 +78,6 @@ dependencies:
88
78
  type: :runtime
89
79
  prerelease: false
90
80
  version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
81
  requirements:
93
82
  - - '='
94
83
  - !ruby/object:Gem::Version
@@ -96,7 +85,6 @@ dependencies:
96
85
  - !ruby/object:Gem::Dependency
97
86
  name: minitest
98
87
  requirement: !ruby/object:Gem::Requirement
99
- none: false
100
88
  requirements:
101
89
  - - ! '>='
102
90
  - !ruby/object:Gem::Version
@@ -104,7 +92,6 @@ dependencies:
104
92
  type: :development
105
93
  prerelease: false
106
94
  version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
95
  requirements:
109
96
  - - ! '>='
110
97
  - !ruby/object:Gem::Version
@@ -112,7 +99,6 @@ dependencies:
112
99
  - !ruby/object:Gem::Dependency
113
100
  name: pry
114
101
  requirement: !ruby/object:Gem::Requirement
115
- none: false
116
102
  requirements:
117
103
  - - ! '>='
118
104
  - !ruby/object:Gem::Version
@@ -120,7 +106,6 @@ dependencies:
120
106
  type: :development
121
107
  prerelease: false
122
108
  version_requirements: !ruby/object:Gem::Requirement
123
- none: false
124
109
  requirements:
125
110
  - - ! '>='
126
111
  - !ruby/object:Gem::Version
@@ -135,6 +120,7 @@ executables:
135
120
  extensions: []
136
121
  extra_rdoc_files: []
137
122
  files:
123
+ - CHANGELOG
138
124
  - Gemfile
139
125
  - Gemfile.lock
140
126
  - LICENSE
@@ -159,27 +145,26 @@ files:
159
145
  - test/test_ai.rb
160
146
  homepage: http://github.com/thirdside/berlin-ai
161
147
  licenses: []
148
+ metadata: {}
162
149
  post_install_message:
163
150
  rdoc_options: []
164
151
  require_paths:
165
152
  - lib
166
153
  - test
167
154
  required_ruby_version: !ruby/object:Gem::Requirement
168
- none: false
169
155
  requirements:
170
156
  - - ! '>='
171
157
  - !ruby/object:Gem::Version
172
158
  version: '0'
173
159
  required_rubygems_version: !ruby/object:Gem::Requirement
174
- none: false
175
160
  requirements:
176
161
  - - ! '>='
177
162
  - !ruby/object:Gem::Version
178
163
  version: '0'
179
164
  requirements: []
180
165
  rubyforge_project:
181
- rubygems_version: 1.8.23
166
+ rubygems_version: 2.1.5
182
167
  signing_key:
183
- specification_version: 3
168
+ specification_version: 4
184
169
  summary: Berlin Artificial Intelligence
185
170
  test_files: []