RSS Feed

Comments RSS

Python – a learning exercise

In the process of learning Python, I have given myself a programming exercise to do.  This is a standard thing I do whenever learning a new programming language and I have used this same exercise several times before.  It is a simple text based game that simply lets a user explore a maze of rooms.   If fully fleshed out, it would be a Zork or D&D type game.  It demonstrates some basic programming tasks such as reading data into an array from a file, getting and responding to user input, looping, control structures, system calls and function definitions.  I share it here as example code for others also learning Python and I welcome comments.   The code is for Python 3.x, but the comments explain how to easily convert it for use in Python 2.x.  It is far from perfect and is for learning purposes only – something to tinker with.  It is based on concepts from Creating Adventure Games on Your Computer by Tim Hartnell, which used the BASIC programming language.   You are welcome to take this code and use and modify for any purpose you like.  The current version of this code will always be at this location: mazegame-current .  In this directory you find the program and the data files it will ask for when the program is run.

My previous blog entry Learning Python provides resources for those wanting to learn Python, as does the Dev page from my main website.

One Response to “Python – a learning exercise”

  • I have made tremendous progress on this program since the original post. It is far more that a simple maze traversal algorithm, but much closer to being a true adventure game similar to Adventure!, Colossal Cavern, or Zork. The next posting I make on this will be a full update and I will provide the code in its entirety for your study and enjoyment.