Posts mit dem Label programming werden angezeigt. Alle Posts anzeigen
Posts mit dem Label programming werden angezeigt. Alle Posts anzeigen

Sonntag, 27. Mai 2012

meowBG, a wxPython based backgammon client


A friend of mine is currently developing a backgammon server, and the idea of building a client was appealing, so I've started to expand my Python GUI programming knowledge a littler further and tried out wxPython.

A little background first: For reasons unknown to me, the name of the web server under development is "Tiger Gammon" (German site), and it's a nice alternative to FIBS, the First Internet Backgammon Server. Both servers communicate with clients over the telnet protocol, which seems odd at first. But when FIBS was born in 1992, that was probably the obvious choice. Tigergammon, on the other hand, strives to be a better FIBS, and thus uses telnet as well. So my client will have to follow that path.

In the meantime my wxPython client has grown pretty nice, but it's not ready for being shown off in public. But as of today, the client has its own splash screen, and I like it so much that I wanted to share it here. Since it's a client for tigergammon, I called it "meowBG", and when I found an old picture of our cat Alice sitting in a waste-paper basket, the logo just fell into place …



I ought to polish it a little more, but for my limited GIMP skills I guess that's as good as it gets. Should meowBG ever be released I may need a talented designer.

Posts about the client itself are soon to follow. Currently it looks like this ...


... which is not perfect but a decent start. Network play over either FIBS or tigergammon is already possible, but the user interface is still far from intuitive. Stay tuned!


Dienstag, 28. Juni 2011

An Ook! interpreter in Python

A recent geocache introduced me to an esoteric language named "Ook!", which was designed for Orang-Utans to communicate without arousing human suspicion.

It's pretty simple, as the language consists of only three syntax elements:
  1. Ook.
  2. Ook!
  3. Ook?
That's it. To make the language a little more powerful, elements are grouped into pairs, e.g. "Ook. Ook!" or "Ook? Ook.". So we have nine possible pairs and thus nine distinct commands, only eight of which are actually used ("Ook? Ook?" has been supplied with no deeper meaning ... maybe it's left for the Orang-Utan to express "WTF are you talking about?!").

When I felt an itch to implement an Ook! interpreter, I discovered that Ook! is all but identical to the well-known Brainfuck, since both languages have eight commands, and there exists a one-to-one mapping between them.

Furthermore, since Brainfuck is already a "minimal" language in that any command consists of one character only, I started off with the BF interpreter.

(Ok, to be totally honest, I started off implementing the Ook! interpreter, which eventually had bugs I wasn't able to track down anymore ... :) only then I realized what a stupid plan it was to begin with the Ook! part and started all over again, this time implementing the BF part first)

After finishing that, the remaining task was to implement a preprocessor which would turn an Ook! listing into a BF listing, and I was done.

If you're curious about the result, grab the code from github.

(It's my first project on github btw, and I absolutely recommend the github for mac application)

Montag, 9. Mai 2011

The marriage of Inform7 and geocaching

Recently I stumbled across a terrific idea ... it all began in 1981. Really, it did. Because that was when my wife was born, inevitably determining her turning 30 in 2011.

So, faced with the upcoming event, I considered my options as to what I might give her for her anniversary. Thinking medium-hard for some time I came up with a medium-brilliant thought: I'd place her her very own geocache! She's pretty fanatical about that stuff, so that was a safe bet. I planned to build her a multi-staged cache.

Nothing too clever so far. Caches like this exist in the hundred-thousands.

... BUT ...

Two weeks before the actual event, a co-worker of mine introduced me en passant to something terrific: Inform7.

Inform7 deserves to be called a programming language. In a way, at least, as its declarative style combined with predicate logic reminds me of my Prolog days. On the other hand, its prose-like appearance gives it a fuzzy, yet natural touch. In a nutshell, it allows you to describe an entire world with all its objects, locations, people, as well as all the rules that apply in it, without making you feel too geeky.

And as soon as you're done, Inform compiles your description, and you get ... AN INTERACTIVE TEXT ADVENTURE! (All ye nerds scream "Yaaaaaaaaay" ...).

So, for instance, your source text might be

 
 Living-room is a room. 
 Kitchen is a room. 
 Kitchen is south of living-room.   


and after compiling you're ready to play. Ok, not much adventure to experience yet, but add some pizza to the kitchen and a computer to the living-room, and it's not so far from some people's actual existence. ;-)

So when my colleague told me about that, I suddenly knew what I had to do: A hybrid of an old-school text adventure and a geocache - that was it! Ideas started flooding my mind as soon as the connection of the two concepts was established ... so many, indeed, that it was hard to keep track of all of them. In the same instant it was sort of exhausting to think of all the stuff I wouldn't be able to implement since first of all I wasn't in the least "fluent" in Inform7, and then there was the time issue: Two weeks only - how many ideas would have to remain unborn? :-)

The game map, as generated by Inform based on the relative positions of the rooms.


In the end I managed to build a small world consisting of 29 rooms, about half of which correspond to "real" places that the players needs to visit in order to collect clues there. Check out this snippet from the game, played entirely inside the browser:



Some of the clues were material, some purely virtual. It was a satisfying result after all. There are monsters in it (trolls, dragons ... standard RPG company), hidden places, keys and locks, hilarious jokes, of course, magic barriers and the like. Adventure veterans would certainly criticize its being a little too simple. Beginners will possibly claim the opposite. Who knows ... judge for yourself, but don't get frustrated! You cannot get past the dragons, as you need a "real" clue for that, so there's no chance you'll finish the game successfully. You'll have to enter the nonvirtual realm for that. :-)

The cache was a nice surprise for my unsuspecting wife, and - as of 9th of May - it is published and available under the name "Wandrin' Duck". I'm excited what kind of feedback I'll get from the geocachers' guild.

Still there's a lament in the back of my mind of all those ideas I left out ... maybe some other day.