PyWeek 6

Collin and I participated in PyWeek6 (week long challenge to make a game with Python) with a mutual friend who has a Python game project he is working on in his spare time. He actually went to PyCon with us, so that was where this idea came up. It was interesting and we put in a lot of time on it. Unfortunately, I had a test and two projects due for school that week too, so I didn’t end up sleeping much… We did come up with a game (you can see it here), although I think we all wish we could have had another day or two. We are getting together this weekend to have a post-mortem. I think a lot of stuff went well (and we actually got something done in a week!), and of course I think a lot of stuff could have gone better. For example, I spent a good chunk of the week working on a quadtree for culling the world. The world ended up being much smaller than we originally planned so the overhead of the quadtree (implemented in Python) killed any potential performance gains. It also turns out we also unwittingly used some 3rd party libs that were released after the library deadline (a month before the start of the competition), so we technically could be disqualified. Oh well. I don’t think any of us really cares about winning the competition, we were more in it for the challenge. However, I am looking forward to hearing some feedback from the other contestants.

That was by far the largest Python project that I have worked on, so it was a real learning experience for me. Python has some great stuff and some really frustrating stuff. I learned that this is not the correct way to use assert:

assert(False, 'error')

That will never be triggered because assert is actually a statement, not a built in function. This is the correct way to use assert:

assert False, 'error'

Note the lack of parentheses. With the parentheses, it evaluates the tuple “(False, ‘error’)” as True since it is not an empty tuple, so it effectively becomes “assert True”. I’ve heard Python 3000 will change “print” to a function instead of a statement, but I haven’t heard anything about “assert”. Ugh. We also encountered some issues with performance doing “engine-level” stuff in Python. However, for a lot of what we required to make a game, Python let us do it quickly and easily. Integrating the different stuff we all worked on went well. Duck typing makes development much easier than having to use interfaces/templates/inheritance/whatever (although it seems like it really requires good automated testing to be safe).

Perhaps I’ll post more after our post-mortem, but try out our entry if you want. There are installation instructions included with the tar.gz file (also read the errata since there are a few errors in the readme). You will need Python 2.5, but beyond that setuputil will install the other dependencies automatically. If you try it, give us some feedback!

One Response to “PyWeek 6”

  1. [...] Crown and Cutlass Crown and Cutlass Developer Blog « PyWeek 6 [...]

Leave a Reply