Thursday 3 March 2011

Snake Wrestling

In the past few months I've been attempting to teach myself Python.  To that end, I decided to write a little program to put to use the new concepts and tools I was learning.  That small program has since snowballed into a project I call SerengetiSim.  I've got kind of a love hate relationship going on with this little program.  Since it began as a simple demonstration of what I had learned so far, it has grown in stages and slowly become a bloated mess of uncommented code.  I still put in little bits here and there when I don't have anything better to do but I have yet to perform a full rewrite to clean up the code and iron out some of the more persistent bugs.  Without any further ado, I present for your entertainment; The Wonderful, The Misguided, Misshapen, and Malformed SerengetiSim!






And here are the links to the pastebin pages for the source:


textinterface.py
newgame.py
control.py
animalcode.py
predcode.py
plantcode.py
timecycle.py
visualinterface.py

A few warnings:

  • textinterface.py is the main class and running it will initialize the game
  • text mode is currently set up to run on Linux only but can be made to work on Windows if you change the clear screen command and the ASCII color codes
  • don't make the map too big in text mode, I have not implemented a view port so you'll see the whole thing
  • visualinterface.py is currently very broken and I did not include the graphics so if you're going to try to get it to work again you'll have to supply your own, pointing and laughing would be a better use of your time
If I ever get around to fixing the visual interface for the sim I might port it to a Java applet using Pyjamas and put it up. That's all folks.

3 comments:

  1. i used to love playing with python. <3

    gave up though.:P

    ReplyDelete
  2. Cool info, I never got very far with any programming language.

    ReplyDelete
  3. i'm teaching myself c at the moment, but python is next!

    ReplyDelete