Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Tuesday, April 19, 2011

Spinning Up The Time Machine

So, I'm still playing with python. Not sure I'm going to write an entire roguelike in it, but figured I'd hack out to the step 4 (walking around a room) on the 15 steps to a roguelike.

I noticed the number of files/lines of code seemed to be much smaller than I remembered, so I pulled up the equivalent submission in magecrawl.

The python copy looks like this:


While the magecrawl looked similar to this (this was from a few weeks later, similar idea though)



Here is the comparision (excluding test code). This isn't comparing to the map generator picture above, just the walking around an empty room.

Python - 3 source files, 127 lines of code.
C# - 13 source files, 503 lines of code.

Much of that difference comes from the verbosity of C#. Some of it comes from the use of interfaces in C# compared to duck typing in python. The rest comes from an effort to implement the minimum needed and keep things simplier.

As a side note, pygame is pretty awesome. I might pull in libtcod for line of sight and pathfinding, but since I want "tiles" graphics, pygame made that crazy easy.