goshrine_bot 0.1.13 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ SPEC = Gem::Specification.new do |s|
14
14
  s.platform = Gem::Platform::RUBY
15
15
  s.authors = ["Pete Schwamb"]
16
16
  s.email = ["pete@schwamb.net"]
17
- s.homepage = "http://github.com/ps2/goshrine_bot"
17
+ s.homepage = "http://github.com/goshrine/goshrine_bot"
18
18
  s.summary = "A client to connect GTP go programs to GoShrine"
19
19
  s.description = <<-END_DESCRIPTION.gsub(/\s+/, " ").strip
20
20
  The GoShrine bot client is a library that allows you connect a local Go playing program that speaks GTP (like gnugo) to http://goshrine.com.
@@ -1,13 +1,13 @@
1
1
  require 'rubygems'
2
2
  require 'json'
3
+ require 'faye'
3
4
  require 'eventmachine'
4
5
  require 'em-http'
5
- require 'faye'
6
6
  require 'logger'
7
7
 
8
8
  module GoshrineBot
9
9
 
10
- VERSION = "0.1.13"
10
+ VERSION = "0.2.0"
11
11
 
12
12
  STDOUT.sync = true
13
13
 
@@ -80,7 +80,6 @@ module GoshrineBot
80
80
  load_existing_games {
81
81
  if @options[:idle_shutdown_timeout] > 0
82
82
  EM::add_periodic_timer( @options[:idle_shutdown_timeout] ) {
83
- puts "checking"
84
83
  @games.each do |token, game|
85
84
  game.idle_check(@options[:idle_shutdown_timeout])
86
85
  end
@@ -57,6 +57,9 @@ module GoshrineBot
57
57
  elsif m['data']['scoring_info'].nil?
58
58
  puts "Missing scoring_info: #{m.inspect}"
59
59
  return
60
+ elsif m['data']['scoring_info']['score'].nil?
61
+ puts "Missing score (game_id = #{game_id}): #{m.inspect}"
62
+ return
60
63
  end
61
64
  score = m['data']['scoring_info']['score']
62
65
  winner = score['black'] > score['white'] ? 'B' : 'W'
@@ -77,17 +80,24 @@ module GoshrineBot
77
80
  color = m["color"].upcase
78
81
  if pos && color && color != my_color
79
82
  pos = sgf_coord_to_gtp_coord(pos, board_size)
80
- puts "Received move #{pos}"
81
- gtp_client.time_left("B", m["black_seconds_left"], 0).callback {
82
- gtp_client.time_left("W", m["white_seconds_left"], 0).callback {
83
- gtp_client.play(color, pos).callback {
84
- self.moves << [color, pos]
85
- self.move_number = m["move_number"].to_i
86
- self.turn = m["color"] == "b" ? "w" : "b"
87
- make_move
83
+ move_proc = Proc.new do
84
+ gtp_client.play(color, pos).callback {
85
+ self.moves << [color, pos]
86
+ self.move_number = m["move_number"].to_i
87
+ self.turn = m["color"] == "b" ? "w" : "b"
88
+ puts "Going to make move..."
89
+ make_move
90
+ }
91
+ end
92
+ if m["black_seconds_left"] && m["white_seconds_left"]
93
+ gtp_client.time_left("B", m["black_seconds_left"] || 0, 0).callback {
94
+ gtp_client.time_left("W", m["white_seconds_left"] || 0, 0).callback {
95
+ move_proc.call
88
96
  }
89
97
  }
90
- }
98
+ else
99
+ move_proc.call
100
+ end
91
101
  end
92
102
  end
93
103
 
@@ -13,7 +13,6 @@ module GoshrineBot
13
13
  end
14
14
 
15
15
  def do_http(verb,options)
16
- puts "Sending"
17
16
  options[:head] =
18
17
  {'Accept' => 'application/json',
19
18
  'cookie' => @cookie_persist.cookie_hash.to_cookie_string}
@@ -22,7 +21,6 @@ module GoshrineBot
22
21
 
23
22
  defer = EM::DefaultDeferrable.new
24
23
  http.callback {
25
- puts "Persisting cookies"
26
24
  @cookie_persist.cookies << http.response_header[EM::HttpClient::SET_COOKIE]
27
25
  defer.succeed(http)
28
26
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goshrine_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-15 00:00:00.000000000Z
12
+ date: 2012-05-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &70254337655960 !ruby/object:Gem::Requirement
16
+ requirement: &70320125116620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.12.10
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70254337655960
24
+ version_requirements: *70320125116620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: em-http-request
27
- requirement: &70254337655480 !ruby/object:Gem::Requirement
27
+ requirement: &70320125116140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70254337655480
35
+ version_requirements: *70320125116140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: faye
38
- requirement: &70254337655020 !ruby/object:Gem::Requirement
38
+ requirement: &70320125115680 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.6.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70254337655020
46
+ version_requirements: *70320125115680
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: json
49
- requirement: &70254337654560 !ruby/object:Gem::Requirement
49
+ requirement: &70320125115220 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.5.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70254337654560
57
+ version_requirements: *70320125115220
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70254337654180 !ruby/object:Gem::Requirement
60
+ requirement: &70320125114840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70254337654180
68
+ version_requirements: *70320125114840
69
69
  description: The GoShrine bot client is a library that allows you connect a local
70
70
  Go playing program that speaks GTP (like gnugo) to http://goshrine.com.
71
71
  email:
@@ -94,7 +94,7 @@ files:
94
94
  - lib/goshrine_bot/goshrine_request.rb
95
95
  - lib/goshrine_bot/gtp_stdio_client.rb
96
96
  - lib/goshrine_bot/runner.rb
97
- homepage: http://github.com/ps2/goshrine_bot
97
+ homepage: http://github.com/goshrine/goshrine_bot
98
98
  licenses: []
99
99
  post_install_message:
100
100
  rdoc_options: []
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project:
117
- rubygems_version: 1.8.12
117
+ rubygems_version: 1.8.10
118
118
  signing_key:
119
119
  specification_version: 3
120
120
  summary: A client to connect GTP go programs to GoShrine