boj / kantan-sgf
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
LICENSE | Thu Feb 12 02:29:39 -0800 2009 | |
| |
README | Mon Mar 02 22:42:51 -0800 2009 | |
| |
Rakefile | Mon Mar 02 04:45:05 -0800 2009 | |
| |
data/ | Mon Mar 02 03:39:16 -0800 2009 | |
| |
examples/ | Mon Mar 02 05:17:43 -0800 2009 | |
| |
kantan-sgf.gemspec | Mon Mar 02 23:54:36 -0800 2009 | |
| |
lib/ | Mon Mar 02 23:54:36 -0800 2009 | |
| |
test/ | Mon Mar 02 04:45:05 -0800 2009 | |
| |
web/ | Tue Mar 03 00:03:22 -0800 2009 |
README
~~ ABOUT ~~~~~* Author: Brian "bojo" Jones Email: mojobojo@gmail.com KANTAN means "simple" in Japanese. Due to the lack of standalone Ruby SGF parsers, I ended up writing this project to help with a few other side projects. Hopefully it benefits other people interested in using Ruby for their SGF parsing related projects. It doesn't do node parsing (yet). I just upgraded it using Treetop grammar to parse the file, so a good majority of the data is pulled out now. Some of it will get refined with more internal handling, but for now enjoy! ~~ Requirements ~~~~~* Requires the Treetop gem to run. $ gem install treetop ~~ USAGE ~~~~~* You pretty much run it like so: # Load and parse sgf = KantanSgf::Sgf.new('data/stoic-bojo.sgf') sgf.parse # Pull back properties puts sgf.player_black puts sgf.player_white puts sgf.komi puts sgf.result # do some magic with the move hash for move in sgf.move_list puts "%s: (%i, %i)" % [move[:color], move[:x], move[:y]] end Note that the move data is stored as: * move: The current move number * color: 'B' or 'W' * x, y: Integer value from 0..board_size - 1 * time: Clock time left * ot_stones: Overtime stones * pass: true Properties can be accessed directly via sgf.properties["prop_name"]. Comments can be access via sgf.comments # {:move, :data}
