|
BGonline.org Forums
Method/Function to Parse an XGID, api to XG?
Posted By: Michael Petch In Response To: Method/Function to Parse an XGID, api to XG? (RobertFontaine)
Date: Sunday, 30 August 2015, at 2:41 a.m.
When you said XGID do you mean the XG file format or an XGID like XGID=-a---aD-C-B-cD---cbcbA--A-:0:0:1:53:0:0:3:0:10 . Currently my software doesn't have XGID processing however it wouldn't be difficult to add if I had the time. Why my code does is reads, decompresses and then makes available the data for every position in a file (including rollouts). I never actually completed the Python interface (it works but really isn't a really a finished API) but I do have a better Java implementation that some others have helped debug. The java variant isn't mentioned on Xavier's webpage but can be found in the information below (which was from an email I sent out on the gnubg mailing list) Email to GNUBG mailing list: About a year ago I produced some code for Python that reads XG file formats and dumps it out to the console. I never got back to finishing that Python code to produce a proper module that can be easily used by other applications. I intend to do that sometime this year and possibly use that Python code to read XG files into GNUbg. We already use Python and most builds come with it enabled - rather than rewrite in in C it might be more convenient to reuse code I have. I've also moved to a more liberal LGPL license for the Python code (and new Java library which I will mention below). This would allow people to integrate it into proprietary software without having to make the source of the program linking to that library available. Of course if you modify the the code of the library itself then those changes have to be made available. In the middle of last year I was approached by a couple individuals (not by Frank Berger) with a keen interest in something that reads XG file formats in Java. I created an initial version a number of months ago but it wasn't until Christmas where I had someone who did significant testing (Thanks Victor Kudryashov). The library is very basic. The initial release only supports reading XG file format (Both XG and XGP files). It doesn't compute PRs, or generate XGID's etc. It simply makes available all the information for others to do more powerful things. If people wish to share code that builds on the basics I would be more than willing to integrate them. The git repository can be cloned with: git clone git://vcs.capp-sysware.com/backgammon/xgdatatoolsjava.git You can download the latest 0.1.2 packaged version (I use Maven) from here: http://www.capp-sysware.com/downloads/misc/xgdatatools-0.1.2-SNAPSHOT-jar-with-dependencies.jar http://www.capp-sysware.com/downloads/misc/xgdatatools-0.1.2-SNAPSHOT.jar Basic documentation (and class hierarchy) can be found here: http://docs.capp-sysware.com/projects/java/xgdatatools/0.1.0/ I have a dependency on Apache Common Langs, and this code work Java 1.6+ . The Langs dependency is only to support much better console output when trying to get a text representation of what is in an XG/XGP file. This isn't a necessity and some may wish to alter the code to use Java's own StringBuilder class. This is a trivial change for those who want to drop the dependency. The two Jar files are the same except one includes the Java Common Langs classes. The default main class can be used to dump an XG files contents to the console with something like: java -jar xgdatatools-0.1.2-SNAPSHOT-jar-with-dependencies.jar nameoffile.xg It lacks help for each individual field but the names are pretty similar to the information published by Xavier here: http://www.extremegammon.com/xgformat.aspx There is a sample program in the source tree that shows you how you can manipulate the objects. See sample1.java . The code is lacking a proper visitor pattern (which I am working on) so for the time being you use instance of to figure out what type of objects are returned. I do have a rudimentary version that does write support but it has some bugs that need to be worked out and it is a low priority so probably won't be finishing that until later in the year. Similar thing with improving the basic class documentation. If someone finds bug or has questions I can be reached at mpetch@capp-sysware.com .
|
BGonline.org Forums is maintained by Stick with WebBBS 5.12.