rubykon 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +6 -2
- data/exe/rubykon +1 -1
- data/lib/rubykon/cli.rb +62 -18
- data/lib/rubykon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 719c9cb87af8a842ef98569911f50788ab6c0943
|
4
|
+
data.tar.gz: 0a6e0f63e45886fbec9c4f993b88488d35fd0709
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3adfcd1fafb3ecb4eec479e2e09cea8bbcee5158a9cafc16b0b09adafb654c778d1f5a20fff8899015635d78c0ede536b95e5601918534491baa410aedc0e499
|
7
|
+
data.tar.gz: 2045fb60ecba1096171bd54ad770d118aee5dacb2175ac10f53e3e11418e4627817d91bc70a846ebfc51cd83867c4c581008bb6836a3717b21aa0954f9f4ff31
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
-
## 0.3
|
1
|
+
## 0.3.1
|
2
|
+
Fixups to the CLI after the fast release.
|
3
|
+
|
4
|
+
### Bugfixes
|
5
|
+
* fix wrong magic comment in gem executable
|
6
|
+
* do not allow invalid moves in the CLI
|
7
|
+
* implement `wdyt` command to ask rubykon what it is thinking
|
8
|
+
* make FakeIO return nil on print/puts as it should be
|
9
|
+
* Allow lower case move input (a19)
|
10
|
+
|
11
|
+
## 0.3 (2015-11-17)
|
2
12
|
Implement full bot together with Monte Carlo Tree Search, as well as a more coarse grained benchmarking tool to benchmark full MCTS runs. Also add a CLI. Mostly a feature release.
|
3
13
|
|
4
14
|
### Performance
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
# Rubykon [![Build Status](https://secure.travis-ci.org/PragTob/rubykon.png?branch=master)](https://travis-ci.org/PragTob/rubykon)[![Code Climate](https://codeclimate.com/github/PragTob/Rubykon.png)](https://codeclimate.com/github/PragTob/Rubykon)[![Test Coverage](https://codeclimate.com/github/PragTob/Rubykon/badges/coverage.svg)](https://codeclimate.com/github/PragTob/Rubykon/coverage)
|
1
|
+
# Rubykon [![Gem Version](https://badge.fury.io/rb/rubykon.svg)](https://badge.fury.io/rb/rubykon)[![Build Status](https://secure.travis-ci.org/PragTob/rubykon.png?branch=master)](https://travis-ci.org/PragTob/rubykon)[![Code Climate](https://codeclimate.com/github/PragTob/Rubykon.png)](https://codeclimate.com/github/PragTob/Rubykon)[![Test Coverage](https://codeclimate.com/github/PragTob/Rubykon/badges/coverage.svg)](https://codeclimate.com/github/PragTob/Rubykon/coverage)
|
2
2
|
A Go-Engine being built in Ruby.
|
3
3
|
|
4
4
|
### Status?
|
5
|
-
|
5
|
+
There is a CLI with which you can play, it does a full UCT MCTS. Still work to do on making move generation and scoring faster. Also there is no AMAF/RAVE implementation yet (which would make it a lot stronger) and it also does not use any expert knowledge right now. So still a lot to do, but it works.
|
6
|
+
|
7
|
+
|
8
|
+
### Sub gems
|
9
|
+
Right now the `mcts` and `benchmark/avg` gem that I wrote for this are still embedded in here. They are bound to be broken out and released as separate gems to play with. If you want to use them now, just use rubykon and you can require `mcts` or `benchmark/avg` :)
|
6
10
|
|
7
11
|
### Why would you build a Go-Bot in Ruby?
|
8
12
|
Cause it's fun.
|
data/exe/rubykon
CHANGED
data/lib/rubykon/cli.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
module Rubykon
|
2
2
|
class CLI
|
3
3
|
|
4
|
-
EXIT
|
5
|
-
CHAR_LABELS
|
6
|
-
X_LABEL_PADDING
|
7
|
-
Y_LABEL_WIDTH
|
4
|
+
EXIT = /exit/i
|
5
|
+
CHAR_LABELS = GTPCoordinateConverter::X_CHARS
|
6
|
+
X_LABEL_PADDING = ' '.freeze * 4
|
7
|
+
Y_LABEL_WIDTH = 3
|
8
|
+
GTP_COORDINATE = /^[A-Z]\d\d?$/
|
9
|
+
MOVE_CONSIDERATIONS_COUNT = 10
|
8
10
|
|
9
11
|
def initialize(output = $stdout, input = $stdin)
|
10
|
-
@output
|
11
|
-
@input
|
12
|
-
@state
|
12
|
+
@output = output
|
13
|
+
@input = input
|
14
|
+
@state = :init
|
15
|
+
@move_validator = MoveValidator.new
|
16
|
+
@root = nil
|
13
17
|
end
|
14
18
|
|
15
19
|
def start
|
@@ -18,7 +22,7 @@ module Rubykon
|
|
18
22
|
@output.puts <<-PLAYOUTS
|
19
23
|
Please enter the number of playouts you'd like rubykon to make!
|
20
24
|
More playouts means rubykon is stronger, but also takes longer.
|
21
|
-
For 9x9 10000 is an acceptable value, for 19x19 1000 already take a long time.
|
25
|
+
For 9x9 10000 is an acceptable value, for 19x19 1000 already take a long time (but still plays bad).
|
22
26
|
PLAYOUTS
|
23
27
|
playouts = get_digit_input
|
24
28
|
init_game(size, playouts)
|
@@ -68,7 +72,7 @@ For 9x9 10000 is an acceptable value, for 19x19 1000 already take a long time.
|
|
68
72
|
if bot_turn?
|
69
73
|
bot_move
|
70
74
|
else
|
71
|
-
|
75
|
+
human_input
|
72
76
|
end
|
73
77
|
end
|
74
78
|
end
|
@@ -96,19 +100,55 @@ For 9x9 10000 is an acceptable value, for 19x19 1000 already take a long time.
|
|
96
100
|
|
97
101
|
def bot_move
|
98
102
|
@output.puts 'Rubykon is thinking...'
|
99
|
-
root = @mcts.start @game_state, @playouts
|
100
|
-
move = root.best_move
|
101
|
-
best_children = root.children.sort_by(&:win_percentage).reverse.take(10)
|
102
|
-
@output.puts best_children.map {|child| "#{@gtp_converter.to(child.move.first)} => #{child.win_percentage}"}.join "\n"
|
103
|
+
@root = @mcts.start @game_state, @playouts
|
104
|
+
move = @root.best_move
|
103
105
|
make_move(move)
|
104
106
|
end
|
105
107
|
|
106
|
-
def
|
108
|
+
def human_input
|
109
|
+
input = ask_for_input.upcase
|
110
|
+
case input
|
111
|
+
when GTP_COORDINATE
|
112
|
+
human_move(input)
|
113
|
+
when 'WDYT'.freeze
|
114
|
+
print_move_considerations
|
115
|
+
else
|
116
|
+
invalid_input
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def ask_for_input
|
107
121
|
@output.puts "Make a move in the form XY, e.g. A19, D7 as the labels indicate!"
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
122
|
+
@output.puts 'Or ask rubykon what it is thinking with "wdyt"'
|
123
|
+
get_input
|
124
|
+
end
|
125
|
+
|
126
|
+
def human_move(input)
|
127
|
+
move = move_from_input(input)
|
128
|
+
if @move_validator.valid?(*move, @game_state.game)
|
129
|
+
make_move(move)
|
130
|
+
else
|
131
|
+
retry_input
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def retry_input
|
136
|
+
@output.puts 'That was an invalid move, please try again!'
|
137
|
+
human_input
|
138
|
+
end
|
139
|
+
|
140
|
+
def print_move_considerations
|
141
|
+
best_children = @root.children.sort_by(&:win_percentage).reverse
|
142
|
+
top_children = best_children.take(MOVE_CONSIDERATIONS_COUNT)
|
143
|
+
moves_to_win_percentage = top_children.map do |child|
|
144
|
+
"#{@gtp_converter.to(child.move.first)} => #{child.win_percentage * 100}%"
|
145
|
+
end.join "\n"
|
146
|
+
@output.puts moves_to_win_percentage
|
147
|
+
end
|
148
|
+
|
149
|
+
def move_from_input(input)
|
150
|
+
identifier = @gtp_converter.from(input)
|
151
|
+
[identifier, :white]
|
112
152
|
end
|
113
153
|
|
114
154
|
def make_move(move)
|
@@ -118,5 +158,9 @@ For 9x9 10000 is an acceptable value, for 19x19 1000 already take a long time.
|
|
118
158
|
@output.puts "#{@game.next_turn_color}'s turn to move!'"
|
119
159
|
end
|
120
160
|
|
161
|
+
def invalid_input
|
162
|
+
puts "Sorry, didn't catch that!"
|
163
|
+
end
|
164
|
+
|
121
165
|
end
|
122
166
|
end
|
data/lib/rubykon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubykon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Pfeiffer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An AI to play Go using Monte Carlo Tree Search. Currently includes the
|
14
14
|
mcts gem and benchmark/avg. Works on all major ruby versions.
|