berlin-ai 0.0.25 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/ai/fake.rb +10 -4
  2. data/lib/berlin-ai.rb +7 -7
  3. data/lib/version.rb +1 -1
  4. metadata +29 -29
data/lib/ai/fake.rb CHANGED
@@ -112,7 +112,7 @@ module Berlin
112
112
 
113
113
  def initialize(state)
114
114
  js = state.as_json
115
- @player_ids = js.map{ |n| n['player_id'] }.uniq.compact
115
+ @player_ids = js.map{ |n| n['player_id'] }.uniq.compact.sort
116
116
 
117
117
  js.each do |node|
118
118
  id = node['node_id'].to_s.rjust(2)
@@ -245,15 +245,21 @@ class Berlin::Fake::Game
245
245
  end
246
246
 
247
247
  def run
248
+ puts Berlin::Fake::Display.new(@state).as_display
249
+ pause
248
250
  while !@state.winner? && @turn < Berlin::Fake::GAME_INFO['maximum_number_of_turns']
249
251
  turn
250
- puts "Press any key"
251
- gets
252
+ pause
252
253
  puts Berlin::Fake::Display.new(@state).as_display
253
- gets
254
+ pause
254
255
  end
255
256
  end
256
257
 
258
+ def pause
259
+ puts "Press any key to continue"
260
+ gets
261
+ end
262
+
257
263
  def turn
258
264
  @turn += 1
259
265
  generate_moves
data/lib/berlin-ai.rb CHANGED
@@ -3,18 +3,18 @@ require 'sinatra'
3
3
  require 'logger'
4
4
  require 'yajl/json_gem'
5
5
 
6
- puts " __ __ __ _______ _______ "
7
- puts "| |--..-----..----.| |__|.-----. | _ |_ _|"
8
- puts "| _ || -__|| _|| | || | | |_| |_ "
9
- puts "|_____||_____||__| |__|__||__|__| |___|___|_______|"
10
- puts
6
+ # puts " __ __ __ _______ _______ "
7
+ # puts "| |--..-----..----.| |__|.-----. | _ |_ _|"
8
+ # puts "| _ || -__|| _|| | || | | |_| |_ "
9
+ # puts "|_____||_____||__| |__|__||__|__| |___|___|_______|"
10
+ # puts
11
11
 
12
12
  %w(game map node fake).each do |file|
13
13
  require File.expand_path( File.dirname( __FILE__ ) ) + "/ai/#{file}"
14
14
  end
15
15
 
16
16
  set :verbose, true
17
- set :logger, Logger.new('berlin.log')
17
+ set :logger, Logger.new(STDOUT)
18
18
 
19
19
  # Parse options
20
20
  OptionParser.new do |opts|
@@ -57,7 +57,7 @@ post '/' do
57
57
  begin
58
58
  # Check if it's one of the four Berlin keywords
59
59
  if ['ping', 'turn', 'game_start', 'game_over'].include? params[:action]
60
- log :info, "New request of type #{params[:action]} : #{params.inspect}"
60
+ # log :info, "New request of type #{params[:action]} : #{params.inspect}"
61
61
 
62
62
  game = Berlin::AI::Game.create_or_update params[:action], params[:infos], params[:map], params[:state]
63
63
 
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 = 25
5
+ BUILD = 26
6
6
 
7
7
  VERSION = "#{MAJOR}.#{MINOR}.#{BUILD}"
8
8
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berlin-ai
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.0.26
4
5
  prerelease:
5
- version: 0.0.25
6
6
  platform: ruby
7
7
  authors:
8
8
  - Christian Blais
@@ -11,88 +11,88 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-07-25 00:00:00.000000000 Z
14
+ date: 2013-08-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- version_requirements: !ruby/object:Gem::Requirement
17
+ name: sinatra
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
18
20
  requirements:
19
21
  - - ! '>='
20
22
  - !ruby/object:Gem::Version
21
23
  version: 1.2.6
22
- none: false
23
- name: sinatra
24
24
  type: :runtime
25
25
  prerelease: false
26
- requirement: !ruby/object:Gem::Requirement
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
27
28
  requirements:
28
29
  - - ! '>='
29
30
  - !ruby/object:Gem::Version
30
31
  version: 1.2.6
31
- none: false
32
32
  - !ruby/object:Gem::Dependency
33
- version_requirements: !ruby/object:Gem::Requirement
33
+ name: yajl-ruby
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
34
36
  requirements:
35
37
  - - ! '>='
36
38
  - !ruby/object:Gem::Version
37
39
  version: 0.8.2
38
- none: false
39
- name: yajl-ruby
40
40
  type: :runtime
41
41
  prerelease: false
42
- requirement: !ruby/object:Gem::Requirement
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
43
44
  requirements:
44
45
  - - ! '>='
45
46
  - !ruby/object:Gem::Version
46
47
  version: 0.8.2
47
- none: false
48
48
  - !ruby/object:Gem::Dependency
49
- version_requirements: !ruby/object:Gem::Requirement
49
+ name: sinatra-reloader
50
+ requirement: !ruby/object:Gem::Requirement
51
+ none: false
50
52
  requirements:
51
53
  - - ! '>='
52
54
  - !ruby/object:Gem::Version
53
55
  version: 0.5.0
54
- none: false
55
- name: sinatra-reloader
56
56
  type: :runtime
57
57
  prerelease: false
58
- requirement: !ruby/object:Gem::Requirement
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
59
60
  requirements:
60
61
  - - ! '>='
61
62
  - !ruby/object:Gem::Version
62
63
  version: 0.5.0
63
- none: false
64
64
  - !ruby/object:Gem::Dependency
65
- version_requirements: !ruby/object:Gem::Requirement
65
+ name: rainbow
66
+ requirement: !ruby/object:Gem::Requirement
67
+ none: false
66
68
  requirements:
67
69
  - - ~>
68
70
  - !ruby/object:Gem::Version
69
71
  version: 1.1.4
70
- none: false
71
- name: rainbow
72
72
  type: :runtime
73
73
  prerelease: false
74
- requirement: !ruby/object:Gem::Requirement
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
75
76
  requirements:
76
77
  - - ~>
77
78
  - !ruby/object:Gem::Version
78
79
  version: 1.1.4
79
- none: false
80
80
  - !ruby/object:Gem::Dependency
81
- version_requirements: !ruby/object:Gem::Requirement
81
+ name: thin
82
+ requirement: !ruby/object:Gem::Requirement
83
+ none: false
82
84
  requirements:
83
85
  - - ! '>='
84
86
  - !ruby/object:Gem::Version
85
87
  version: '0'
86
- none: false
87
- name: thin
88
88
  type: :runtime
89
89
  prerelease: false
90
- requirement: !ruby/object:Gem::Requirement
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
91
92
  requirements:
92
93
  - - ! '>='
93
94
  - !ruby/object:Gem::Version
94
95
  version: '0'
95
- none: false
96
96
  description: Berlin Artificial Intelligence
97
97
  email:
98
98
  - christ.blais@gmail.com
@@ -121,17 +121,17 @@ require_paths:
121
121
  - lib
122
122
  - test
123
123
  required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
124
125
  requirements:
125
126
  - - ! '>='
126
127
  - !ruby/object:Gem::Version
127
128
  version: '0'
128
- none: false
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
130
131
  requirements:
131
132
  - - ! '>='
132
133
  - !ruby/object:Gem::Version
133
134
  version: '0'
134
- none: false
135
135
  requirements: []
136
136
  rubyforge_project:
137
137
  rubygems_version: 1.8.23