Star Trek game – a Python port from Tiny BASIC

A while back I mentioned that I was in the process of porting an old Computing Today Star Trek game from Tiny BASIC to Python on my Raspberry Pi. This was before I’d taken the edX Python course and learned to code properly in the language.

Frankly, although my code works, it is truly horrible stuff. And I didn’t even have the excuse of being limited to a couple of kilobytes of memory that the original was designed to fit into. I’ve just never had the time since to go back and do it better.

However, a couple of people have asked for the code, so here it is, in all of its – ahem – glory.

The original Tiny BASIC versionΒ (pdf format) – you’ll need this to make sense of how to play the game.

My Python portΒ (pdf format) – you’ll need to copy and paste this into a .py file to make it work with a Python 2.7 interpreter (obviously).

Have fun!

 

7 comments

  • Pingback: Raspberry Pi-powered Star Trek Projects and Posts Roundup @StarTrek #StarTrek #piday #RaspberryPi @Raspberry_Pi « Adafruit Industries – Makers, hackers, artists, designers and engineers!

  • Jim Edgar

    Nice port. Though we start off and recharge with zero shields and the comments say 1000. Simple fix. Now I have 40000 shields!

  • DJStephson

    Please upload a .py file as well πŸ™‚ After copying from PDF to LibreOffice I lost all the indentation, and had to manually reindent it.

    • tim

      I’ve created a github repository for it: https://github.com/psychotimmy/trek-game – enjoy!

      • ieko

        Thank you so much for putting this up, amazing work!!! Can you attach a GPL license to it?

        • tim

          You’re welcome, and no. I’m not prepared to attach any licence to it as it wasn’t my original idea and the python code I wrote has been vastly improved by others already. Truly “free” code!

          • ieko

            Thanks for your reply!! I was afraid there might not be a reply for such an old post. πŸ™‚

            I’m really excited that you’d like the code to be free (as in freedom), and that others have been able to build upon it (where do I find them???). In fact, that’s exactly why I suggested the GPL: https://www.gnu.org/licenses/quick-guide-gplv3.html

            Please forgive me if you already know this, but the GPL is the GNU General Public License. It is a software license that explicitly grants anyone who gets the code four essential software freedoms to: (1) use the software for any purpose; (2) change the software to suit your needs; (3) share the software with your friends and neighbors; (4) share the changes you make. I really like this writing on free software: https://www.gnu.org/philosophy/free-sw.html

            The game isn’t your “original idea”, but your code is certainly an original work covered by copyright. Each piece of code is considered an original work/expression – this has been legally established since at least the 1970s. And under current copyright laws, no one is allowed to use your code, fork your code, or modify it unless they obtain explicit permission from you. Such permission is given through licenses. Without attaching a license to your code (and hence permission for others to use it), those who have vastly improved your code were actually infringing on your copyright, which probably isn’t what you intended! Thus, to make “Truly β€œfree” code”, it needs a free software license, and the GPL is a great one.

            On the other hand, if you do not want any copyright associated with this code, you can also release it into the public domain (public domain is defined as any work that doesn’t have copyright) by using the Creative Commons public domain dedication: https://creativecommons.org/share-your-work/public-domain/

            Sorry if this seems pedantic, but correct licensing is very important especially if you want your code to be free (as in freedom). GitHub provides easy facilities and guidance on how to apply the license, and there’s also an easy guide here: https://www.gnu.org/licenses/gpl-howto.html

            Thank you so much again for creating such a great piece of work and sharing it with us. Now it only needs a free software license so you can formally give everyone the permission to learn from your work and build upon it!

Leave a Reply

Your email address will not be published. Required fields are marked *