Giter VIP home page Giter VIP logo

solitaire's Introduction

Solver for the Game of Solitaire in Clojure

"Peg solitaire is a board game for one player involving movement of pegs on a board with holes. Some sets use marbles in a board with indentations. The game is known simply as Solitaire in the United Kingdom where the card games are called Patience. It is also referred to as Brainvita (especially in India) ...", quoted from Wikipedia article Peg-Solitaire.

This clojure application finds solutions for the game of peg solitaire. For a small number of moves all constellations are determined iteratively and stored in an internal hash-map. Hashing ensures that each board setup is evaluated only once. After an iteration step the given solution space is pruned by means of a scoring function. The next iteration step is applied only for those constellations which seem to be most promising afterwards. This approach shrinks the number of analyzed constellations dramatically. On a 2 GHz Intel Dual Core machine the solution is determined in only 20 seconds.

Build

You need the clojure build tool leinignen for compilation. Download the lein script file from Github

$ cd ~/bin
$ wget http://github.com/technomancy/leiningen/raw/stable/bin/lein
$ chmod +x lein

and type

$ lein self-install

The following commands will generate and stand-alone jar file:

$ lein compile
$ lein uberjar

Refer also to Zef's Leiningen page for more specific information about build options.

Invocation

The following command will start the simulation

$ java -jar solitaire-standalone.jar 

Two optional parameters allow to change the complexity of the solution space. The first determines the number of iterations before pruning takes place. The second one determines the number of constellations to be taken into account for following iterations

Licence

This clojure solitaire solver implementation stands under the terms of the GNU General Public Licence.

September 2011, Otto Linnemann

Resources and links

Thanks to all the giants whose shoulders we stand on. And the giants theses giants stand on... And special thanks to Rich Hickey (and the team) for Clojure. Really, thanks!

solitaire's People

Contributors

linneman avatar

Stargazers

Jörg Ramb avatar

Watchers

Jörg Ramb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.