Peg Game Win Probability
Output Readme Download Replit Sel. & Copy Full

If you want to change the arrangement of the holes, either edit the ten.json file or create a new json and then replace the word ten with the appropriate filename in the node commands below. The array of holes should include elements of the form [x,y] where x is the column and y is the row. Every other row should include x values that are halves like 1.5 to intuitively represent the offset nature of a hexagonal pattern. You can run "node makesvg.js ten test" after editing the array to see the arrangement in img/0000000000.svg (the # of zeroes will equal the number of holes in your array). You will probably want to edit the makesvg.js file, though, to generate an image that properly fits in the box. If you use an array with 20+ holes, then some commands below may be slow and/or use lots of storage.

Create the moves.json folder with all valid moves: node createmoves.js ten

If you want to make some graphics at some point, then create all of the SVGs: node makesvg.js ten

If you want to create a graph of the possible games: node reversegraph.js ten Then visit output.html Add an argument at the end to set the number of initial pegs so "node reversegraph.js ten 3" would create the graph of all games ending with 3 pegs left.

To create the counts (after creating the moves), run: node reversecount.js ten

If you want to create a chart of the probabilities just visit probchart.html after generating the counts.

I also have repls where you can play a peg game, or an isometric version. Read my blog post about computing peg game win probabilities. Or play peg games in a variety of shapes and difficulties. Or if you prefer buying physical products, I handcraft epoxy resin peg games in a variety of shapes.