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).


Posts Tagged with…

Reader Comments

  1. Simon Walters

    I think as long as it resembles the main frame teletype input/output format you’ll be keeping to the original 🙂

    I programmed a version in BBC Basic when I was little but to my great regret, I didn’t have the foresight to archive a copy off 🙂

    One day, I hope I’ll meet someone who did save it (it was quite popular at the time!) and we will be re-united 🙂
    Look forward to seeing yours in action !


    • tim

      Hi Mitch,

      The listing pre-dates the ZX81 by 2-3 years! It’s from a scan I made of the original magazine at the time I wrote the post, so the silvery effect is one of age plus my decision to scan it in as a greyscale image rather than black and white.


  2. richard mcclendon

    If you get stuck understanding what the original code is doing, holler and I’ll try to help. Have you considered evolving this into amulti person game. Either have multiple star ship captains logging in or members of your own crew?

    • tim

      Hi Richard,

      I got there in the end, but it was dreadful code! Now that I’ve got a bit more experience with Python I might try again, but it’s finding the time to hack around that’s the biggest challenge. I like the idea of a multi-player version though 🙂


Your thoughts?