Interactive fiction with Python | Hello World issue 8

Nicholas Provenzano explains how he introduced Python to students in his literature class, bridging computer science and literacy.

Literature classes seem like the last place you would find students coding, but interactive fiction has been around for decades. Students love to play computer games, and the very best games have amazing stories. This project will allow students to create their own piece of fiction and then use Python to turn it into a text-based computer game. Students will have a chance to create their own hero and monsters, treasures and traps and so much more while being introduced to Python. Students that love to write, and students that love to code, will love this lesson.

Hello World issue 8

I’ve been thinking a lot recently about to ways to bring computer science into the literature classroom. I set out exploring the Raspberry Pi projects page, where I saw a project that allowed the user to create their own text-based computer game using Python. I thought this would be a great way to engage students in reading, writing, and programming.

Students create their own piece of fiction and then use their stories to create an amazing text-based computer game based on the role-playing game (RPG) tutorial from Raspberry Pi: helloworld.cc/rpg. From the first day working on this project, my students fell in love with the writing and the coding. They couldn’t wait to create their game and share them with their friends.

The project is best introduced with a focus on creative writing, where students should create an outline for their own adventure story. With that in hand, introduce the students to the Raspberry Pi RPG tutorial. It is much easier for students to create their game if they draw out the rooms on paper to help them visualise the game they’re creating. The more time they are given to create their game, the more complex it can become. Students will be able to fully explore the code while creating a fun game they can share with others.

Hello World issue 8

This project is the perfect way to bring coding to a literature class. Students that love to write will be introduced to text-based programming, while students that love to code will have an opportunity to explore fiction through their own writing.

My students were excited to spend their time creating a complex story, and an even more complex game to challenge their friends and their teacher. Students who struggled with the code were helped by other students who’d already moved ahead. We spent a week on this project, but you could spend longer, depending on the breadth of the stories and games. Watching students use their critical thinking skills to plan out a maze for their players was great to see.

The best part was watching students who do not normally engage in reading and writing lessons become leaders as they embraced the coding and were excited to turn their story into a game and share it with everyone. This project will become a mainstay in my teaching for years to come.

Take this to your club or classroom

For the complete lesson plan of the above project, download Hello World issue 8 for free and turn to pages 80–81.

Hello World issue 8

Get Hello World issue 8 for free

Hello World is available to download for free in PDF format anywhere in the world. Subscribe to Hello World today to receive the latest issues into your inbox as soon as they’re released.

Hello World issue 8

If you are a UK-based educator, you can also subscribe for free print copies of Hello World, which will be delivered to your door at no extra cost.

And, lastly, if you’d like to purchase Hello World magazine, you can buy the latest issue via the Raspberry Pi Press website.

4 comments

Avatar

This IF project with Python is done in only one week? Is it closer to CYOA or text adventure? The article didn’t say. Having the rooms diagram, I suspect text adventure type, but I’m not sure. Also, is it done in 2 word verb noun format?

From time to time, there is a push toward a “better” format for programming. Invariably, this is visual. None of them lasting beyond toy stage. I’m guessing this is because it’s a hassle to write large visual program due to the relative small monitor size.

Avatar

Did you click through to https://projects.raspberrypi.org/en/projects/rpg or https://helloworld.raspberrypi.org/issues/8 ???

It uses two word commands. The code starts simple then gives opportunities to make it more complex/interesting.

You can try it out at the first link, above

Avatar

This is a great project to get kids started with Python programming!

I’m new to the RP community so please forgive me – but I don’t understand what this project has to do with the Raspberry Pi.

Avatar

Thank you for your comment Jon!

The Raspberry Pi blog covers the work of the Raspberry Pi Foundation – a charity that works to put the power of computing and digital making into the hands of people all over the world. Hello World magazine is part of this wide mission and so while it includes lots of articles about how educators are using Raspberry Pi computers, editorially we are device- and platform-neutral.

You can read more about the magazine here: https://www.raspberrypi.org/blog/hello-world-new-magazine-for-educators/

And you can subscribe for free here: helloworld.cc/subscribe

Leave a Comment

Comments are closed