berlin-ai 0.0.26 → 0.0.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/berlin-ai.gemspec +5 -6
  2. data/lib/berlin-ai.rb +17 -17
  3. data/lib/version.rb +1 -1
  4. metadata +20 -20
data/berlin-ai.gemspec CHANGED
@@ -10,16 +10,15 @@ Gem::Specification.new do |s|
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = ["Christian Blais", "Guillaume Malette", "Jodi Giordano"]
12
12
  s.email = ["christ.blais@gmail.com", "gmalette@gmail.com", "giordano.jodi@gmail.com"]
13
- s.homepage = "http://github.com/christianblais/berlin-ai"
13
+ s.homepage = "http://github.com/thirdside/berlin-ai"
14
14
  s.summary = "Berlin Artificial Intelligence"
15
15
  s.description = "Berlin Artificial Intelligence"
16
16
 
17
- s.add_dependency 'sinatra', '>=1.2.6'
18
- s.add_dependency 'yajl-ruby', '>=0.8.2'
19
- s.add_dependency 'sinatra-reloader', '>=0.5.0'
17
+ s.add_dependency 'sinatra', '1.4.3'
18
+ s.add_dependency 'yajl-ruby', '1.1.0'
19
+ s.add_dependency 'sinatra-contrib', '1.4.1'
20
20
  s.add_dependency 'rainbow', '~>1.1.4'
21
-
22
- s.add_dependency 'thin'
21
+ s.add_dependency 'thin', '1.5.1'
23
22
 
24
23
  s.files = `git ls-files`.split("\n")
25
24
 
data/lib/berlin-ai.rb CHANGED
@@ -3,19 +3,22 @@ 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
- require File.expand_path( File.dirname( __FILE__ ) ) + "/ai/#{file}"
13
+ require File.expand_path(File.dirname( __FILE__ )) + "/ai/#{file}"
14
14
  end
15
15
 
16
16
  set :verbose, true
17
17
  set :logger, Logger.new(STDOUT)
18
18
 
19
+ # set tests to false
20
+ $test_ais = false
21
+
19
22
  # Parse options
20
23
  OptionParser.new do |opts|
21
24
  opts.on("-h", "--help", "Display this screen" ) do
@@ -36,8 +39,7 @@ OptionParser.new do |opts|
36
39
  end
37
40
 
38
41
  opts.on("-l", "--log [LOGFILE]", "Create a log file for incoming requests (defaults to 'berlin.log')") do |l|
39
-
40
- set :logger, Logger.new( l || 'berlin.log' )
42
+ set :logger, Logger.new(l || 'berlin.log')
41
43
  end
42
44
 
43
45
  opts.on("-t N", "--test N", Integer, "Test against N random AI") do |t|
@@ -56,17 +58,17 @@ end.parse!
56
58
  post '/' do
57
59
  begin
58
60
  # Check if it's one of the four Berlin keywords
59
- if ['ping', 'turn', 'game_start', 'game_over'].include? params[:action]
60
- # log :info, "New request of type #{params[:action]} : #{params.inspect}"
61
+ if ['ping', 'turn', 'game_start', 'game_over'].include?(params[:action])
62
+ log :info, "New request of type #{params[:action]} : #{params.inspect}"
61
63
 
62
- game = Berlin::AI::Game.create_or_update params[:action], params[:infos], params[:map], params[:state]
64
+ game = Berlin::AI::Game.create_or_update(params[:action], params[:infos], params[:map], params[:state])
63
65
 
64
- if ['ping', 'turn'].include? params[:action]
66
+ if ['ping', 'turn'].include?(params[:action])
65
67
  # Clear old moves
66
68
  game.clear_moves
67
69
 
68
70
  # Let the player decides his moves
69
- Berlin::AI::Player.on_turn( game )
71
+ Berlin::AI::Player.on_turn(game)
70
72
 
71
73
  # Get moves from AI
72
74
  moves = game.moves.to_json
@@ -96,13 +98,11 @@ def log level, message
96
98
  puts message if settings.verbose
97
99
 
98
100
  # logger
99
- settings.logger.send( level, message ) if settings.logger
101
+ settings.logger.send(level, message) if settings.logger
100
102
  end
101
103
 
102
104
  if $test_ais
103
- at_exit {
104
- Berlin::Fake::Game.new($test_ais).run
105
- }
105
+ at_exit { Berlin::Fake::Game.new($test_ais).run }
106
106
  else
107
107
  set :app_file, $0
108
108
  end
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 = 26
5
+ BUILD = 27
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.26
4
+ version: 0.0.27
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,56 +11,56 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-08-25 00:00:00.000000000 Z
14
+ date: 2013-08-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sinatra
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
- - - ! '>='
21
+ - - '='
22
22
  - !ruby/object:Gem::Version
23
- version: 1.2.6
23
+ version: 1.4.3
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  none: false
28
28
  requirements:
29
- - - ! '>='
29
+ - - '='
30
30
  - !ruby/object:Gem::Version
31
- version: 1.2.6
31
+ version: 1.4.3
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: yajl-ruby
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  none: false
36
36
  requirements:
37
- - - ! '>='
37
+ - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.8.2
39
+ version: 1.1.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
- - - ! '>='
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.8.2
47
+ version: 1.1.0
48
48
  - !ruby/object:Gem::Dependency
49
- name: sinatra-reloader
49
+ name: sinatra-contrib
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
- - - ! '>='
53
+ - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 0.5.0
55
+ version: 1.4.1
56
56
  type: :runtime
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  none: false
60
60
  requirements:
61
- - - ! '>='
61
+ - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 0.5.0
63
+ version: 1.4.1
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: rainbow
66
66
  requirement: !ruby/object:Gem::Requirement
@@ -82,17 +82,17 @@ dependencies:
82
82
  requirement: !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
- - - ! '>='
85
+ - - '='
86
86
  - !ruby/object:Gem::Version
87
- version: '0'
87
+ version: 1.5.1
88
88
  type: :runtime
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  none: false
92
92
  requirements:
93
- - - ! '>='
93
+ - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: '0'
95
+ version: 1.5.1
96
96
  description: Berlin Artificial Intelligence
97
97
  email:
98
98
  - christ.blais@gmail.com
@@ -113,7 +113,7 @@ files:
113
113
  - lib/berlin-ai.rb
114
114
  - lib/version.rb
115
115
  - test/test_ai.rb
116
- homepage: http://github.com/christianblais/berlin-ai
116
+ homepage: http://github.com/thirdside/berlin-ai
117
117
  licenses: []
118
118
  post_install_message:
119
119
  rdoc_options: []