Raspberry Pi – Python Star Trek progress
Since my Raspberry Pi arrived a few weeks ago, I’ve been tinkering with it rather a lot. For example, I’m currently on my 3rd operating system build. I’ve already been through the Debian squeeze and wheezy beta, and last night I started using a version of the Raspbian port (derived from Debian, but complied to take advantage of the floating point processor on the Pi, meaning better performance for most things).
All this tinkering means that I haven’t got as far as I hoped with my attempt to learn a little more Python by creating a port of a Star Trek Tiny BASIC game, originally published by Computing Today (CT) in October 1979. Its been slow going – and not only because I’m busy with other things!
My first problem was trying to understand how the original software worked. It’s not easy – and an extract of the original listing from the magazine illustrates why.
The limitations of the Tiny BASIC language combined with the limited memory capacity of home computers in 1979 (8 kilobytes would have been a luxury for most people) mean that it’s a rather difficult program to decipher, even with the two pages of description CT published in addition to the listing.
In some ways I’d have been better off redesigning the game from scratch. However, I’m trying to aim for as an authentic reconstruction as I can manage, but one that is better structured and in Python. My quest for authenticity applies even down to using the same data structures for the galaxy and the 64 sectors it was divided into in the original game, making sure that I’m using the same encoding for stars, starbases and Klingons. The porting task would have been far simpler if I’d decided to abandon the original data structures and used something far more powerful in their place, but that would have felt like cheating.
Even so, I think I’m around halfway there. Here’s a screenshot of the Enterprise -O- moving through Klingon >!< infested space to prove it …
… and a small snippet of Python to show how a sector of the galaxy is decoded. (Hint – the value in the galaxy array for sector 17 shown above is 305).