SGF Parser library released

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.

On Oct 3, 2009, at 22:21 , Aldric G. wrote:

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.

Ryan D. wrote:

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?

Ryan D. wrote:

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 :slight_smile:
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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs