kayabot 0.1.7 → 0.1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/kayabot +3 -3
- data/kayabot.gemspec +2 -2
- data/lib/gg.rb +2 -2
- data/lib/kayabot.rb +10 -5
- metadata +4 -3
data/bin/kayabot
CHANGED
@@ -9,7 +9,6 @@ require File.expand_path("../lib/kayabot", File.dirname(__FILE__))
|
|
9
9
|
require File.expand_path("../lib/gg", File.dirname(__FILE__))
|
10
10
|
$0='kayabot'
|
11
11
|
|
12
|
-
|
13
12
|
@url = ""
|
14
13
|
|
15
14
|
if ARGV.length > 0
|
@@ -23,10 +22,10 @@ if ARGV.length > 0
|
|
23
22
|
k = KayaBot.new(config)
|
24
23
|
k.listener_loop
|
25
24
|
else
|
26
|
-
puts "Invalid config file. url,user, pass, title, size required."
|
25
|
+
$stderr.puts "Invalid config file. url,user, pass, title, size required."
|
27
26
|
end
|
28
27
|
else
|
29
|
-
puts "File does not exist."
|
28
|
+
$stderr.puts "File does not exist."
|
30
29
|
end
|
31
30
|
elsif ARGV.length >= 3
|
32
31
|
k = KayaBot.new(ARGV[0], ARGV[1], ARGV[2])
|
@@ -34,4 +33,5 @@ if ARGV.length > 0
|
|
34
33
|
end
|
35
34
|
else
|
36
35
|
puts "Usage:\n - kayabot <yaml_config_file>\n - kayabot <url> <bot_nickname> <password>"
|
36
|
+
puts "For redirecting output: kayabot <args> 1> output.log 2> errors.log"
|
37
37
|
end
|
data/kayabot.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "kayabot"
|
3
|
-
s.version = "0.1.7"
|
3
|
+
s.version = "0.1.7.1"
|
4
4
|
s.summary = "Interface to run Go Bots on Kaya"
|
5
|
-
s.description = "This is an interface to run GTP compliant Go Bots on Kaya. "
|
5
|
+
s.description = "This is an interface to run GTP compliant Go Bots on Kaya. Modified version for Zen."
|
6
6
|
s.authors = ["Gabriel Benmergui"]
|
7
7
|
s.email = ["gabriel.benmergui@kaya.gs"]
|
8
8
|
s.homepage = "http://github.com/conanbatt/OpenKaya"
|
data/lib/gg.rb
CHANGED
@@ -97,7 +97,7 @@ def score_game(game_id, game_sgf)
|
|
97
97
|
re = gtp.final_score
|
98
98
|
end
|
99
99
|
|
100
|
-
|
100
|
+
$stdout.puts "dead stones are #{dead_stones}"
|
101
101
|
|
102
102
|
File.delete(filepath)
|
103
103
|
return {:score => re, :dead_stones => dead_stones}
|
@@ -121,7 +121,7 @@ def ai_move(game_id, game_sgf, color)
|
|
121
121
|
size = @master_node.match(/SZ\[(\d+)\]/)[1]
|
122
122
|
re = gtp.genmove color
|
123
123
|
end
|
124
|
-
|
124
|
+
$stdout.puts "Bot generated #{re}"
|
125
125
|
move = convert_move(re,size)
|
126
126
|
|
127
127
|
File.delete(filepath)
|
data/lib/kayabot.rb
CHANGED
@@ -11,6 +11,7 @@ class KayaBot
|
|
11
11
|
OPEN_GAME_URL = "/bot/open_game"
|
12
12
|
RESIGN_URL = "/bot/resign"
|
13
13
|
SCORE_URL = "/bot/score"
|
14
|
+
CLOSE_GAME_URL = "/bot/close_game"
|
14
15
|
VERSION = Gem::Specification.find_by_name("kayabot").version.to_s
|
15
16
|
|
16
17
|
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
@@ -52,11 +53,12 @@ class KayaBot
|
|
52
53
|
sleep TIME_LAPSE #lets not explode in requests
|
53
54
|
end
|
54
55
|
rescue SystemExit, Interrupt
|
56
|
+
close_game
|
55
57
|
raise
|
56
58
|
rescue Exception => e
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
$stderr.puts "There was an error. Will try to run again. If problems persist, contact Kaya at info@kaya.gs"
|
60
|
+
$stderr.puts e
|
61
|
+
$stderr.puts e.backtrace[0]
|
60
62
|
sleep 5
|
61
63
|
listener_loop
|
62
64
|
end
|
@@ -65,7 +67,7 @@ class KayaBot
|
|
65
67
|
def fetch_and_parse_data
|
66
68
|
page = @agent.get(@server_url + "/bot/status", {:version => VERSION })
|
67
69
|
json = JSON.parse(page.body)
|
68
|
-
|
70
|
+
$stdout.puts json
|
69
71
|
@status = json["status"]
|
70
72
|
@move = json["moves"]
|
71
73
|
@bots_turn = json["bot_play?"]
|
@@ -93,10 +95,13 @@ class KayaBot
|
|
93
95
|
def resign
|
94
96
|
@agent.post(@server_url+ RESIGN_URL, {:result => "resign"})
|
95
97
|
end
|
98
|
+
def close_game
|
99
|
+
@agent.post(@server_url + CLOSE_GAME_URL)
|
100
|
+
end
|
96
101
|
|
97
102
|
def post_score
|
98
103
|
result = score_game("temp", sgf_content)
|
99
|
-
|
104
|
+
$stdout.puts result
|
100
105
|
@agent.post(@server_url+ SCORE_URL, {:score => parse_result_from_bot(result[:score]), :dead_stones => result[:dead_stones]})
|
101
106
|
end
|
102
107
|
#Black wins by 61.5 points
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kayabot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.7
|
4
|
+
version: 0.1.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
@@ -43,7 +43,8 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
description:
|
46
|
+
description: This is an interface to run GTP compliant Go Bots on Kaya. Modified version
|
47
|
+
for Zen.
|
47
48
|
email:
|
48
49
|
- gabriel.benmergui@kaya.gs
|
49
50
|
executables:
|