Skip navigation

Monthly Archives: March 2012

Here is a new version of Kleptos, sans one debilitating typo.

Advertisements

It’s ready: the first draft of Kleptos.

After trying to wrangle github for a while and failing, I decided to just host it at mediafire. The link is here.

You will need Python 2.7+ in order to run it. If you are using a terminal, open the terminal in the unzipped folder and run the main file, kleptos.py. If you are using IDLE or something similar, just make sure that it can find the kleptos.py file – kleptos.py knows where to find everyone else.

I have not tested it on anything but Linux – though it should work on Windows. Please comment if you’re having a problem.

So assuming it works for you, tell me what you think. If you are a code reader, let me know – though keep in mind that this is my rough draft, and I’ll be reading and editing (and adding better comments) over the course of this next week. Suggestions will be welcome.

Even if I accomplish nothing more, it feels great to be able to move forward. It will be good to get back on track with my curriculum, though working on this project has been educational like cramming keywords into my brain could never be. Coding is art as much as science, and practice is worth its weight in gold. Enjoy, everyone!

I’m not totally finished, but I feel a big relief: I have finished all of my planned features and actions for the game. Tomorrow will be testing, debugging, refining and commenting, and I will conclude by uploading it all onto github.

I won’t be 100% finished – I’m going to print out all the code on Monday and edit it like a manuscript. So next week I’ll be reviewing it piece by piece. Your comments and criticism would be most welcome at that point, too – keeping in mind that this is more of a prototype and exercise than an actual, complete game.

That’ll be it for now. I’ll be back tomorrow hopefully with a finished draft!

I managed to finish everything I set out to do today with Python, even if it might have dipped into more of my time for other things than I would have wished. So it goes.

A lot of this extra time was spent in the debugging phase of today’s work. In particular, I was having trouble getting the game to restart. There were a few minor issues with it that I cleared up easily, but I got seriously stuck on resetting the player’s starting inventory. Copying some code I’ve seen in other programs, I decided to use global variables at the top of the file containing my “runner” (driver) class to initialize some of the game’s starting values, including inventory. It looks like this:


STARTING_INVENTORY = ["dagger", "coins"]


This seems to be an artifact of C++’s “#define” statements, but I suppose it works just fine in Python. I think the idea is to make these variables exceptionally readable and easy to locate so they can be changed conveniently.

The problem I ran into was that, when resetting the game after getting rid of the coins, reassigning this value to the runner object’s self.inventory attribute was only giving the player the dagger. It took me the longest time to figure out what was going on.

After maybe 20 minutes, I finally remembered that I had encountered this problem in the past, but had carelessly forgotten about it: lists are not copied when reassigned. When you make a list and continue using it, one list is created and will be passed along to variable after variable.

So, when I was assigning STARTING_INVENTORY to self.inventory at the beginning, then clipping “coins” off of self.inventory, I was actually clipping coins off of the original list assigned to STARTING_INVENTORY. When I was passing STARTING_INVENTORY back into self.inventory, I was passing back that same, clipped list that was already assigned to self.inventory. In other words, I was not actually resetting the inventory and therefore cheating the player out of his or her hard-earned coins.

What this has taught me (or retaught me) is that lists are more concrete than abstract; the changes you make to them last longer; they are mortal. Of course you can copy them (which was my eventual solution), but it’s something you have to specify; it is not native to the nature of the list to be copied and disseminated; it wants to remain unique.

But enough anthropomorphism of data structures.

I have written out all the traps and dead ends for the game, and tomorrow I make some finishing, aesthetic touches. The traps are really not intricate and the dead-ends are far from thorough. I have realized that 99% of the actions in adventure games are dead ends. It would take a very long time for me to map every mundane, pointless action in detail, so I will leave it as it is. Considering that in the example I’m supposed to follow there are maybe three possible choices, I have gone far past the call of duty.