It is currently Sun May 11, 2025 1:55 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
Offline
 Post subject: Beta release of SGFGrove.js
Post #1 Posted: Sun Mar 15, 2015 8:56 am 
Dies in gote
User avatar

Posts: 27
Liked others: 6
Was liked: 7
Hi,

I'm releasing SGFGrove.js, a type-ware SGF parser/composer intended for the browser.

https://github.com/anazawa/sgfgrove

Features:

- no dependencies, while the tests require Node.js
- convert a SGF property value to the appropriate JavaScript type
- extendable, i.e. you can add game-specific properties other than go
- supports old FF[1]-FF[3] formats via the extension
- JSON-aware, i.e. the data structure can be converted into JSON without any modifications
- accepts malformed SGF as possible, generate strict SGF (it's not enough at this time)
- fun to use

This is a beta release, and so implementation details of this module are still
very much in flux. Feedback is welcome!


This post by anazawa was liked by: oca
Top
 Profile  
 
Offline
 Post subject: Re: Beta release of SGFGrove.js
Post #2 Posted: Sun Mar 15, 2015 11:09 pm 
Lives in sente
User avatar

Posts: 844
Liked others: 180
Was liked: 151
Rank: 3d
GD Posts: 422
KGS: komi
Thanks! Excellent readme.md.


This post by quantumf was liked by: anazawa
Top
 Profile  
 
Offline
 Post subject: Re: Beta release of SGFGrove.js
Post #3 Posted: Sat May 02, 2015 6:20 pm 
Dies in gote
User avatar

Posts: 27
Liked others: 6
Was liked: 7
I released the version 0.0.2 (beta).

Changes from 0.0.1:

(diff / changes)

* add .jshintrc
* add .travis.yml
* remove jsdoc.conf
* add "argg" and "jshint" to package.json as "devDependencies"
* SGFGrove.stringify's replacer callback is applied to the given data recursively
* (regexp) use [\s\S] instead of .
* fix FF[4] Compose type bug (the right value was invalid)
* add sgfgrove/collection.js that is an iterator/manimulator for SGF colleciton
* add tests for SGFGrove.collection
* lint everything to satisfy jshint

[README]
* add Travis CI status image
* add more links to SEE ALSO
* update examples

Branches:

* master - https://github.com/anazawa/sgfgrove
* develop - https://github.com/anazawa/sgfgrove/tree/develop

Current state:

* The basic data structure of SGF collection/game tree/property will not be changed any more
* The number of test cases is insufficient

Enjoy!

Top
 Profile  
 
Offline
 Post subject: Re: Beta release of SGFGrove.js
Post #4 Posted: Sat May 02, 2015 6:41 pm 
Dies in gote
User avatar

Posts: 27
Liked others: 6
Was liked: 7
Frequently asked questions:

# How can I clone the repository?

Install git and execute the following command:
Code:
$ git clone https://github.com/anazawa/sgfgrove.git


# How can I run the tests?

Install Node.js and run the following command:
Code:
$ npm test

Note that "tape", "argg" and "jshint" packages are required.

...

Top
 Profile  
 
Offline
 Post subject: Re: Beta release of SGFGrove.js
Post #5 Posted: Sat May 02, 2015 7:48 pm 
Dies in gote
User avatar

Posts: 27
Liked others: 6
Was liked: 7
(Introduction to toSGF method)

The toSGF method allows you to convert a used-defined object into SGF.
This method is invoked implicitly as a method on the object when you generate a SGF string:
Code:
SGFGrove.stringify([[
    [
        { FF: 4 },
        {
            B: {
                toSGF: function () {
                    return "pd";
                }
            }
        }
    ],
    []
]]);
// => "(;FF[4];B[pd])"

What happened? The B property (black move) of the second node was replaced with the return value of the toSGF method ("pd").

Since B/W property (black/white move) is frequently used in SGF, it's a good idea to define a Move class:
Code:
var Move = function (x, y) {
    this.x = x; // => "p"
    this.y = y; // => "d"
};

Move.prototype.toSGF = function () {
    return this.x + this.y; // => "p"+"d" => "pd"
};

The Move class has "x" and "y" attributes and implements an object method "toSGF".
While the "x" or "y" attribute in the above definition is-a string, you can also define them as a number.
You can use any coordinate system in your JavaScript if you define how to convert your Move object into SGF.

Using the Move class, the above example can be rewritten as follows:
Code:
SGFGrove.stringify([[
    [
        { FF: 4 },
        {
            B: new Move("p", "d")
        }
    ],
    []
]]);
// => "(;FF[4];B[pd])"


You can also add toSGF methods to SGF collection/game tree/node to absract those data.
The toSGF method helps you write reusable code.

Top
 Profile  
 
Offline
 Post subject: Re: Beta release of SGFGrove.js
Post #6 Posted: Sat May 09, 2015 11:59 am 
Dies in gote
User avatar

Posts: 27
Liked others: 6
Was liked: 7
Unfortunately, I have no time to update this module these days.
Thus 0.0.2 (beta) will become 1.0.0 without code changes.

I wrote this module to replace WGo.js's built-in SGF reader in my project.
I think the latest version of SGFGrove.js is stable enough for that purpose.

I you discover a bug in SGFGrove.js, please open a new issue on GitHub.
Patches are very welcome.

Thanks!

Top
 Profile  
 
Offline
 Post subject: Re: Beta release of SGFGrove.js
Post #7 Posted: Sun Sep 13, 2015 6:20 pm 
Dies in gote
User avatar

Posts: 27
Liked others: 6
Was liked: 7
Released the version 1.0.2.

Changes from 1.0.1 (diff):

- add a table of contents to README.md
- add "SGF Property Types" to README.md
- add "Limitations" to README.md
- add scripts/test.psgi
- add sgfgrove/validator.js
- add test/test.stringify.js
- #stringify does not throw an exception anymore but simply ignores properties that have invalid values

Branches:

* master - https://github.com/anazawa/sgfgrove
* develop - https://github.com/anazawa/sgfgrove/tree/develop

New Features:

SGF validator (alpha)
Code:
var collection = SGFGrove.parse("(;FF[4])");
var validator = SGFGrove.validator(...);

validator.validate(collection, {
    onRootPropNotInRootNodeError: function (error) {
        delete this.node[this.propIdent]; // this error is acceptable, so fix it
    },
    onTwoMovesInNodeError: function (error) {
        throw error; // this SGF does not make sense, so reject it
    },
    onGameInfoAlreadySetError: function (error) {
        // do nothing (ignore this error)
    },
    ...
});


Browser Tests
Code:
$ plackup scripts/test.psgi
$ open http://localhost:5000/


Enjoy!

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group