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 CHANGED
@@ -22,6 +22,8 @@ The configuration yaml must look like this:
22
22
  url : "http://alpha.kaya.gs:9292"
23
23
  user : "MyBot"
24
24
  pass : "MyBot's password"
25
+ title : "my title"
26
+ size : (9,13 or 19 only)
25
27
 
26
28
  Ask for a bot account at info@kaya.gs to run it!
27
29
 
data/kayabot.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "kayabot"
3
- s.version = "0.1.1"
3
+ s.version = "0.1.3"
4
4
  s.summary = "Interface to run Go Bots on Kaya"
5
5
  s.description = "This is an interface to run GTP compliant Go Bots on Kaya."
6
6
  s.authors = ["Gabriel Benmergui"]
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 not Dir.exists?(SGF_FILE_PATH)
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 not Dir.exists?(SGF_FILE_PATH)
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
- alphabet = "ABCDEFGHIJKLMNOPQRS"[0..size.to_i - 1]
139
- sgf_alphabet = "ABCDEFGHJKLMNOPQRST"[0..size.to_i - 1]
140
- return alphabet["ABCDEFGHJKLMNOPQRST".index(move[0])].downcase + alphabet.reverse[(move[1].to_s + move[2].to_s).to_i - 1].downcase
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 = "0.1.1"#Gem::Specification.find_by_name("kayabot").version.to_s
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 == "rack.session"
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.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-05-24 00:00:00.000000000 Z
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize