I wanted to "program" a peg solitaire game in the browser, but of course it should be done in XSLT (1.0).
The infrastructure with Saxon-CE for XSLT in the browser development is great ...
Nice, my "XSLT peg solitaire in the browser" solution has been added to Saxon-CE "Demonstration" section!
— H. Stamm-Wilbrandt (@HermannSW) June 27, 2013
If you "just want to play" now, click on the board you want to play (http://stamm-wilbrandt.de/en/xsl-list/peg-solitaire/):
French - Wiegleb - 3-3-2-2 - English - Diamond
Sample "English" game::
Now if we look at the English board, we have 32 pegs and a hole in the initial position:
And a xml-stylesheet processing-instruction would instruct the browser which stylesheet to use for drawing.
Of course each field would have a hyperlink associated which links to "the next" position.
We have 33 fields, and each can have a peg on it or not -- this makes 2^33 or more than 8 billion different positions!
Based on code snippets I already used in posting "[xsl] support of stylesheet embedding for ALL browsers"
* xslt-events.js, providing the "dynamic XML processing" capability.
* Chrome (18.0.1 / 17.0.9)
* Firefox (11.0 / 10.0.3)
* Internet Explorer (8 / -)
* Opera (11.62 / 11.62)
* Safari(5.1.5 / -)
need to be loaded exactly once, and network connectivity is not needed afterwards.
* "play" mode, where you can see the "stop" button at bottom right
* "edit" mode, where you can see the "play" button at bottom right (create your own initial configurations!)
If you selected "a wrong" peg in "play" mode, clicking on it again unmarks it.
The heart of the stylesheet is the simple serializer neded to generate the XML string at the bottom.
If you want to see, click on this animation of the solution.
So this is the initial English board position English.html:
This is a screenshot from myAndroid cell phone running peg-solitaire in Opera mini browser: