berlin-ai 0.0.32 → 0.0.33

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,14 +10,14 @@ Create your AI in a simple `.rb` file:
10
10
  require 'berlin-ai' # Require the berlin-ai library.
11
11
 
12
12
  class Berlin::AI::Player
13
- def on_turn(game) # Implement the on_turn method of Berlin::AI::Player.
13
+ def self.on_turn(game) # Implement the on_turn method of Berlin::AI::Player.
14
14
  # Do your magic here.
15
15
 
16
16
  # Here's an AI that randomly moves soldiers from node to node.
17
17
  game.map.controlled_nodes.each do |node|
18
18
  node.adjacent_nodes.shuffle.each do |other_node|
19
- rand(0..(node.available_soldiers))
20
- game.add_move(node.id, other_node.id, soldiers)
19
+ soldiers = rand(0..(node.available_soldiers))
20
+ game.add_move(node, other_node, soldiers)
21
21
  end
22
22
  end
23
23
  end
@@ -29,8 +29,10 @@ module Berlin
29
29
  end
30
30
  end
31
31
 
32
- def to_s
33
- "<Berlin::AI::Node @id=#{@id} @player_id='#{@player_id}' @type='#{@type}' @points=#{@points} @soldiers_per_turn=#{@soldiers_per_turn} @number_of_soldiers=#{@number_of_soldiers} @incoming_soldiers=#{@incoming_soldiers} @available_soldiers=#{@available_soldiers} @adjacent_nodes=#{adjacent_nodes.map(&:id)}>"
32
+ def to_s(options={})
33
+ str = "<Berlin::AI::Node @id=#{@id} @player_id='#{@player_id}' @type='#{@type}' @points=#{@points} @soldiers_per_turn=#{@soldiers_per_turn} @number_of_soldiers=#{@number_of_soldiers} @incoming_soldiers=#{@incoming_soldiers} @available_soldiers=#{@available_soldiers} @adjacent_nodes=#{adjacent_nodes.map(&:id)}"
34
+ options.each { |key, val| str << " @#{key}=#{val}"}
35
+ str << ">"
34
36
  end
35
37
 
36
38
  # Reset information for new turn
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 = 32
5
+ BUILD = 33
6
6
 
7
7
  VERSION = "#{MAJOR}.#{MINOR}.#{BUILD}"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berlin-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.32
4
+ version: 0.0.33
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: