12 MIN READ TIME

CODING ACADEMY

Code your own Python text adventure

Nate Drake guides you through creating your own interactive text adventure with the power of Python, starting with the basics…

Text adventure

ACADEMY

MUCredit: https://codewith.mu

Part One!

Don’t miss next issue, subscribe on page 16!

OUR EXPERT

Nate Drake wants to dedicate this series to his dad, who once told him that no one was ever going to pay him to sit around and play video games.

To download all the code samples for part one of this series, open a terminal and install Git via sudo apt-get install git . Next run git clone https:// github.com/ azuregate/ lxfpython textadventure. git . The files download to the ‘lxfpython adventure’ folder in your home directory.

T hose of us old enough to remember the ’70s and early ’80s know that games were graphically very uninspiring then. Not to mention the fact that personal computers were still prohibitively expensive.

In 1975, MIT student William Crowther took some time out of his busy schedule developing ARPANET to create a text adventure game he could play with his kids. Although it wasn’t the first of its kind (that honour belongs to 1973’s Hunt the Wumpus), Colossal Cave Adventure quickly spread over the early internet after heavy modifications. The basic premise was the same as any text adventure, in that you entered commands, such as the cardinal points of the compass (N, S, E and W), to move between areas, and interact with items, traps and monsters in a bid to win through to the end with maximum points.

Younger readers may find it difficult to believe that people actually still do this for fun. In fact, IF (interactive fiction) has never been more popular. The annual XYZZY Awards even offer prizes to those who code the very best text adventure games.

In this four-part series, we plan to take you through the basic steps of creating your own text adventure game using the Python 3 programming language. The good news is that since it’s text-based, you won’t need a degree in Photoshop wizardry. It’s also a great programming project for getting started with Python, as well as developing clean coding practices.

If you’re a Linux user, there’s more good news, because support for Python 3 is almost certainly already built into your distro. You can just type python3 via the terminal to get started.

Still, this isn’t the easiest way to code and run Python scripts, so we’ve used the Mu Pytho interpreter instead. It’s available in the Ubuntu software centre and it offers a quick and easy way to run scripts. Mu’s also available for the Raspberry Pi.

Unlock this article and much more with
You can enjoy:
Enjoy this edition in full
Instant access to 600+ titles
Thousands of back issues
No contract or commitment
Try for 99c
SUBSCRIBE NOW
30 day trial, then just $9.99 / month. Cancel anytime. New subscribers only.


Learn more
Pocketmags Plus
Pocketmags Plus

This article is from...


View Issues
Linux Format
August 2023
VIEW IN STORE

Other Articles in this Issue


WELCOME
MEET THE TEAM
We’re running our own home AIs this issue, so what’s the one job you’d like AI to take off your hands? And it can’t be dealing with grumpy editors…
Machines learning
The Management demanded an AI cover and here
REGULARS AT A GLANCE
Newsdesk
THIS ISSUE: Ubunto Core is Snapped up >> AMD announces free firmware >> Fresh features for Gnome >> Wine owned by employees
Kernel Watch
Jon Masters keeps up with all the latest happenings in the Linux kernel, so you don’t have to.
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com
Mailserver
LXFbuntu will not be a thing, but let
HotPicks
Vorta Mullvad Browser Wike CryFS rmLint Imaginer Letterpress cli-chess OpenRCT2 Boost Changer PDF Mix Tool
Linux format
The #1 open source mag Future Publishing Limited,
REVIEWS
Anycubic Photon Mono 2
Denise Bertacchi likes this blend of quick setup with detailed prints.
Intel Core i3-13100F
As Intel reclaims the mid-range, Paul Alcorn assesses that the company has lost the low-end.
Fedora 38
Nate Drake took the latest Fedora for a test drive and was blown away by the vast array of new spins and features.
EuroLinux 9.2
Nate Drake is on the continent this month, taking a stroll through the natural beauty of EuroLinux.
Peropesis 2.1
Nate Drake grapples with the ultra-minimalist Peropesis. Will he relive Linux’s glory days, recover a corrupted system or have a breakdown?
Valheim
Management are delirious to learn that Christopher Livingston can keep working long after his death and will take draugr entrails as payment!
ROUNDUP
Ubuntu spins
With the release of Ubuntu 23.04 still fairly recent, Michael Reed examines the differences between the official spins of that distribution.
The applications
A distro gets a lot of its personality from the default selection of apps.
Configuration tools
Hopefully, the settings cover all of the main areas of the system and its appearance.
The user interface
Your connection to the system.
Drive and memory efficiency
Extra efficiency is like having a faster CPU without spending money.
Package management
There is a variety of front-ends to the Ubuntu package system.
Suitability for switchers
How suitable is this distro for those used to a different OS?
Extra features and customisations
What does this distribution have that the others don’t?
The Verdict
Ubuntu spins
ALSO CONSIDER
The natural alternatives are the other Ubuntu flavours,
CONTROL YOUR A.I.
CONTROL YOUR A.I.
AI usually requires server farms of training GPUs, but Tam Hanna’s modest freelance budget lets him train his own personal HAL.
Nvidia CUDA rulez
You might not like it, but Nvidia runs this show.
Natural language translation
Modern smart machines can perform live translation.
AI see you…
Enable an AI to say what it sees.
Chatty AI man
A simple 250GB download can secure your own personal HAL.
IN DEPTH
Free all the things!
One of the brains behind Collabora Online, Michael Meeks talks to us about taking open source office to the cloud and document liberation.
Inside BlendOS
Matt Holder discovers how to use the Arch-based BendOS to mash together multiple distributions. Does it give the best of them all?
Silicon insides
Apple, AMD and Intel all take significantly different approaches to building CPUs. Darien Graham-Smith takes a closer look at today’s varied processor designs.
Pi USER
It’s (finally) raining Pis, hallelujah!
Eben Upton takes to the blogs to promise millions of Pis this summer.
Astronomical!
It’s out of this world.
AI, AI, oh!
Learning farms.
GET THE LOWE DOWN
Les Pounder works with groups such as the
Debug Probe
Les Pounder was about to reach for a can of fly spray in an effort to rid his code of bugs, but then he spotted this.
Pi Compute Blade
Les Pounder hasn’t been left on the shelf, but he’s been put on the rack.
Use a Pi HAT on the Raspberry Pi Pico
Being a skinflint Northerner, Les Pounder is all about reusing things, so he explains how you can use Pi HATs on the Pico.
TUTORIALS
Minimalist RSS reader
As far as Shashank Sharma is concerned, it’s not social media but ads that are the bane of modern internet usage, and he has a clever workaround.
Keep your Linux install backed up
Nick Peers reveals the tools, techniques and tips you need to protect everything from personal files to your entire Linux installation.
PL/I – the multifaceted language
Mike Bedford discovers the mysteries of PL/I, the language that IBM hoped would replace both FORTRAN and COBOL.
How to test out new desktops the easy way
Never accused of being fast and smooth, Mats Tage Axelsson explains how to try your next desktop and make the switch faster and smoother.
Capture and restore old photos and slides
Mike Bedford shows you how to scan, repair and archive old film-based photos, to give your family heirlooms a new lease of life.
Compose using the ultimate tracker
Michael Reed explores some common music-making workflows in Ardour 7, the premier Linux digital audio workstation application.
CODING ACADEMY
Spice up your Python console applications
Matt Holder demonstrates how to use the Python Rich library to add formatting to your console applications.
Chat
X
Pocketmags Support