tag:blogger.com,1999:blog-40776180249371367312024-03-12T19:27:03.958-07:00Shogi SoftwareThis blog traces progress of the project that's subject is to documenting shogi community standards for storing, representing, transmitting shogi-related data (games, tsume, etc.), building tools to translate between the formats, discuss Shogi software in general.Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.comBlogger19125tag:blogger.com,1999:blog-4077618024937136731.post-19669511863264785132011-01-15T00:16:00.000-08:002011-01-15T00:16:30.925-08:00http://shogi-lab.netYesterday I came across this site by Adam Szlachta: shogi-lab.net.<br />
<div><br />
</div><div>It looks like a work in progress but it looks very promising. The site, as I understand it, intends to present in visually pleasing way, shogi games, openings, tsume, etc.<br />
<br />
Like I said, it looks like a beginning now, but have a look at <span class="Apple-style-span" style="border-collapse: collapse; color: #00cc00; font-family: 'courier new', monospace; font-size: 13px;"><a href="http://www.shogi-lab.net/oneye/" style="color: #00cc00;" target="_blank">http://www.shogi-lab.net/<wbr></wbr>oneye/</a>.</span><br />
You can browse through two games from Yoshiharu Habu "Habu's Words". <br />
<br />
I hope the site will achieve its full potential...<br />
<br />
Best wishes, Adam!</div>Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com1tag:blogger.com,1999:blog-4077618024937136731.post-64371161547614804902009-04-18T10:04:00.000-07:002009-04-19T03:14:47.957-07:00Google App Engine and File Upload<p>Google App Engine (GEA) finally got Java support. That's good. This is leaving me with no more excuses for delaying my Shogi Tools work.</p><div><div>So I got a grip and wrote some more code. Right now I am focusing on turn-based Shogi server.</div><div style="text-align: center;"><br /></div><div>I wanted there to provide the functionality to upload a user's picture.</div><div><br /></div><div>But how to achieve this in GAE? GAE doesn't allow you to write files on the discs. How to do this fast and easy? I remember using in some of my earlier projects a ready to use Java library that made file uploading very easy for me.<br /></div><div style="text-align: center;"><br /></div><div><span class="Apple-style-span" style="font-size:180%;">Apache Commons </span><span style="font-size:180%;"><strong><span class="Apple-style-span">FileUpload</span></strong></span></div><br /><div>Thank God for people from Apache.org. I went to their site <a href="http://commons.apache.org/fileupload/">http://commons.apache.org/fileupload/</a>. The folks prepared a library to add robust, high-performance, file upload capability to our servlets and web applications. I decided to see how would it play with GAE.<br /><br />Below there is a description of the process of creating a Java web application, under Eclipse environment, which uses commons FileUpload.<br /></div><br /><br /><div><span style="font-size:180%;">Example Google App Project</span></div><div><div>I assume you have downloaded and installed Google Plugin for Eclipse. In my case I used Eclipse 3.4 (and the dedicated plugin). </div><div><br /></div><div>We'll start off with creating new Google App Engine project.<br /><br /></div><div>Open up your Eclipse. Then create new GAE project.</div><div style="text-align: justify;">You can do this by clicking g+ icon on Eclipse toolbar (<img style="cursor: pointer; width: 94px; height: 64px;" src="http://1.bp.blogspot.com/_YZjHIT7L6gg/SeoQVwkh_6I/AAAAAAAAA8U/t6r9dp15Sbo/s400/gae_toolbar.png" alt="" id="BLOGGER_PHOTO_ID_5326087475320455074" border="0" />) or choosing File->New->Other->Google->Web Application Project. "New Web Application Project" dialog shows up.</div><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_YZjHIT7L6gg/Ser28pKtVcI/AAAAAAAAA-E/7Zqkwkp0Vqc/s1600-h/newproject.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 337px; height: 400px;" src="http://4.bp.blogspot.com/_YZjHIT7L6gg/Ser28pKtVcI/AAAAAAAAA-E/7Zqkwkp0Vqc/s400/newproject.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5326341031022384578" /></a><br /><div style="text-align: left;">For the purpose of this "tutorial", provide the project name ("UploadTest"), package name ("org.fbc.uploadtest") and uncheck the GWT support. After clicking "Finish" GEA Eclipse</div><div> plugin creates a new project for us with a structure similar to the following screenshot:<br /><br /></div><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_YZjHIT7L6gg/SerF9Kt2B4I/AAAAAAAAA9U/oUhm0vznAEw/s1600-h/projstructure.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 260px; height: 271px;" src="http://3.bp.blogspot.com/_YZjHIT7L6gg/SerF9Kt2B4I/AAAAAAAAA9U/oUhm0vznAEw/s400/projstructure.png" alt="" id="BLOGGER_PHOTO_ID_5326287163958364034" border="0" /></a><div><span class="Apple-style-span" style="font-size:180%;">HTML page for file upload</span></div><div><span class="Apple-style-span" style="font-size:100%;"><span class="Apple-style-span">Next, we create a HTML file which enables the user to pick up the files to upload to the server.<br />Do this by replacing contents of (generated by GEA plugin) index.html. Open it for editing and paste the following content:</span></span></div><div><br /><pre><br /><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br /><html><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><br /><title>GAE file upload test</title><br /></head><br /><body><br /><form name="filesForm" action="uploadtest" method="post" enctype="multipart/form-data"><br />File 1:<input type="file" name="file1"><br><br />File 2:<input type="file" name="file2"><br><br />File 3:<input type="file" name="file3"><br><br /><input type="submit" name="Submit" value="Upload Files"><br /></form><br /></body><br /></html><br /></pre><br />There are few key points here:<br /><ul><li>form's attribute "method" is set to "post"</li><li>form's attribute "enctype" is set to "multipart/form-data"</li><li>form's "action" points to the servlet that will handle the upload (yet to be created)</li><li>input filed type is "file"</li></ul></div><br /><br /><span style="font-size:180%;">Configure Apache commons in Eclipse</span><br /><div>First, if we haven't done it yet, we should download FileUpload and IO libraries from Apache's page. I decided to use the latest (1.2.1) version of FileUpload (<a href="http://archive.apache.org/dist/commons/fileupload/">http://archive.apache.org/dist/commons/fileupload/</a>). The version is dependent (see <a href="http://commons.apache.org/fileupload/dependencies.html">http://commons.apache.org/fileupload/dependencies.html</a>) on version 1.3.2 of IO library, so I downloaded exactly this version (<a href="http://archive.apache.org/dist/commons/io/binaries/commons-io-1.3.2-bin.tar.gz">http://archive.apache.org/dist/commons/io/binaries/commons-io-1.3.2-bin.tar.gz</a>).<br /><br />After unpacking the contents look for commons-fileupload-1.2.1.jar and commons-io-1.3.2.jar. Copy the files to war/WEB-INF/lib directory (see the project structure image above). This directory contains all the java libraries that will be deployed to appspot server for your app to use them.<br /><br />Now, for your project to "see" them, you have to add the to the project's build path. I do this by right-clicking on the projects node in the project explorer, choosing Build Path->Configure Build Path (see the image below).<br /></div><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_YZjHIT7L6gg/Serq8JGuC1I/AAAAAAAAA9s/CVRFxfqYxkw/s1600-h/configurepath.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 248px;" src="http://3.bp.blogspot.com/_YZjHIT7L6gg/Serq8JGuC1I/AAAAAAAAA9s/CVRFxfqYxkw/s400/configurepath.png" alt="" id="BLOGGER_PHOTO_ID_5326327828276185938" border="0" /></a><br /><div>Then I go to "Library tab" (1), click Add JARs (2), indicate desired files in "war" directory (3) and add them to the build path (4). Look below.<br /></div><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_YZjHIT7L6gg/Serqw8VAGqI/AAAAAAAAA9k/CFBHeW6JjTI/s1600-h/addjars.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 312px;" src="http://4.bp.blogspot.com/_YZjHIT7L6gg/Serqw8VAGqI/AAAAAAAAA9k/CFBHeW6JjTI/s400/addjars.png" alt="" id="BLOGGER_PHOTO_ID_5326327635867867810" border="0" /></a><br /><div>The libraries are now in the project's classpath. We can start creating the servlet.<br /></div><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_YZjHIT7L6gg/SertuuhhdLI/AAAAAAAAA90/jMttHalXWvg/s1600-h/jarsadded.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 329px; height: 157px;" src="http://4.bp.blogspot.com/_YZjHIT7L6gg/SertuuhhdLI/AAAAAAAAA90/jMttHalXWvg/s400/jarsadded.png" alt="" id="BLOGGER_PHOTO_ID_5326330896337433778" border="0" /></a><br /><div><span style="font-size:180%;">Upload servlet</span></div>We are ready to send the file. Now we must prepare ourselves to receive it on the server side. For that purpos we change the contents of "UploadTestServlet.java". GAE plugin generated this class for us in src folder and org.fbc.uploadtest package (see the picture with project structure).<br /><br />Our upload form (index.html) says it sends the data to the server with "post" method. So, in our servlet we must provide doPost method. Here is the code:<br /><pre><br />public void doPost(HttpServletRequest req, HttpServletResponse res)<br />throws ServletException, IOException {<br />try {<br />ServletFileUpload upload = new ServletFileUpload();<br /><span style="font-weight: bold;">upload.setSizeMax(50000);</span><br />res.setContentType("text/plain");<br />PrintWriter out = res.getWriter();<br /><br />try {<br />FileItemIterator iterator = upload.getItemIterator(req);<br />while (iterator.hasNext()) {<br />FileItemStream item = iterator.next();<br />InputStream in = item.openStream();<br /><br />if (item.isFormField()) {<br />out.println("Got a form field: " + item.getFieldName());<br />} else {<br />String fieldName = item.getFieldName();<br />String fileName = item.getName();<br />String contentType = item.getContentType();<br /><br />out.println("--------------");<br />out.println("fileName = " + fileName);<br />out.println("field name = " + fieldName);<br />out.println("contentType = " + contentType);<br /><br />String fileContents = null;<br />try {<br /> <span style="font-weight: bold;">fileContents = IOUtils.toString(in);</span><br /> out.println("lenght: " + fileContents.length());<br /> out.println(fileContents);<br />} finally {<br /> IOUtils.closeQuietly(in);<br />}<br /><br />}<br />}<br />} catch (SizeLimitExceededException e) {<br />out.println("You exceeded the maximu size ("<br />+ e.getPermittedSize() + ") of the file ("<br />+ e.getActualSize() + ")");<br />}<br />} catch (Exception ex) {<br /><br />throw new ServletException(ex);<br />}<br />}</pre><br />The code should be quite self explanatory, so I won't dwell on this (although I am open to questions :-) ).<br /><br />I'll just point out few things. I marked two places in the source bold.<br />The first line:<br /><div style="text-align: center;"><pre>upload.setSizeMax(50000);</pre></div><br />sets the file size limit. When the user tries to upload a file larger then (in our case) 50000 bytes, an exception occurs. When setting the maximal size remember about the GAE limits and quotas.<br /><br />(If you paste doPost to the class, Eclipse should automatically add imports the code uses. If not so, do add the following lines manually:<br />import org.apache.commons.fileupload.FileItemIterator;<br />import org.apache.commons.fileupload.FileItemStream;<br />import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException;<br />import org.apache.commons.fileupload.servlet.ServletFileUpload;<br />import org.apache.commons.io.IOUtils;<br />)<br /><br /><div>The second line</div><div style="text-align: center;"><pre>fileContents = IOUtils.toString(in);</pre></div>does all the magic needed to fetch the input stream to String. With a single line of code. Thanks, IOUtils! ;-)<br /><br />Now you have a String containing uploaded file's data waiting for you to do whatever you want to do with it.<br /><br />In my example I just output the string to the browser (so when you test it it's best to use text files).<br /></div><br /></div><br /><div><span style="font-size:180%;">Testing the code</span><br />All is set and ready. Just run the code. I do this by right-clicking on the project root node in the project browser and choosing Run As->Web Application.<br /></div><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_YZjHIT7L6gg/SeryhSatukI/AAAAAAAAA98/PI8bSj7WZFg/s1600-h/runas.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 322px;" src="http://3.bp.blogspot.com/_YZjHIT7L6gg/SeryhSatukI/AAAAAAAAA98/PI8bSj7WZFg/s400/runas.png" alt="" id="BLOGGER_PHOTO_ID_5326336163012524610" border="0" /></a><br /><div>On the Eclipse console, if everything went fine, you should see the following message:<br /><br /><div style="text-align: center;">The server is running at http://localhost:8080/<br /><div style="text-align: left;"><br />So, open up your favourite browser and go to the address. Choose some files (remember the size limit) and submit the form.<br /><br />In my case (I chose log4j.properties from src folder), I got the following message in my browser:<br /><pre><br />--------------<br />fileName = log4j.properties<br />field name = file2<br />contentType = application/octet-stream<br />lenght: 1063<br /># A default log4j configuration for log4j users.<br />#<br /># To use this configuration, deploy it into your application's WEB-INF/classes<br /># directory. You are also encouraged to edit it as you like.<br /><br /># Configure the console as our one appender<br />log4j.appender.A1=org.apache.log4j.ConsoleAppender<br />log4j.appender.A1.layout=org.apache.log4j.PatternLayout<br />log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n<br /><br /># tighten logging on the DataNucleus Categories<br />log4j.category.DataNucleus.JDO=WARN, A1<br />log4j.category.DataNucleus.Persistence=WARN, A1<br />log4j.category.DataNucleus.Cache=WARN, A1<br />log4j.category.DataNucleus.MetaData=WARN, A1<br />log4j.category.DataNucleus.General=WARN, A1<br />log4j.category.DataNucleus.Utility=WARN, A1<br />log4j.category.DataNucleus.Transaction=WARN, A1<br />log4j.category.DataNucleus.Datastore=WARN, A1<br />log4j.category.DataNucleus.ClassLoading=WARN, A1<br />log4j.category.DataNucleus.Plugin=WARN, A1<br />log4j.category.DataNucleus.ValueGeneration=WARN, A1<br />log4j.category.DataNucleus.Enhancer=WARN, A1<br />log4j.category.DataNucleus.SchemaTool=WARN, A1<br /></pre><br />So, everything works fine. The browser uploaded a file to our application, which now could store the file in the GAE datastore.<br /><br />Hope this info is helpful to anyone.<br /><br />See you next time,<br />fat bold cyclop<br /><br />P.S. I left working example on http://100.latest.kbguesttbook.appspot.com/.<br /></div></div></div>Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com40tag:blogger.com,1999:blog-4077618024937136731.post-70499119616957656402008-07-05T21:51:00.000-07:002009-10-25T22:40:02.165-07:00JavaScript ANTLR targetTonight I managed to build ANTLR version with JavaScript target.<br />
<br />
I must admit it was one of the most bizarre builds I did. The problem was not the target itself. The maintainers did a decent job making it. Although it is in it's early stages (the guys claim it not yet ready for publication) the compilation of the target went smooth. Building ANTLR is another story. The instructions (http://www.antlr.org/wiki/pages/viewpage.action?pageId=732) are less then obvious and only a little bit helpful. And that's a bit strange, because all in all, ANTLR is quite well documented.<br />
<br />
[[In situation like this I start to appreciate build tools that are more strict as for defining dependencies in projects, like Maven.]]<br />
<br />
Anyway, I did build it, so there is no need to complain.<br />
<br />
What is important, that I can theoretically use the Shogi grammars I am working on, to build example browser-side parser for game record. Of course, I could do it earlier, by hand. But it would be much more tedious work. And this also gives me an opportunity to learn new things which is, as usual, great fun :-).<br />
<br />
I think my first attempt will be a parser/viewer for format in which Reijer Grimbergen posts games on shogi-l and (most of the time) on his pages.<br />
<br />
You can see <a href="http://www.teu.ac.jp/gamelab/SHOGI/GAMES/57osho1.html">an example game score in this format here</a>. There are no variations. The file consist of only 3 types of information: tag (game details), move (what move whas made) and comment. The file is well formed -- there are strict rules to determine which line is what. A tag line starts and ends with '[' and ']' respectively. A line with move information starts with integer, followed by a dot, followed by move description, followed by two timestamps. The only exception are the comments. They can appear anytime in the text and couldn't be easily distinguished by the machine.<br />
<br />
As I understand it, if I, in my parser, write a rule to recognize comment, which is basically free text, the rule would also consume other part of the file also. In other words every line of the text would satisfy the rule (every line can be treated as a free text), so the parser would be confused which rule to apply.<br />
<br />
Actually I am not sure if a grammar file can describe it. (read: I am not sure if I could describe it ;-) ). Well, we'll see about that.<br />
<br />
Ok, wish me luck.Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com1tag:blogger.com,1999:blog-4077618024937136731.post-26834072223194333912008-07-03T05:58:00.000-07:002008-07-03T06:58:10.806-07:00JavaScript SFEN parser<a href="http://shogi-software.blogspot.com/2008/01/proposal-standard-for-storing-shogi.html">Earlier in my posts</a> I described Shogi FEN notation. I also showed SFEN parser -- a Java Web application that creates diagrams from SFEN data.<br /><p>This time I spent some time learning JavaScript and programing the browser. As a result I came up with JavaScript <a href="http://fat.bold.cyclop.googlepages.com/javascriptshogiboardviewer">Shogi Board Viewer</a> and <a href="http://fat.bold.cyclop.googlepages.com/javascriptshogiboardviewer2">Shogi FEN parser</a>. They have similar functionality as the former, but it's easier to use it on one's own Web pages.<br /></p><span style="font-size:130%;"><span style="font-size:180%;">The viewer</span><br /></span>JS Shogi Board Viewer is a JavaScript component that makes it possible to generate Shogi position diagram on your Web page.<br /><br />The viewer consists of 3 elements:<ol style="margin-left: 40px;"><li>JavaScript program to generate the diagram</li><li>CSS file containing style definitions for the diagram</li><li>Images representing the board and the pieces</li></ol>"Interesting" thing about the viewer is the way it is provided with Shogi data.<br /><p>Well, I wanted my viewer to be "generic" (independent of the position data source) and possibly small. Therefore I decided that the position is provided with a javascript object. Feels like real pain, doesn't it? But fortunately, JSON notation comes to the rescue. Thanks to it we can build JavaScript objects that are understood both by computers and humans. </p>Besides, JSON is quite popular data exchange format, so there could be converters (i.e. from Shogi FEN or others) easily plugged in to the viewer.<br /><h4 style="font-weight: normal;" id="j3wj16"><span style="font-size:130%;">Shogi position data format</span></h4><h4 style="font-weight: normal;" id="j3wj16"><span style="font-size:100%;">The good thing about JSON is that it's very self-descriptive format. Here is how I designed the format.</span></h4><p>The description consists of 4 elements:<br /></p><ul style="margin-left: 40px;" id="dm7s2"><li id="dm7s3">side on move</li><li id="dm7s4">white pieces in hand</li><li id="dm7s5">black pieces in hand</li><li id="dm7s6">pieces on the board</li></ul><p> and could be expressed as JSON like this:</p><blockquote style="margin-left: 40px;" id="xpg3"></blockquote><blockquote><blockquote style="margin-left: 40px;" id="xpg3">{<br />"sideOnMove":"black",<br />"blackHand":[],<br />"whiteHand":[],<br />"pieces":[]<br />}</blockquote></blockquote><p><b id="ld1q">Side on move</b> is simple: it can be either "black" or "white".</p><p><b id="ld1q0">Pieces in hand </b>data is an array of numbers. Each number represent the count of pieces for a given rank. The rank is indicated by position in the array. Pieces info is stored in a given order:<br /></p><ul style="margin-left: 40px;" id="s0kh"><li id="s0kh0">Pawn (index 0)</li><li id="s0kh1">Lance (index 1)</li><li id="s0kh2">Knight</li><li id="s0kh3">Silver</li><li id="s0kh4">Gold</li><li id="s0kh5">Bishop</li><li id="s0kh6">Rook (index 6)<br /></li></ul><p> So, for a Silver and 2 Pawns in hand the data would look like this:<br /></p><p></p><blockquote>[2,0,0,1,0,0,0,0,0,0]</blockquote><p></p><p>I am not particularly happy with the format. I don't like the fact that a human has to remember position of piece ranks in the array. The format could be therefore change in the matter. [[Maybe better would be to have pairs rank:count?]]</p><p><b id="ld1q1">Pieces on board</b> are given by field:rank pairs. <b id="ld1q2">A field</b> is described by 2 chars: column number and row char in the standard Shogi coordinate system. Leftmost column is named '9', rightmost is '1'. Uppermost row is 'a', lowermost is 'i'. </p><p><b id="ld1q3">A piece</b> symbol is "borrowed" from Shogi Ladder notation (http://www.shogi.net/ladder/shogiboard.html). The 'w' and 'b' in front of the piece symbol's abbreviations indicate white and black respectively. When a piece is promoted, it will be given with a preceding "+", as in "+bL" or "+wP".<br /><br />Summing up, here is an example Tsume Shogi position and it's JSON object representation:<br /></p><div id="r268"><table class="zeroBorder" googattrclassname="zeroBorder" id="wmvr" border="0" cellpadding="3" cellspacing="0"><tbody id="r2680"><tr id="r2681"><td id="r2682"><div id="v1sm" style="padding: 1em 0pt; text-align: left;"><img id="bi33" style="width: 182px; height: 182px;" src="http://docs.google.com/File?id=dgx8wxkr_157qbxt2cdd_b" /></div></td><td id="r2683"><blockquote id="ez3."><span id="j3wj34" class="inline_code"></span><span style="font-size:78%;">tsumeJson = {<br /> "sideOnMove":"black",<br /> "blackHand":[0,0,0,0,1,0,0,0,0,0],<br /> "whiteHand":[0,0,0,0,0,0,0,0,0,0],<br /> "pieces":[{"2a":"wK"},{"1a":"wL"},{"3c":"+wR"},{"1c":"+bB"},{"3d":"+bB"}]<br /> };</span><br /></blockquote><span id="j3wj34" class="inline_code"><br /></span></td></tr></tbody></table></div><span style="font-size:180%;">The parser<br /></span><p>JS SFEN parser is a JavaScript class that is able to translate generate Shogi position data in SFEN to JavaScript objects. The parser and it's best friend, JS Shogi Board Viewer, make it easy to put a Shogi diagram for given SFEN on your Web page.</p><p>I won't explain SFEN here. I did my best on <a href="http://code.google.com/p/shogitools/wiki/sfen_start">this ShogiTools wiki page</a> so If you are interested in the details, please check it out.<br /></p><p> The viewer consists of 2 elements:</p><ol style="margin-left: 40px;"><li>JavaScript SFEN parser class.<br /></li><li>JavaScript Shogi model classes (SFEN is translated to these objects).</li></ol>Usage of the parser is simple. You put the following line in your code, to get JavaScript object representing given position:<br /><span style="font-size:85%;"><blockquote>tsumeJson = SfenParser.parse("7r1/6B1p/6Bsk/9/7P1/9/9/9/9 B 2S");</blockquote></span>Then you send it to the viewer and voila!<br /><br />Please, <a href="http://myjavaserver.com/%7Efatboldcyclop/sp_example2.html">check out the example to see it in action</a>. You can see a Shogi board here and you are able to dynamically set the SFEN to be shown.<br /><br />The code is put inside the HTML file, so you can view the source to see what's going on there.<br /><br />I hope that someone finds it useful...<br /><br />As usual, any comment are welcomed.Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com1tag:blogger.com,1999:blog-4077618024937136731.post-3002775932184840992008-06-27T09:10:00.000-07:002008-07-05T21:50:50.291-07:00New ANTLR targetsTill now I used javacc (http://javacc.dev.java.net/), the Java Compiler Compiler, for creating my parsers.<br /><br />Like I said earlier (<a href="http://shogi-software.blogspot.com/2008/01/tsume-shogi-parser-or-how-to-store-28k.html">http://shogi-software.blogspot.com/2008/01/tsume-shogi-parser-or-how-to-store-28k.html</a>) I was hoping to try ANTLR out.<br /><br />Today I read two interesting pieces of information:<br /><ol><li>There is an IDE to develop and debug grammars, ANTLRWorks.</li><li>New (3.1) ANTLR would support JavaScript and ActionScript as targets (platforms in which parsers generated by ANTLR can run).</li></ol>It is certainly big motivation for me to check this tool out. First of all, ANTLRWorks will make designing and testing my Shogi grammars much easier and faster.<br />Secondly, new targets will allow creation of shogi games browsing/viewing software on these two very popular platforms: JavaScript and Flash/Flex.<br /><br />I am going to give it a try very soon.Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com0tag:blogger.com,1999:blog-4077618024937136731.post-15242322125087276082008-06-24T00:31:00.000-07:002009-10-27T02:02:42.640-07:00Visiting the Dark SideI've been inactive (as a blogger) for quite a time now.<br />
<br />
Due to some technical problems MyJavaServer.com didn't accept any new files. That made me search for alternative hosting site for my experiments.<br />
I couldn't find anything similar to mjs but I googled <a href="http://www.vndv.com/">http://www.vndv.com/</a> out. They give you free hosting for your PHP pages, MySQL databases, subdomains, ftp access, no advertisements, very decent user interface, tutorials. But no Java... Well, nobody's perfect :-)<br />
I spent time on toying a little bit with PHP and client side technologies.<br />
<br />
I'll show you my firs PHP page (<a href="http://fatboldcyclop.vndv.com/index.php">http://fatboldcyclop.vndv.com/index.php</a>):<br />
<br />
<blockquote><pre><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php phpinfo(); ?>
</body>
</html>
</pre></blockquote><br />
I am very proud of it :-). But seriously, I did some reading on PHP and I found it interesting. I decided to check it out later and take a closer look at client side web development with JavaScript and CSS first.<br />
My first attempt was to write JavaScript Shogi Board Viewer. I'll describe the program on this blog later. Now I'll share with you my impressions on JavaScript (JS)-- it was basically my first real contact with the language.<br />
<br />
First of all, I greatly underestimated the language. Now I think that it is a flexible, dynamic and powerful language. You can do many thing using small clever JS "tricks", but...<br />
<br />
But developing in JS is for me a road trip through hell. I managed to get used to auto complete feature of Java IDEs. In Java, which is very strict, the tool can "easily" predict what the programmer can type (object properties and methods, etc.). With JavaScript it's not so easy -- it is dynamic, method and properties can be added on the fly, etc. But IDE is only small part of the problem.<br />
The biggest pain was for me browser compatibility. I had a piece of code ruining smoothly on few browsers (i.e. FireFox 2 and 3, Opera, Safari) but IE somehow didn't like a line or two. Figuring out which line was the real challenge.<br />
<br />
Debugging JS is so difficult. Thank God for <a href="http://getfirebug.com/">FireBug</a>. It saved me a lot of time and nerves, but it comes only with FireFox. Fortunately, Opera (9.5) and IE 8.0beta also have a "cheaper" version of the tool.<br />
<br />
Another annoying thing about client side web development is CSS compliance. I tried to do simple things like having 2 text boxes next to each other. O what fun it is to make it work exactly the same in all the browsers. This one gives you an extra margin between two boxes, other resizes one box, etc. etc.<br />
By the way, I fought with IE7.0 for correct placement of pieces on the board in <a href="http://shogitools.appspot.com/html/sfen.html">my SFEN converter</a>. I won the battle but I lost the war. After I finally forced IE7 to show it right, IE8 was released. And of course, the newer version of the browser has it's own way of positioning page elements.<br />
<br />
Anyway, I'm glad I gave it a try. I learnt few things:<br />
<ul><li>I lack the imagination to think how people did it before the FireFox came to life.</li>
<li><a href="http://browsershots.org/">browsershots.org</a> is a great tool to test your web design in different browsers.</li>
<li>Trying/learning different languages opens your eyes to new possibilities. </li>
<li>JavaScript is an interesting and powerful language but using it is not such fun at all.</li>
<li>If you want to show HTML code on your blog, you could use <a href="http://francois.schnell.free.fr/tools/BloggerPaste/BloggerPaste.html">this tool</a> to make it possible.<br />
</li>
</ul>All in all it was a very educational experiment for me -- short walk on the dark side of the web development.Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com1tag:blogger.com,1999:blog-4077618024937136731.post-88755403152882442882008-06-23T05:47:00.000-07:002015-11-17T01:13:32.809-08:00Unicode for Shogi characters<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">.nobrtable br { display: none }</style><br />
To be able to translate Shogi data between formats you have to know possible piece symbols. I collected the information I could get (mainly from wikipedia.org) in the following table. Then I found (on http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml) unicode values for eaech Shogi piece.<br />
Shogi pieces<br />
<div class="nobrtable">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table border="" style="empty-cells: show;"><tbody>
<tr><th><br />
English name<br />
<br /></th><th><br />
Unicode<br />
<br />
for abbr. Kanji<br />
<br /></th><th><br />
Kanji<br />
<br /></th><th><br />
Rōmaji<br />
<br /></th><th><br />
Meaning<br />
<br /></th><th colspan="3" width="188"><br />
Abbreviations<br />
<br /></th></tr>
<tr><th></th><th></th><th></th><th></th><th></th><th><br />
Symbol<br />
<br /></th><th><br />
Kanji<br />
<br /></th><th><br />
Rōmaji<br />
<br /></th></tr>
<tr><td><br />
King (reigning)<br />
<br /></td><td><br />
738B<br />
<br /></td><td><br />
王将<br />
<br /></td><td><br />
ōshō<br />
<br /></td><td><br />
<div align="LEFT">
royal general</div>
<br /></td><td><br />
K<br />
<br /></td><td><br />
王<br />
<br /></td><td><br />
ō<br />
<br /></td></tr>
<tr><td><br />
King (challenging)<br />
<br /></td><td><br />
7389<br />
<br /></td><td><br />
玉将<br />
<br /></td><td><br />
gyokushō<br />
<br /></td><td><br />
<div align="LEFT">
jeweled general</div>
<br /></td><td><br />
K<br />
<br /></td><td><br />
玉<br />
<br /></td><td><br />
gyoku<br />
<br /></td></tr>
<tr><td><br />
Rook<br />
<br /></td><td><br />
98DB<br />
<br /></td><td><br />
飛車<br />
<br /></td><td><br />
hisha<br />
<br /></td><td><br />
<div align="LEFT">
flying chariot</div>
<br /></td><td><br />
R<br />
<br /></td><td><br />
飛<br />
<br /></td><td><br />
hi<br />
<br /></td></tr>
<tr><td><br />
Promoted rook (Dragon)<br />
<br /></td><td><br />
9F8D or 7ADC<br />
<br /></td><td><br />
龍王<br />
<br /></td><td><br />
ryūō<br />
<br /></td><td><br />
<div align="LEFT">
dragon king</div>
<br /></td><td><br />
+R<br />
<br /></td><td><br />
龍 or<br />
竜<br />
<br /></td><td><br />
ryū<br />
<br /></td></tr>
<tr><td><br />
Bishop<br />
<br /></td><td><br />
89D2<br />
<br /></td><td><br />
角行<br />
<br /></td><td><br />
kakugyō<br />
<br /></td><td><br />
<div align="LEFT">
angle mover</div>
<br /></td><td><br />
B<br />
<br /></td><td><br />
角<br />
<br /></td><td><br />
kaku<br />
<br /></td></tr>
<tr><td><br />
Promoted bishop (Horse)<br />
<br /></td><td><br />
99AC<br />
<br /></td><td><br />
龍馬<br />
<br /></td><td><br />
ryūma or ryūme<br />
<br /></td><td><br />
<div align="LEFT">
dragon horse</div>
<br /></td><td><br />
+B<br />
<br /></td><td><br />
馬<br />
<br /></td><td><br />
uma<br />
<br /></td></tr>
<tr><td><br />
Gold general (Gold)<br />
<br /></td><td><br />
91D1<br />
<br /></td><td><br />
金将<br />
<br /></td><td><br />
kinshō<br />
<br /></td><td><br />
<div align="LEFT">
gold general</div>
<br /></td><td><br />
G<br />
<br /></td><td><br />
金<br />
<br /></td><td><br />
kin<br />
<br /></td></tr>
<tr><td><br />
Silver general (Silver)<br />
<br /></td><td><br />
9280<br />
<br /></td><td><br />
銀将<br />
<br /></td><td><br />
ginshō<br />
<br /></td><td><br />
<div align="LEFT">
silver general</div>
<br /></td><td><br />
S<br />
<br /></td><td><br />
銀<br />
<br /></td><td><br />
gin<br />
<br /></td></tr>
<tr><td><br />
Promoted silver<br />
<br /></td><td><br />
5168<br />
<br /></td><td><br />
成銀<br />
<br /></td><td><br />
narigin<br />
<br /></td><td><br />
<div align="LEFT">
promoted silver</div>
<br /></td><td><br />
+S<br />
<br /></td><td><br />
全<br />
<br /></td><td><br />
—<br />
<br /></td></tr>
<tr><td><br />
Knight<br />
<br /></td><td><br />
6842<br />
<br /></td><td><br />
桂馬<br />
<br /></td><td><br />
keima<br />
<br /></td><td><br />
<div align="LEFT">
horse</div>
<br /></td><td><br />
N<br />
<br /></td><td><br />
桂<br />
<br /></td><td><br />
kei<br />
<br /></td></tr>
<tr><td><br />
Promoted knight<br />
<br /></td><td><br />
572D or 4ECA<br />
<br /></td><td><br />
成桂<br />
<br /></td><td><br />
narikei<br />
<br /></td><td><br />
<div align="LEFT">
promoted laurel</div>
<br /></td><td><br />
+N<br />
<br /></td><td><br />
(圭 or<br />
今)<br />
<br /></td><td><br />
—<br />
<br /></td></tr>
<tr><td><br />
Lance<br />
<br /></td><td><br />
9999<br />
<br /></td><td><br />
香車<br />
<br /></td><td><br />
kyōsha<br />
<br /></td><td><br />
<div align="LEFT">
incense chariot</div>
<br /></td><td><br />
L<br />
<br /></td><td><br />
香<br />
<br /></td><td><br />
kyō<br />
<br /></td></tr>
<tr><td><br />
Promoted lance<br />
<br /></td><td><br />
674F or 4EDD<br />
<br /></td><td><br />
成香<br />
<br /></td><td><br />
narikyō<br />
<br /></td><td><br />
<div align="LEFT">
promoted incense</div>
<br /></td><td><br />
+L<br />
<br /></td><td><br />
(杏 or<br />
仝)<br />
<br /></td><td><br />
—<br />
<br /></td></tr>
<tr><td><br />
Pawn<br />
<br /></td><td><br />
6B69<br />
<br /></td><td><br />
歩兵<br />
<br /></td><td><br />
fuhyō<br />
<br /></td><td><br />
<div align="LEFT">
foot soldier</div>
<br /></td><td><br />
p<br />
<br /></td><td><br />
歩<br />
<br /></td><td><br />
fu<br />
<br /></td></tr>
<tr><td><br />
Promoted pawn (tokin)<br />
<br /></td><td><br />
3068 or 4E2A<br />
<br /></td><td><br />
と金<br />
<br /></td><td><br />
tokin<br />
<br /></td><td><br />
<div align="LEFT">
reaches gold</div>
<br /></td><td><br />
+p<br />
<br /></td><td><br />
と (or<br />
个)<br />
<br /></td><td><br />
to<br />
<br /></td></tr>
</tbody></table>
<br /></div>
<span style="font-size: 130%;">Coordinates</span><br />
In KIF files the characters are Shift-JIS encoded. Characters used to describe shogi board coordinates and their unicode values are listed below.<br />
<div class="nobrtable">
</div>
<div class="nobrtable">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table border="" style="width: 185px;"><tbody>
<tr><th><br />
description<br />
<br /></th><th><br />
char<br />
<br /></th><th><br />
unicode<br />
<br /></th></tr>
<tr><td><br />
1st column<br />
<br /></td><td><br />
1<br />
<br /></td><td><br />
FF11<br />
<br /></td></tr>
<tr><td><br />
2nd column<br />
<br /></td><td><br />
2<br />
<br /></td><td><br />
FF12<br />
<br /></td></tr>
<tr><td><br />
3rd column<br />
<br /></td><td><br />
3<br />
<br /></td><td><br />
FF13<br />
<br /></td></tr>
<tr><td><br />
4th column<br />
<br /></td><td><br />
4<br />
<br /></td><td><br />
FF14<br />
<br /></td></tr>
<tr><td><br />
5th column<br />
<br /></td><td><br />
5<br />
<br /></td><td><br />
FF15<br />
<br /></td></tr>
<tr><td><br />
6th column<br />
<br /></td><td><br />
6<br />
<br /></td><td><br />
FF16<br />
<br /></td></tr>
<tr><td><br />
7th column<br />
<br /></td><td><br />
7<br />
<br /></td><td><br />
FF17<br />
<br /></td></tr>
<tr><td><br />
8th column<br />
<br /></td><td><br />
8<br />
<br /></td><td><br />
FF18<br />
<br /></td></tr>
<tr><td><br />
9th column<br />
<br /></td><td><br />
9<br />
<br /></td><td><br />
FF19<br />
<br /></td></tr>
<tr><td><br />
1st row<br />
<br /></td><td><br />
一<br />
<br /></td><td><br />
4E00<br />
<br /></td></tr>
<tr><td><br />
2nd row<br />
<br /></td><td><br />
二<br />
<br /></td><td><br />
4E8C<br />
<br /></td></tr>
<tr><td><br />
3rd row<br />
<br /></td><td><br />
三<br />
<br /></td><td><br />
4E09<br />
<br /></td></tr>
<tr><td><br />
4th row<br />
<br /></td><td><br />
四<br />
<br /></td><td><br />
56DB<br />
<br /></td></tr>
<tr><td><br />
5th row<br />
<br /></td><td><br />
五<br />
<br /></td><td><br />
4E94<br />
<br /></td></tr>
<tr><td><br />
6th row<br />
<br /></td><td><br />
六<br />
<br /></td><td><br />
516D<br />
<br /></td></tr>
<tr><td><br />
7th row<br />
<br /></td><td><br />
七<br />
<br /></td><td><br />
4E03<br />
<br /></td></tr>
<tr><td><br />
8th row<br />
<br /></td><td><br />
八<br />
<br /></td><td><br />
516B<br />
<br /></td></tr>
<tr><td><br />
9th row<br />
<br /></td><td><br />
九<br />
<br /></td><td><br />
4E5D<br />
<br /></td></tr>
</tbody></table>
<br />
<br />
<br />
<span style="font-size: 130%;">Move modificators</span><br />
The symbols used in Kifu to identify the piece to move (when there is<br />
a situation in which more then one piece of the same kind can reach<br />
given destination):<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table border="1" style="width: 387px;"><tbody>
<tr><th><br />
symbol</th><th><br />
unicode</th><th><br />
meaning</th></tr>
<tr><td><br />
直</td><td><br />
76F4</td><td><br />
move straight</td></tr>
<tr><td><br />
引</td><td><br />
5F15</td><td><br />
pull (back)</td></tr>
<tr><td><br />
上</td><td><br />
4E0A</td><td><br />
go forward (literally means “up”)</td></tr>
<tr><td><br />
寄</td><td><br />
5BC4</td><td><br />
go to the side</td></tr>
<tr><td><br />
右</td><td><br />
53F3</td><td><br />
right</td></tr>
<tr><td><br />
左</td><td><br />
5dE6</td><td><br />
left</td></tr>
<tr><td><br />
右引</td><td><br />
<br />
<br />
<br /></td><td><br />
right-back</td></tr>
<tr><td><br />
右寄</td><td><br />
<br />
<br />
<br /></td><td><br />
right-go to the side</td></tr>
<tr><td><br />
右上</td><td><br />
<br />
<br />
<br /></td><td><br />
right up</td></tr>
<tr><td><br />
左引</td><td><br />
<br />
<br />
<br /></td><td><br />
left-back</td></tr>
<tr><td><br />
左寄</td><td><br />
<br />
<br />
<br /></td><td><br />
left-go to the side</td></tr>
<tr><td><br />
左上</td><td><br />
<br />
<br />
<br /></td><td><br />
left up</td></tr>
</tbody></table>
<br />
<br /></div>
<div class="nobrtable">
</div>
<div class="nobrtable">
I hope someone finds this information useful.</div>
</div>
Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com4tag:blogger.com,1999:blog-4077618024937136731.post-8105435003334620052008-03-27T02:04:00.000-07:002008-03-27T04:22:54.375-07:00Requirements for new Shogi game formatThere seems to be great need for a single computer standard for exchanging Shogi games data.<br /><br />There has been ongoing debate on discussion board (shogi-l) for years now.<br /><br />Although the discussion tends to be difficult (like <a href="http://en.wikipedia.org/wiki/Chicken-and-egg_problem">the never ending dillema "which came first, the chicken or the egg"</a>) but the point is quite simple. After scanning the post you notice that there are just a few simple requirements to be fulfilled.<br /><br />I try to collect them here. The standard should let for the following features:<br /><ol><li>Storing multiple games in one file.</li><li>Providing game information (type of the game, players, date, event, outcome, ...) in the way that any shogi software could correctly interpret it.</li><li>Allowing to store variants.</li><li>Allowing to store comments in different languages.</li><li>Allowing to embed multimedia contents (board markups, pictures, sounds, movies) in the comments.<br /></li></ol>Except for the last (embedding multimedia) I consider them to be the core features. They have to be included into the specification. In my opinion no matter if the standard is totally new or if it's based on some existing format (Simple Game Format, Portable Shogi Notation, KIF) it needs to address the problems mentioned above.<br /><br />By the way, they seem to be easy to implement:<br /><br />Ad 1) If the single game has concise and well defined description, the games are easily distinguishable/separable. Even if it is not the case, some game separator could be introduced.<br /><br />Ad 2) The information could be provided in key/value pairs (let's not bother about their form now), for example sente:Sato Yasumitsu or [sente "Sato Yasumitsu"].<br /><br />We would have to agree on the standard set of tags (sente, gote, event, etc.). The less, the better. The standard, to be flexible and extensible, would state that other tags are allowed but are not given any special meaning. This way if one program needs to add some information that matters only to it, it uses his own tag without any side effects on other programs.<br /><br />Ad 3) There are many possibilities here. SGF and PSN uses tree-like text data structure for example. I could think of few more solutions but the actual implementation doesn't really matter. Ideally, the structure should be easy for the machines to decode but still easy enough for humans to read it.<br /><br />Ad 4) For comments we should opt for standard Unicode encoding like UTF-8.<br /><br />Ad 5) I have some reservations about number 5. It will greatly improve viewing the games with software but it also will make the format less readable by humans.<br /><br />The most important thing is to make the multimedia comments/markups optional. I imagine not every Shogi game viewer will want the feature (furthermore I believe some target devices, like simple cell-phones, won't be able to use it).<br /><br />I would split the problem of multimedia comments into two categories:<br /><ol><li>markups that don't require embedding additional data (markups for actions that are understand by viewer: drawing arrows, coloring board fields, showing hyper link, etc.)</li><li>markups that require embedding additional data (pictures, sounds, movies, etc.)</li></ol>The first category is easy. The more I think about the second category the less I am convinced it belongs to the standard ;-)<br /><br />And what do you think?Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com1tag:blogger.com,1999:blog-4077618024937136731.post-38840408167989951242008-02-12T04:55:00.000-08:002008-02-13T06:21:01.950-08:00Tsumeshogi diagrams with Kanji, part IIII finally managed to finish PDF collection of 300 Tsumeshogi problems with pieces represented by Kanji characters (http://shogitools.googlecode.com/files/tsume_collection_0_3.pdf).<br /><br />Now I am starting to validate the data. It turns out that there are few mistakes in the input data.<br /><br /><span style="font-size:130%;">Missing tsume</span><br />I produced the collection from problems posted weekly on Shogi-l by Reijer Grimbergen.<br />There was 50 "episodes", 6 problems each which gives 300 problems. I dug the posts from our archives.<br />I found out that the 35th part of the series was missing from the archives -- or at least I couldn't find it.<br /><br /><span style="font-weight: bold;">Does anyone, by any chance has a copy of the post or the 6 problems?</span><br /><br /><span style="font-size:130%;">Errors in definition</span><br /><span style="font-size:100%;">The second problem are errors in the definition. Some problems posted on shogi-l have clearly mistaken data:<br /><br /></span>Problem 103:<br />Black: S3d, S2c, P1f In hand: B, G<br />White: <span style="font-weight: bold; font-style: italic;">K2d</span><span style="font-style: italic;">,</span> B5a, L1c, L1b, P3d, <span style="font-weight: bold; font-style: italic;">P2d</span><br /><a href="http://www.myjavaserver.com/%7Efatboldcyclop/sfen_ggl.jsp?notsume=true&sfen=4b4%2F8l%2F7Sl%2F6pp1%2F9%2F8P%2F9%2F9%2F9+B+GB#diagram">diagram</a><br /><br />Problem 138:<br />Black: +B3d, B1d, <span style="font-weight: bold; font-style: italic;">N1a</span><span style="font-style: italic;">,</span> L4c In hand: N<br />White: K2b, <span style="font-weight: bold; font-style: italic;">N1a</span>, P1c<br /><a href="http://www.myjavaserver.com/%7Efatboldcyclop/sfen_ggl.jsp?notsume=true&sfen=8n%2F7k1%2F5L2p%2F6%2BB1B%2F9%2F9%2F9%2F9%2F9+B+N#diagram">diagram</a><br /><br />Problem 198:<br />Black: R3a, B4e, <span style="font-weight: bold; font-style: italic;">S4b</span><span style="font-style: italic;"> </span> In hand: R<br />White: K2b, G1c, <span style="font-weight: bold; font-style: italic;">S4b</span>, N2a, L1b, P2e<br /><a href="http://www.myjavaserver.com/%7Efatboldcyclop/sfen_ggl.jsp?notsume=true&sfen=6Rn1%2F5s1kl%2F8g%2F9%2F5B1p1%2F9%2F9%2F9%2F9+B+R#diagram">diagram</a><br /><br />Problem 297:<br />Black: R3f, <span style="font-weight: bold; font-style: italic;">S1d</span><span style="font-style: italic;"> </span> In hand: G, 2S<br />White: K3d, +B4b, G2e, L1a, P3b, <span style="font-weight: bold; font-style: italic;">P1d</span><br /><a href="http://www.myjavaserver.com/%7Efatboldcyclop/sfen_ggl.jsp?notsume=true&sfen=8l%2F5%2Bbp2%2F9%2F6k1p%2F7g1%2F6R2%2F9%2F9%2F9+B+2SG#diagram">diagram</a><br /><br /><span style="font-weight: bold;">Does somebody have any ideas how the problems should look like?</span><br /><br /><br /><span style="font-size:130%;">Mistakes in the problems</span><b><br /></b>There could be some mistakes in the problems themselves. I found the two while browsing the archives (http://www.shogi.net/shogi-l/Archive/1993/Njan27-01.txt, http://www.shogi.net/shogi-l/Archive/1993/Njan27-02.txt). I made required corrections to problems:<br />12. 7l1/6k2/7p1/6p2/6N2/7+pP/9/9/9 B SGR<br />44. 9/6p2/5B1g1/5p2R/6k2/9/6S2/9/9 B B<br /><br /><br />If you find any errors while solving the problems, please drop a note on Shogi-l, or as a comment to this post.<br /><br />Thanks in advance!Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com0tag:blogger.com,1999:blog-4077618024937136731.post-59724653297700285782008-02-07T10:31:00.000-08:002008-02-13T04:58:22.338-08:00Tsumeshogi diagrams with Kanji, part II<h2>The delay</h2>As I wrote earlier I had been planning to produce this version of "my" Tsumeshogi Collection for a long time now. The only thing that was putting me off was weird interpretation of "reference-orientation" XSL-FO attribute. <a href="http://www.w3schools.com/xslfo/prop_reference-orientation.asp">The specification describes it as follows:</a><br /><p>The reference-orientation property defines the direction for top for the content-rectangle of the reference-area.</p><table border="1" cellpadding="3" cellspacing="0" width="100%"><br /><caption>Property Values</caption><br /><tbody><tr><th align="left" valign="top" width="20%">Value</th><th align="left" valign="top" width="80%">Description</th></tr><br /><tr><td valign="top">0</td><td valign="top">Default. The orientation of this area has the same orientation as the containing reference-area</td></tr><tr><td valign="top">90</td><td valign="top">The orientation is rotated 90 degrees from the orientation of the containing reference-area</td></tr><tr><td valign="top">180</td><td valign="top">The orientation is rotated 180 degrees from the orientation of the containing reference-area</td></tr><tr><td valign="top">270</td><td valign="top">The orientation is rotated 270 degrees from the orientation of the containing reference-area</td></tr><tr><td valign="top">-90</td><td valign="top">Same as specifying 270</td></tr><tr><td valign="top">-180</td><td valign="top">Same as specifying 180</td></tr><tr><td valign="top">-270</td><td valign="top">Same as specifying 90</td></tr></tbody></table><br />The first problem was that in Apache FOP using -90, -180 and -270 as reference-orientation instead of 90, 180 and 270 resulted in content being drawn outside its block.<br /><h2>The first results</h2><p>The commercial equivalent of FOP, RenderX' XEP, did better in this area. I used to produce my <a href="http://shogitools.googlecode.com/files/tsume_collection_0_2.pdf">first version of the collection with Kanji for the Shogi pieces</a>.</p><h2>The power of the Open Source community</h2>Although XEP is a decent piece of software (and the company provides free personal edition) I decided to keep on looking for open source alternative.<br /><p><a href="http://lists.w3.org/Archives/Public/www-xsl-fo/2008Feb/0002.html">I described what I am doing and I asked the question</a> about the strange FOP behaviour on public w3.org lists. I didn't have to wait long for the answer. Jeremias Maerki <a href="http://lists.w3.org/Archives/Public/www-xsl-fo/2008Feb/0003.html">informed me</a> that the situation I described is a known bug in Apache FOP which hasn't been resolved yet.</p><p>Bad news, but at least I finally knew what is going on...</p><p>The same day, few hours later, Jeremias posted his second answer: he fixed the bug!</p><p>After downloading the newest version of FOP from Apache's site I am now able to produce the collection the way I wanted to.<br /></p>Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com0tag:blogger.com,1999:blog-4077618024937136731.post-26887833553940530852008-02-04T10:33:00.000-08:002008-02-07T10:16:44.813-08:00Tsumeshogi diagrams with KanjiI have just found a PDF (from xsl-fo) renderer which properly handles rotated text in tables.<br /><br />I produced Tsumeshogi collection with 300 problems using "international" symbols. After that I decided to do the same thing using Kanji characters.<br /><br />The PDF generator I used, Apache FOP, acted strange when it came to rotated characters (the idea was to use Kanji representation for Shogi diagrams, black pieces heading up, white pieces upside down). So I gave up.<br /><br />Few days ago I found out, that there is a commercial implementation of PDF renderer (fortunately, they also provied "personal licence") -- RenderX's XEP (<a href="http://www.renderx.com/tools/xep.html">http://www.renderx.com/tools/xep.html</a>).<br /><br />Thank's to this piece of software I will soon be able to produce my Tsumeshogi collection using Kanji characters.<br /><br />Just give me a day or two...Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com2tag:blogger.com,1999:blog-4077618024937136731.post-54918037780354495512008-01-27T00:08:00.000-08:002008-06-19T11:45:52.687-07:00Installing Oracle XE on openSUSE LinuxDespite what I have read on the net it was quite easy. I decided to put the information on the net in case I would have to repeat the procedure. And maybe someone else would need the information...<br /><br />First I'll tell you what machine I use, then I'll show you what I did.<br /><h3>The machine</h3>I use HP Compaq 6710b laptop, with 2G of RAM. Inside the machine is the Intel® Core™2 Duo T7300 2GHz processor.<br />There is Windows Vista preinstalled in it, but I decided to use OpenSuse (10.3) Linux as my development environment.<br /><br /><h3>Installation procedure</h3>You could summarize the whole process in 3 steps:<br />1. Obtaining the installation file.<br />2. Installing Oracle XE and required libraries.<br />3. Configuring Oracle instance.<br /><br />In my case the procedure went as follows:<br />1. I downloaded Oracle XE for Linux x86 (http://www.oracle.com/technology/software/products/database/xe/htdocs/102xelinsoft.html). I chose oracle-xe-univ-10.2.0.1-1.0.i386.rpm.<br /><br />2. Logged as the root I run the installer. Everything went smooth except for the database didn't run. I checked the installation guide (I know, I should have done it earlier :-) ) and it turned out that this Oracle distribution requires libgc and libaio libraries.<br /><br />I ran software management program (/sbin/yast2 --install) that lets you see and modify software components installed on your openSUSE.<br />In my case the libraries where absent so I looked for them on openSUSE Build Service pages (http://software.opensuse.org/searchand), downloaded and installed them.<br /><br />3. The final step, according to the manual was running the provided configuration script. So I did, as the root, ran<br /><br /> /etc/init.d/oracle-xe configure<br /><br />I chose the default options when prompted and set up the password for sys and system users:<br /><blockquote> Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]:y<br /> Starting Oracle Net Listener...Done<br /> Configuring Database...Done<br /> Starting Oracle Database 10g Express Edition Instance...Done<br /> Installation Completed Successfully.<br /> To access the Database Home Page go to "http://127.0.0.1:8080/apex"<br /></blockquote>I tried to run the database's home page by running FireFox and entering http://127.0.0.1:8080/apex address.<br /><br />Unfortunately I couldn't log in (I probably did something wrong but I am not sure what was it -- maybe just misspelled the password during log-in),<br />so I opened "Run SQL command line" and typed: <br /><blockquote>conn sys as sysdba <password entered="" while="" configuring="">;<br /> alter user system identified by <password>;<br /> alter user sys identified by <password>;</password></password></password></blockquote><password entered="" while="" configuring=""><password><password>After this maneuver I retried entering user/password and finally successfully logged into the database's home page.<br /><br />Like I said, I am not sure if the last step (resetting the password) was necessary. When I have a chance to run the installation again I'll correct the information.<br /><br />Have fun with Oracle on openSUSE!</password></password></password>Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com12tag:blogger.com,1999:blog-4077618024937136731.post-73000487144027401622008-01-25T21:27:00.000-08:002008-02-03T09:10:39.557-08:00New Shogi Tools banner<img style="float:left; margin:0 10px 10px 0;width: 400px;" src="http://fat.bold.cyclop.googlepages.com/shogitools_banner_alpha.png" border="0" alt="" /><br /><br /><br />A friend of mine was so kind to make a banner for my Shogi Tools project.<br /><br /><br />I put the banner on the project's page. I also used it on www.myjavaserver.com/~fatboldcyclop/sfen_ggl.jsp.<br /><br />Thanks Yummy!Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com1tag:blogger.com,1999:blog-4077618024937136731.post-39144204077752288142008-01-23T07:00:00.000-08:002008-01-23T07:05:45.580-08:00Learning from our Go colleaguesTrying to figure out the way to increase popularity of Shogi I also look for already proved solutions.<br /><br />I took a close look at Go world. The game, much like Shogi, is of Asian origin. And it is quite popular all around the world.<br /><br />It quickly turned out that there are quite a few thinks to be envy about. Few things and activities in the Go community.<br /><br />I'll try to describe them shortly here as an entry point to the discussion if the ideas would work in Shogi world.<br /><br /><h1>SGF</h1> <br />SGF is the abbreviation of 'Smart Game Format'.<br /><br />It is the least important of the things I bring up here, but still. Go guys have worked out a standard for storage and presentation of their games. (Of course, as our world is not perfect, there are few flavours of the standard.) The format allows them to discuss comment and discuss games on the net and off-line.<br />SGF provides many features such that strongly suppor this:<br /><ul><li>board markup,<br /></li><li>comments,<br /></li><li>game information,<br /></li><li>setup positions,</li><li>variations etc.<br /></li></ul>You can, for example, draw arrows indicating lines of attack, markup some pieces that play a special role in a given position, etc.<br /><br />Like I said, the standard itself may not be a big thing, but it let's them to communicate more easily and it also "gave birth" to many game viewer and editor programs.<br /><h1 class="title">The Go Teaching Ladder</h1>Now, here is a thing I personally admire a lot. As the site states itself, after several high dan players have recommended getting your own games reviewed by stronger players as a good way to make progress, some guys came up with idea to do it over the net.<br />Volunteers in the ladder comment games made by weaker players. Anyone may submit a game for commenting by a stronger player. <br />The service is totally free and community based. This is possible, because many advanced Go players are eager to teach weaker players.<br />This way weak players benefit from their advice and advanced player benefits from teaching as well.<br /><br />Isn't it something?<br /><br /><h1>Sensei's Library</h1><br />Sensei's Library is meant to be a place where Go players can meet to find information, contribute information and discuss any items related to the game. This is a Wiki which everybody is welcome to edit. There are problems with it but I think the idea is great.<br /><br />There is wealth of information there, whether you are looking introduction to the game, some player's bio, problems to solve -- it's here.<br /><br /><h1>goproblems.com</h1><br />goproblem.com is a base with problems to solve on-line (currently 5467 problems).<br />The problems are divided by genre and difficulty. The system measures two types of difficulty and it's "coolness". The difficulty is expressed as: x/y where x is the percentage of people who've gotten this problem <i>wrong</i> and y is the average number of seconds it took people to solve the problem correctly. Coolness is a way for people to judge the problem subjectively.<br /><br />While you solve the problems your rating is recalculated. You have also access to statistics of your progress.<br /><br />Another cool thing is that the system let's its users to dynamically shape the database itself. You can do it by adding new problems.<br />Problems submitted by users wait in the sandbox. Other people play with the problems there and you, as an author, can read people's comments to see if there are any issues with your problem. Also, an examination of the attempt paths will show you where some areas may need to be improved (if a common attempt path has not been accounted for in the problem).<br /><br /><br /><h1>Would it work for Shogi?</h1><br />Here are my thoughts.<br /><br />Having standard for game storage and annotation would be useful but is not essential.<br /><br />Teaching Ladder is a great idea. Unfortunately I think it won't work for us. The community is too small.<br /><br />Site like Sensei's Library would be great. There is often a situation with "normal" sites that the author looses interest in maintaining it (or doesn't have time, etc. etc.). With Wiki this would be not a problem as anybody (or at least "more people") can make the site live.<br /><br />As for goproblems.com, people claim to gain much play strength by solving the problems systematically. I think the same is true for Shogi.<br />I'd love to have this kind of server for Shogi. In fact, I'd want it so badly that I think I could write one myself ;-)<br /><br /> What do You think?<br /><br /><br /><h3>Links</h3><br />SGF definition -- http://www.red-bean.com/sgf/<br />Go Teaching Ladder -- http://gtl.xmp.net/<br />Sensei's Library -- http://senseis.xmp.net/<br />Go Problems -- http://www.goproblems.com/Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com3tag:blogger.com,1999:blog-4077618024937136731.post-39298387741254898902008-01-18T23:38:00.001-08:002009-10-27T02:04:50.143-07:00Shogi FEN -- similar works<h1>Different FEN</h1><br />
After publication of the post about my proposal for Shogi positional data storage standard, there was some comments on shogi-l.<br />
Bernhard C. März pointed out that there is similar way of storing Shogi positions described earlier. He gave a link to the archived shogi-l message: <a href="http://www.shogi.net/shogi-l/Archive/2002/Nsep29-03.txt" target="Other">http://www.shogi.net/shogi-l/Archive/2002/Nsep29-03.txt</a>.<br />
The description differs from mine in 'pieces in hand' part.<br />
<br />
There was some discussion about the approach.<br />
<blockquote><br />
>> > *fat bold cyclop* wrote:<br />
>> > > I think the only flaw of it is, I think, it insufficient for<br />
>> > > storing positions with more than 9 pieces in hand.<br />
>> > In my opinion, this is a rather serious problem.<br />
>><br />
>> Just use A, B, C, ..., H for 10 through 18.<br />
>><br />
>> Using A through F for 10 to 16 is pretty standard (hexadecimal).<br />
>> This particular extension seems rather obvious.<br />
<br />
I have implemened a FEN notation in MacShogi 2 years ago, but I don't<br />
have added the GUI part to use it yet.<br />
<br />
I first have chosen the hexadecimal option to store the number of<br />
pawns in hand but finally, I have preferred to use only digits.<br />
<br />
The algorithm is pretty simple for pawns: the pieces in hand part in<br />
the notation has 7 digits in all, one digit for each piece type,<br />
except for the pawn where 2 digits can be used. So, if the string<br />
contains 8 digits, the pawn number uses 2 digits, otherwise only one<br />
digit is used for the number of pawn pieces.<br />
<br />
It works well. But this is only a matter of personal choice.<br />
</blockquote><br />
<br />
<h1>Another SFEN</h1>Tord Romstat devised http://www.glaurungchess.com/shogi/usi.html (draft dated 2007-01-24).<br />
Both approaches seem to be identical. Both in contents and name :)Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com0tag:blogger.com,1999:blog-4077618024937136731.post-1714828710083720592008-01-13T00:58:00.000-08:002009-10-27T01:57:09.855-07:00Proposal: Standard for storing Shogi position information<blockquote>Foreword: I know that similar work have been undertaken by different people already.<br />
I don't claim I am inventing something that others didn't think of before. If you know some sources I'd be glad to put links to them in this post.<br />
</blockquote><br />
<br />
That said, I move on to the subject with is a proposal of standard for storing positional data in Shogi. I called it Shogi FEN (or SFEN) because it is derived from FEN standard designed for chess. I write more about the standard itself <a href="http://code.google.com/p/shogitools/wiki/sfen_start">on ShogiTools project's wiki</a>. Here I try to advocate the need for a standard like SFEN.<br />
<br />
<h2>Do we need such a standard</h2>I think it is very important to have a standardized way to write Shogi positions. This way data are easily exchanged between programs. Let me give you some examples:<br />
<ol><li>Imagine you have a database program that stores tsume Shogi problems. Your computer is Mac with English OS, your friend has Japanese Windows and he uses different database program and you want to share the problems with him.</li>
<li>You post some positions from games of masters as a diagram on your web page using some flash application. The application is faulty and you want to switch to other program, let's say Java applet.</li>
<li>You want to have a test suit of 100 positions for benchmarking different Shogi engines.<br />
</li>
</ol>In all these situations, if there is a standard way to store positional data, there is no additional work required on your side. Otherwise there should be some conversion mechanism provided. Moreover, to be able to convert between proprietary standards you have to know them both.<br />
<br />
<h2>What's so good about SFEN</h2>Nothing :-). At least nothing until it becomes a standard. But what are the 'pros' of it?<br />
<br />
It's more compact than traditional ASCII-diagram notation. The whole position data fits a sigle text line. In my opinion they are also easier to interpret by programs and quite readable by humans at the same time.<br />
<br />
The idea of similar standard succeeded in chess world. I think we could learn from their experience and adopt similar solution.<br />
<br />
<h2>Why wouldn't we want SFEN</h2>I can think about only one good reason: "We already have a good standard for this and don't need another one".<br />
<br />
If this would be the situation, I probably wouldn't bother making this post. But, as I see it, there are some solutions 'on the market', but:<br />
<ol><li>They are not really standards -- there is many flavors of single 'standard'.</li>
<li>There is no formal specification for them -- at least none non-Japanese.</li>
</ol>If you know of some standards, real or almost real, their specification on the net, please drop me a note. I'll be happy to post links to them and discuss them here.<br />
<br />
<h2>Live demo</h2><br />
I prepared <a href="http://shogitools.appspot.com/html/sfen.html">a site where you can see SFEN in action</a>.<br />
<br />
It's a nice moment for me, because the puzzles of my ShogiTools project start to fit together. In my earlier post <a href="http://shogi-software.blogspot.com/2008/01/tsume-shogi-parser-or-how-to-store-28k.html">about Tsume Parser</a> I described how I translated tsume problems from shogi-l into computer-readable form.<br />
<br />
Here I used the product of that project and made a simple converter to SFEN data.<br />
<br />
Finally, I put all (almost 300) tsume on the page. You can see on-line SFEN to diagram conversion (and solve some tsume at the same time! ;-) ).<br />
<blockquote><br />
<b></b><br />
<b style="font-weight: bold;"><s>Note. </s></b><span style="font-weight: bold;"><s>When runing applications, don't worry if you see something like </s></span><i style="font-weight: bold;"><s>Can't contact servlet runner at 127.0.0.1:6905</s></i><span style="font-weight: bold;"><s>. MyJavaServer.com does this kind of things from time to time. Wait few moments and try again.</s> MyJavaServer is down for good. The example has been moved to Google AppEngine.</span><br />
<br />
<span style="font-weight: bold;"></span><br />
<span style="font-weight: bold;"><s>Note 2. </s></span><s>The page is best viewed with Mozilla browser. I could force Internet Explorer to cooperation. The elements are slightly misplaced.</s> I think I finally won the IE battle.<br />
</blockquote><br />
<br />
<h2>Other works</h2>After publication of the post there was some comments on shogi-l.<br />
Bernhard C. März pointed out that there is similar way of storing Shogi positions described earlier. He gave a link to the archived shogi-l message: <a href="http://www.shogi.net/shogi-l/Archive/2002/Nsep29-03.txt" target="Other">http://www.shogi.net/shogi-l/Archive/2002/Nsep29-03.txt</a>.<br />
<br />
<br />
<br />
Thank you for your attention. As always -- any comments and suggestions are welcomed.Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com1tag:blogger.com,1999:blog-4077618024937136731.post-28581304343061186292008-01-07T01:32:00.000-08:002009-10-25T22:30:10.611-07:00What we can do to make Shogi more popular?Shogi is a great game. No doubts about it. But Shogi is mainly played in Japan. There are some, maybe thousands, enthusiasts outside Japan.<br />
Where this disproportion comes from?<br />
The Japanese group is naturally highly privileged. Shogi is native to Japaneses. There is wealth of information for them: books, theoretical materials, web sites, online game servers. In presence of such an obvious and natural division I will try consider the subject separately for both groups. But before that, let us consider what makes people attracted to the game.<br />
<h2>What makes us attracted to the game</h2>I think there are several factors that make an ordinary man a board game fan. I am new to Shogi but I can judge from my experience with chess.<br />
<br />
As I contemplate the matter I become to think that on of the most important things is a <span style="font-weight: bold;">hero</span>. We like to have someone we admire, whose steps we follow, who is an example for us.<br />
In chess we had our Titans. Capablanca, Tal (the magician of Riga, genius tactician and attacker, my favourite), Alekhine (timeouted to have his 6 teeth extracted during world championship match to come back and win it!), Fisher (great individuality, the man who broke Soviet chess domination lasting for decades), Kasparov (great charisma, some claim that he is the best chessplayer of all time).<br />
<br />
I am sure there are plenty of Shogi Heroes out there. But I cannot read a single line about them. Except news posted on discussion board by Mr. Manabu Terao or Mr. Reijer Grimbergen (sorry if I failed to mention other people that try to help us in similar way) there is no information in English.<br />
<br />
So, heroes was one thing. The second thing is the <span style="font-weight: bold;">community</span>. We need to share our joy from the game. We want to hear how others are doing, what's the latest news in 'our world'. We want to share tips, how to improve. We want to meet to play a game or two (over the board or via Internet). I think there is no need to dwell on this one -- it's quite obvious.<br />
<br />
The third think is the <span style="font-weight: bold;">struggle for improvement</span>. We love to prove to others that we are good at our game. And we have a chance to do it in very civilized way: by winning a game. There is healthy competition between us and that's good. But there is even more. We struggle with ourselves to get better. We learn from our mistakes, from books, from the articles on the net.<br />
<br />
But wait. How can we learn from our mistakes when there is virtually no Shogi software to store and browse our non-Japanese games? How can we read articles when we don't know the language?<br />
<br />
There are probably many more reasons that make us interested in a game. Some more important then the others. I just mentioned the reasons I consider most important. I also tried to point out what blocks the factors to make the game of Shogi more popular outside Japan.</p><br />
I think there something we can do about it.<br />
<h2>So, what Japaneses could do?</h2>First of all, make the information flow. Let us know what is going on in Shogi world? How the fight for dominance is going between masters? How our heroes are doing?<br />
The Japan Shogi Association (JSA, http://www.shogi.or.jp/) page is Japanese only. If I am not wrong (and I cannot confirm it, because there is no English information about it) it is the main Shogi federation. I think it is reasonable to require international version of the site from them.<br />
I don't know if there are any, but chess world has few news sites. The most notable, in my opinion, is chessbase.com. Similar site for Shogi would be great.<br />
<br />
Second thing is: share your knowledge. There are people doing this already -- you can see their effort on http://shogi-shack.net/default.aspx, http://shogi.typepad.jp/eweblog/ or http://www.teu.ac.jp/gamelab/SHOGI/shogipage.html.<br />
<br />
The third thing: translate some software.<br />
<br />
The forth: play Shogi with us. Kick our butts so we can learn new ways of doing it.<br />
<br />
<h2>So, what Gaijins could do?</h2>Well, we could learn Japanese. I never tried it myself but I think it's is quite reasonable. Shogi is a part of Japan culture and it's an opportunity to get it now better.<br />
<br />
Before we learn Japanese, though, we could do one simple thing. We can ask our Japanese friends to do all the things we think could help spread Shogi over the world (see above). We could write to JSA and ask them to translate their site.<br />
<br />
And, of course, we can try to help ourselves. Once there was this great effort, the Shogi portal called shogi.net. It seems to be dead right now (last update December 2004). Why don't we revitalise it or try something similar?<br />
<br />
From what I see on shogi-l, there are some folks that are eager to write some new Shogi software. If there is any way to help, we should try.<br />
<br />
OK, that's all for this short divagation.<br />
<br />
Any comments are welcome...Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com4tag:blogger.com,1999:blog-4077618024937136731.post-23137855840267714742008-01-03T23:03:00.000-08:002009-10-25T12:31:26.000-07:00Tsume Shogi Parser (or "How to store 28k of data into 802k file and be happy about it")<h1>What is Tsume Shogi Parser? </h1>I am a huge shogi patzer. I am also a poor Java programmer. Well, all in all, I am a miserable creature. But even though I am so old that I remember the era of black&white TV, I think I can improve. (Not in being miserable, I mean. The other way.)<br />
<br />
I wanted to strengthen my shogi skills by solving mating problems. You would be surprised how hard it is to find some good materials on the net. If you have some experience with Go or Western Chess you think that the Internet is the ultimate source for this kind of stuff. You couldn't be more mistaken -- at least when you don't read Japanese.<br />
<br />
Fortunately, there are good folks out there. Shogi-l email discussion list is a place where people like these meet. Reijer Grimbergen, i.e., posted series of 300 tsume shogi problems. Roger Hare was so kind to collect some of them into a single file:<br />
<div align="center"><a href="http://www.shogi.net/arc/shogi-l/tsume_faq.txt">http://www.shogi.net/arc/shogi-l/tsume_faq.txt</a>. <br />
</div><br />
That's how I got my learning materials. The only problem left was it's form:<br />
<pre>...
4. Black: R4d, +B4c, +P2a In hand: G
White: K2c, G3c, S4b, L1b, P4a
5. Black: R2b, G3e, S3a, L2e In hand: None
White: K3c, G4c, S1d, P4e
...
</pre><br />
A beginner like me could use some more "visually attractive" format. By the way, it's a human nature I think: people always want more. First I complained that there are no materials at all, and then (after I found them) I wanted them to be full of diagrams and nicely formated.<br />
Anyway, that's how I decided to write a converter for the problems. I called it Tsume Shogi Parser.<br />
<h2>The process</h2>Tsume Shogi Parser is intended to be a building block to use in other applications (these applications are meant to provide user interface for user convenience). In the near future I plan to provide a web app that would allow the user to upload a text file and get the resulting pdf. The parser could also be used in shogi game database to produce handouts on the fly.<br />
<br />
Ok, let's face it. The parser will be not for much use. After all, there is only one source of data stored in this format. I treat this thing as an exercise before more important challenge: writing a parser for "This week in Shukan Shogi" posted by Reijer Grimbergen on <a href="http://groups.google.com/group/shogi-l">shogi-l</a>. The second benefit from it is trying out the part that generates pdf. That's IS going to be useful in other projects.<br />
<br />
Let's go back to the parser. For know I’ll describe the inner mechanics of the Tsume Shogi Parser.<br />
<br />
<h3>Technologies</h3>For this piece of software I chose to use:<br />
<ul><li>Java -- of course ;-),<br />
</li>
<li>JavaCC -- for defining the input file grammar and automatically generate a parser,</li>
<li>XML -- for storing the data into format that can be converted into virtually anything else,</li>
<li><a href="http://jibx.sourceforge.net/">JiBX</a> -- for translating Java objects to XML (marshaling)</li>
<li>XLS-FO -- for storing information about expected layout of the handout,</li>
<li>XSLT 2.0 -- for defining a way of injecting tsume data to layout template,</li>
<li>Saxon -- the only XSLT processor I know that supports XSLT 2.0,<br />
</li>
<li>Apache FOP -- for generating PDF.</li>
</ul>So, the process can be diagrammed as follows:<br />
<br />
<pre>Shogi-l file->(.jj + javacc + jibix)->xml file->(xslt 2.0, saxon)->(fo, fo)->pdf
and in the future
-> spd, psn
-> database</pre><h3>Reading tsume</h3>I have put all the tsume problems I found on shogi-l (most of them posted by <a href="http://www.teu.ac.jp/gamelab/index.html">Reijer Grimbergen</a>) to a single file. If you're interested in it, you can <a href="http://shogitools.googlecode.com/files/tsume.fulllist.txt">download it from Tsume Shogi Project download pages</a>. I also collected in a single file <a href="http://shogitools.googlecode.com/files/tsume.fulllist.answers.txt">the answers for the tsume problems</a>.<br />
<br />
Then I wrote a JavaCC grammar for the file -- I made the computer understand what which field in the file meant. You can see the grammar on the ShogiTools project's wiki.<br />
<br />
It was my first contact with parsers and it cost me a lot of sweat. I am still no expert here but I manage to write a simple grammar and generate a parser from it. JavaCC is of great help here. It automates most of the work so you can focus on the merit, although I had lots of problems with it. Partly because I was a beginner in the matter of parsers, partly because of lousy project documentation and community support. I've read that similar program, ANTLR, is much better in these matters. Next time I should try it so I could make an honest comparison. (If you can share your experience in the subject, please, drop me a note. <br />
<br />
The thing is, that with the help of JavaCC and JavaCC Eclipse Plugin I generated a program that read tsume problem file and stored it in memory in Java objects. (The class diagrams of the value object used for it should be on ShogiTools pages.)<br />
It turned out that the input data was a bit inconsistent in form. The parser showed few places and I had to do some corrections by hand. But this was not a big problem.<br />
<br />
<h3>Producing XML</h3>Now I wanted the data stored into an XML file.<br />
<br />
Why XML? It is license-free, platform-independent and well-supported. Also because of the promise of easy transformations to presentation formats (without coding).<br />
<br />
Anyway that's what the theory says. I wanted to see this in practice.<br />
<br />
The process of transforming the memory representation of an object to a data format suitable for storage or transmission is called <a href="http://en.wikipedia.org/wiki/Marshalling">Marshaling</a>. So I typed "fastet marshaller" into google search engine and got JiBX on pole position. And I used JiBX.<br />
<br />
The interesting thing about JiBX is it's byte-code injection mechanism. In short: you define the mapping between classes and the XML. Then the mapping information is injected into your existing classes' bytecode. This means you can structure the Java classes the way you want -- they doesn't need to match the structure of the XML. It also turns out that this is a fast way do the conversion.<br />
<br />
This part was quite quick. The program read 11k of tsume definitions and spat out 802 kB XML file. The description of XML structure can be found on ShogiTools pages.<br />
<h2>The output</h2>So, what is so good about having such a huge file instead of small one? And why it is so big?<br />
<br />
Let's compare the entry for a single position in input text file and output xml file.<br />
The text entry goes like this:<br />
<blockquote>1. Black:+B3d, +B1c In hand: G<br />
White: K2a, +R3c, L1a<br />
</blockquote><br />
Equivalent XML fragment is:<br />
<blockquote><pre><Position>
<number>1</number>
<BlackDescription>
<PiecesPositions>
<PiecePosition>
<Piece>
<isPromoted>true</isPromoted>
<rank>B</rank>
</Piece>
<col>3</col>
<row>d</row>
</PiecePosition>
<PiecePosition>
<Piece>
<isPromoted>true</isPromoted>
<rank>B</rank>
</Piece>
<col>1</col>
<row>c</row>
</PiecePosition>
</PiecesPositions>
<Hand>
<Piece>
<isPromoted>false</isPromoted>
<rank>G</rank>
</Piece>
</Hand>
</BlackDescription>
<WhiteDescription>
<PiecesPositions>
<PiecePosition>
<Piece>
<isPromoted>false</isPromoted>
<rank>K</rank>
</Piece>
<col>2</col>
<row>a</row>
</PiecePosition>
<PiecePosition>
<Piece>
<isPromoted>true</isPromoted>
<rank>R</rank>
</Piece>
<col>3</col>
<row>c</row>
</PiecePosition>
<PiecePosition>
<Piece>
<isPromoted>false</isPromoted>
<rank>L</rank>
</Piece>
<col>1</col>
<row>a</row>
</PiecePosition>
</PiecesPositions>
</WhiteDescription>
</Position>
</pre></blockquote><br />
The second fragment is huge. It is well structured, data are organized in logical chunks. You may ask here: So what!?<br />
<br />
And I agree. It's is no good to have kosher data structures for the sake of kosherness only. The real issue is what you can do with the data. There are the benefits of data conversion. Let me show you how our XML can be transformed.<br />
<br />
My first try was to write XSL transformation to get an ASCII diagrams of the positions. For the given position (XML fragment above) I got this:<span style="font-size: 100%;"><br />
</span><br />
<pre>1.
White in hand:
9 8 7 6 5 4 3 2 1
+---+---+---+---+---+---+---+---+---+
| | | | | | | | wK| wL|a
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | |b
+---+---+---+---+---+---+---+---+---+
| | | | | | |+wR| |+bB|c
+---+---+---+---+---+---+---+---+---+
| | | | | | |+bB| | |d
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | |e
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | |f
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | |g
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | |h
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | |i
+---+---+---+---+---+---+---+---+---+
Black in hand:G
</pre><br />
The whole file can be <a href="http://shogitools.googlecode.com/files/big_tsume_collection.txt">downloaded from here</a>.<br />
Surly, we can do better than this! Well, we're almost there :-) This ASCII diagram thing was just a warm up before writing XSLT to produce PDF file. First I had to do xsl-fo my homework. For the PDF renderer I chose apache FOP which is quite well documented. So, I was able to learn some xsl-fo from apache documentation. I also used w3schools tutorials (http://www.w3schools.com/xslfo/default.asp).<br />
I wanted my tsume shogi handout to have 6 problems per page and some tsume definition as an introduction. It was quite a bit of tedious work but I think it was worth it.<br />
Judge for yourself. Here is <a href="http://shogitools.googlecode.com/files/tsume_collection_0_1.pdf">the output pdf file</a>.<br />
<br />
<br />
<h2>Future development</h2><br />
I have my handouts for doing some shogi exercises off-line. My goal is reached so I stop my experiments for now. Instead I will list possible improvements below. <br />
<br />
The pdf I managed to produce has English description of pieces on the board (i.e. wG for white gold, bK for black king). I could use Kanji characters instead. But first I need to know the unicode for each piece character and own some unicode font.<br />
<br />
The whole thing is not a big deal. But during the process of converting my tsume text files into pdf I managed to learn few things. I think I also broke fresh ground for future conversion component that could be used in shogi programs. Imagine, you have your shogi database and you are able to add ability to render you games in the format you need just by supplying suitable transformation (XSLT) file.<br />
<br />
<br />
<br />
See You next time...Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com4tag:blogger.com,1999:blog-4077618024937136731.post-45414305987298083032008-01-01T22:57:00.000-08:002009-10-25T11:34:09.100-07:00Shogi Tools<h1>Who is Fat Bold Cyclop?</h1><br />
My real-life alter ego works in the software industry, has a beautiful wife, two great kids and a dog.<br />
<br />
We both like the same things but when it comes, after hard day of work, he's time to get rest I take over the control and do some fun stuff. These include playing chess or shogi over the net, watching movies, reading books. He is always puzzled why he is so tired :-)<br />
<br />
For more information about me, please visit <a href="http://sites.google.com/site/fatboldcyclopsplace/">FBC's homepage</a>.<br />
<br />
One of the things of our interest is shogi. The other is developing software.<br />
<br />
<h1>What are Shogi Tools</h1>The whole idea of this appeared when I was browsing shogi-l discussion list.<br />
<br />
I was looking for some tsume shogi problems to solve. Finally, I found in their archives a file http://www.shogi.net/arc/shogi-l/tsume_faq.txt. Roger Hare collected there 131 problems (mostly submitted by Reijer).<br />
<br />
I wanted to have the tsume collection in some printable format so I could make a handout.<br />
<br />
So I started to write a tool which I called Tsume Parser. It is supposed to read a file in the descriptive format (the format used by Roger) and convert it into more "visually attractive" one.<br />
<br />
I also wished I had a program to help me to enhance my "board vision" in shogi. There are some similar programs for chess (i.e. http://chesstraining.sourceforge.net/) but none for Japanese chess.<br />
<br />
I have other ideas for software that could help organize my shogi.<br />
These led me to the conclusion that I have to take active part in developing some shogi software.<br />
<br />
That's how Shogi Tools appeared as a project on code.google.com. There are two main goals of the project:<br />
<br />
<ul><li>Documenting shogi community standards for storing, representing, transmitting shogi-related data (games, tsume, etc.).</li>
<li>Building tools to translate between the formats.</li>
</ul>Future plans contain, after building mentioned set of tools, production of turn based on-line game server for shogi players.<br />
<br />
On the pages of this blog You will be able to trace the progress of my work on the subject. I'll try to describe the problems I encounter and how (or if) I solved them. <br />
<br />
<br />
See you!Fat Bold Cyclophttp://www.blogger.com/profile/05150168717094079722noreply@blogger.com0