SGF Parser library released

  • Thread starter Aldric Giacomoni
  • Start date
A

Aldric Giacomoni

http://github.com/Trevoke/SGFParser

SGF stands for Smart Game Format, it's best known for storing go games,
but also stores chess, backgammon and a whole bunch of other similar
games.

I've got a 'working' version of an SGF parser. I have issues with KGS
records, I believe it's due to the way I handle ']' characters within
comments.

If you have time, please take a look at the code (it's quite short) and
let me know what you think, or whatever suggestions you may have.

Thanks in advance.
 
R

Ryan Davis

http://github.com/Trevoke/SGFParser

SGF stands for Smart Game Format, it's best known for storing go
games,
but also stores chess, backgammon and a whole bunch of other similar
games.

I've got a 'working' version of an SGF parser. I have issues with KGS
records, I believe it's due to the way I handle ']' characters within
comments.

If you have time, please take a look at the code (it's quite short)
and
let me know what you think, or whatever suggestions you may have.

Looks neat, but it really needs tests. Then it'll go from "working" to
working.

require 'test/unit'

class TestSGFTree < Test::Unit::TestCase
def test_load_string
input = "something"
expected = SGFNode.new "..."

assert_equal expected, SGFTree.new.load_string(something)
end
end

# and build it out from there

P.S. You're mixing tabs and spaces and your indentation looks
absolutely wack as a result. Stick to 2 spaces per indent.
 
A

Aldric Giacomoni

Ryan said:
Looks neat, but it really needs tests. Then it'll go from "working" to
working.

P.S. You're mixing tabs and spaces and your indentation looks
absolutely wack as a result. Stick to 2 spaces per indent.

Hi Ryan, thanks for the input. I'll fix that indentation. Do you know
any particular place to read up on how to create tests, or will any
appropriate google search get me something decent?
 
A

Aldric Giacomoni

Ryan said:
Looks neat, but it really needs tests. Then it'll go from "working" to
working.

Ryan, or whomever else may be reading this, I've done some updates to
the code, and it actually works as it should now, which is always nice.
I've also implemented some basic cucumber testing, which turned out to
almost be fun :)
The library, again, is at http://github.com/Trevoke/SGFParser

I was wondering if anyone had any better ideas for the implementation -
the SGF format is pretty much a tree, and so I've basically implemented
a linked list. It's not particularly ruby-ish and that bugs me, but I
couldn't think of an elegant solution. Any ideas, however wacky they may
be?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top