kayabot 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +2 -0
- data/kayabot.gemspec +1 -1
- data/lib/gg.rb +6 -6
- data/lib/kayabot.rb +3 -3
- metadata +2 -2
data/README.markdown
CHANGED
data/kayabot.gemspec
CHANGED
data/lib/gg.rb
CHANGED
@@ -75,7 +75,7 @@ SGF_FILE_PATH = "gnugo_games/"
|
|
75
75
|
|
76
76
|
def score_game(game_id, game_sgf)
|
77
77
|
re = nil
|
78
|
-
if
|
78
|
+
if Dir[SGF_FILE_PATH].empty?
|
79
79
|
Dir.mkdir(SGF_FILE_PATH)
|
80
80
|
end
|
81
81
|
filepath = SGF_FILE_PATH + "#{game_id}.sgf"
|
@@ -102,7 +102,7 @@ end
|
|
102
102
|
def ai_move(game_id, game_sgf, color)
|
103
103
|
|
104
104
|
re = nil
|
105
|
-
if
|
105
|
+
if Dir[SGF_FILE_PATH].empty?
|
106
106
|
Dir.mkdir(SGF_FILE_PATH)
|
107
107
|
end
|
108
108
|
filepath = SGF_FILE_PATH + "#{game_id}.sgf"
|
@@ -135,9 +135,9 @@ def convert_move(move, size=19)
|
|
135
135
|
elsif move == "resign"
|
136
136
|
return 'resign'
|
137
137
|
else
|
138
|
-
|
139
|
-
|
140
|
-
|
138
|
+
h = move[0].ord
|
139
|
+
v = (size.to_i - move[1,2].to_i + 65)
|
140
|
+
sgf_move = [h, v].map {|x| if x > 73 then (x - 1).chr else x.chr end}
|
141
|
+
return sgf_move.downcase
|
141
142
|
end
|
142
143
|
end
|
143
|
-
|
data/lib/kayabot.rb
CHANGED
@@ -11,7 +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
|
-
VERSION =
|
14
|
+
VERSION = Gem::Specification.find_by_name("kayabot").version.to_s
|
15
15
|
|
16
16
|
attr_accessor :challenger, :status, :move
|
17
17
|
|
@@ -32,7 +32,7 @@ class KayaBot
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def connect
|
35
|
-
return if @agent.cookies.last && @agent.cookies.last.name == "
|
35
|
+
return if @agent.cookies.last && @agent.cookies.last.name == "kaya.session"
|
36
36
|
page = @agent.post(@server_url+ "/session/create", {:id => @user, :password => @pass})
|
37
37
|
end
|
38
38
|
|
@@ -89,7 +89,7 @@ class KayaBot
|
|
89
89
|
end
|
90
90
|
#Black wins by 61.5 points
|
91
91
|
def parse_result_from_bot(result)
|
92
|
-
color = result[0]
|
92
|
+
color = result[0].chr
|
93
93
|
points = result.match(/\d{0,3}\.\d/)[0]
|
94
94
|
return "#{color}+#{points}"
|
95
95
|
end
|
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.
|
4
|
+
version: 0.1.3
|
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-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|