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

 

12 thoughts on “Raspberry Pi – Python Star Trek progress

  1. 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 !

    Simon

    1. Hi Simon,

      I think the first time I played this game (or something like it) was sometime in 1981 on a Lear Siegler ADM 3A If I remember correctly, it was attached to a DEC VAX 11/750 running BSD Unix, rather than VMS!

      Tim.

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

      Tim.

  2. 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?

    1. 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 🙂

      Tim.

    1. Hi,

      Happy to. I’ll put it in a new blog post later on this week once I’ve found it again. The code is pretty bad (well, terrible if I’m honest – it dates from before I’d sat down and learned the language properly), but it is functional.

      Tim.

Your thoughts?