Klotski

From Freehackers
Jump to: navigation, search

A brick game

by Philippe Fremy

Introduction

Klotski is small brick game which has its root in a wooden game named (in french) Ane rouge. The goal is to bring the red piece to its destination by moving other pieces. It sounds simple but it is a real brainteaser.

There was a klotski game on Windows 3.1, and this is were all levels are from. There is also a basic gnome version of klotski here. I had a look at it before starting Klotski, so some design ideas have probably slipped from there :-)

Screenshot

klotski-screenshot.png

Requirements

On Linux, you need Python, Qt and PyQt. On Windows, everything works by itself :-).

History

Klotski is written in Python and uses the PyQt binding developped by Phil Thompson, to take advantage of the QCanvas from Qt.

This is my first program using python and PyQt. I must say I have enjoyed it a lot: Python and Qt are both excellent, easy to use and well documented. I have never been able to implement my ideas so quickly. The usual cycle think, organise into organigram, code, compile, correct compiling errors, run, correct bugs, run, it work was reduced to think, code, run, it works. Because of the simplicity and the power the python language, my ideas could be expressed very clearly and I could concentrate on what I wanted to do instead of how I needed to code it. The result is a simple and clean program, that was coded in half the time (and probably less) it would have taken to do it in C++.


Download

version 1.2 : 01 june 2006


version 1.1: 17 november 2004

version 1.0 : 23 january 2001

Get the code

This project is using mercurial to handle the source code.

You can get the latest package/tarball from

You can browse the code online (and make diff or take snapshots)

If you're familiar with source control, you can get the code by cloning the mercurial repository (And hence you'll be able to update later on) using the following command (or your favorite mercurial UI client in Windows/MacOS)

 hg clone http://sources.freehackers.org/Klotski

and then update it using

 hg pull -u

Feedback

I'm always interested in feedback, either good or bad. What would really interest me are contributions of new boards. Don't hesitate to contact me.

You can also contribute to klotski. Look at the file boards.kts, it contains the description of the board in a simple format. Adding a new board is quite easy.

Report your bugs here.

Solution

Due to many requests, I have put-up a solution of the most difficult puzzle, the dreaded Ane Rouge: the solution.

Look at it only when you start to get desperate (this is, after at least one month of effort). It took me something like one month to find it. The real tricky part is the end: you have to make the red square change side else it won't go out.

Related links

  • Bricks Games, a very good sliding tile game with many levels and special pieces, web ranking, puzzles everymonth and very good things.
  • Glotski , a Gnome equivalent


Other software by Philippe Fremy

  • LuaUnit: A unit-testing framework for the Lua language
  • Klotski: a mind-breaking game
  • Indent Finder: analyse source code indentation to set your editor automatically
  • PyTiCroque: a software to help playing at www.croquemonster.com