- Chapter 1 - Introduction
- About This Book
- Who This Book Is For?
- What You’ll Learn
- Introducing Python
- Why Python for Adventure Games?
- Chapter 2: Getting Started with Python
- Installing Python
- Your Coding Environment
- Running Your First Program
- Core Python Concepts We’ll Use
- Practice Exercises
- Chapter 3: Build Your First Adventure (Step by Step)
- Step 1 — Project seed: a loop that reads commands
- Step 2 — Model the world: rooms as dictionaries
- Step 3 — Track the Player
- Step 4 — Track the Items
- Step 5 — Show the world:
show_status()
- Step 6 Move around:
move(direction)
- Step 7 — Pick up Items:
pick(item_name)
- Step 8 — Use items to alter the world:
use(item_name)
- Step 9 — Your Tiny Command Parser (What it is, why it matters, and how to build it)
- Step 10 — Wire up the main loop
- Chapter 4: Adding a Logic Puzzle: The Ice Pool in the Chamber
- Updating the Chamber Room
- Updating
use(item_name)
- Updating
show_status()for the Chamber
- Puzzle Flow in Play
- Chapter 5: Making Commands Friendlier with Item Aliases (Resolver Approach)
- Step 1: Add aliases to your items
- Step 2: Write a resolver
- Step 3: Plug the resolver into the parser layer (not the game logic)
- Step 4: Enjoy the smoother player experience
- Design Tip: Keep canon, think human
- Optional: Friendly “Did you mean…?” suggestions
- Quick Exercise
- Chapter 6: Building Our Adventure with Objects
- Why Object-Oriented?
- Architecture and Tree Structure
- The
ItemClass
- The
PlayerClass
- The
RoomClass
- Strategy Pattern:
UseStrategyandPickStrategy
- The
GameClass (Controller)
- Putting It Together
- Benefits of OO Refactor
- Chapter 7: Saving Your Adventure — Persisting Game State with JSON
- Step 1 — Decide What to Save
- Step 2 — Sketch the JSON Shape (Schema)
- Step 3 — Add
to_dict()Snapshotters
- Step 4 — Add
from_dict()Restorers
- Step 5 — Add
save()andload()Helpers
- Step 6 — Wire Parser Commands (
save,load)
- Step 7 — Test the Flow (and What to Expect)
- Step 8 — Versioning, Migrations, and Safety
- Step 9 - Adding Save-on-Quit and Load-on-Start
- Step 9 - Adding Restart Functionality
- Step 10 — Putting It All Together
- Step 11 — Nice Extras (Reader Exercises)
- Recap
- Chapter 8: Share Your Adventure with the World
- Step 1 — Install Streamlit
- Step 2 — Create
streamlit_app.py
- Step 3 — Run Locally
- Step 4 - Deploying to Streamlit from GitHub
- Step 5 — Deploy to Hugging Face Spaces Using Streamlit
- Step 6 - Setting up for Gradio Deployment
- Step 7 - Publishing Your Adventure Game with Gradio on Hugging Face
- Step 8 — Build and Deploy
- Step 9 — Share Your Game!
- Step 10 — Optional Extras
- Recap
- Chapter 9 — Designing Your Own Adventure
- 1. Start with a Theme or Setting
- 2. Map Out Rooms & Connections
- 3. Think in Terms of Clues & Puzzles
- 4. Add Flavor Through Items
- 5. Expand the Parser (Optional)
- 6. Keep the Scope Reasonable
- 7. Playtest, Playtest, Playtest
- 8. Share with the World
- Closing Thoughts
- Epilogue — The Adventure Continues
- Appendix
- Appendix A — Adventure Game Terms
- Appendix B. Advanced Python Concepts
- Appendix C. Object-Oriented Concepts
- Appendix D. Unit Testing
- Appendix E — Resources & Next Steps
- Chapter 1 - Introduction
Creating Text Adventures in Python
Learn Python and Publish your Adventure on the Web
Step inside the world where code becomes story. Creating Text Adventures in Python is your guide to building interactive fiction from scratch, even if you’re new to programming. You’ll learn how to design rooms, puzzles, and branching choices while mastering Python essentials along the way. With each chapter, your simple prototype grows into a full adventure engine—complete with item interactions, save/load systems, and web deployment so friends can play your game online. Whether you dream of crafting fantasy quests, mystery stories, or sci-fi journeys, this book shows you how to bring those worlds to life line by line. By the final page, you won’t just be reading adventures—you’ll be writing them, playing them, and sharing them with the world.
The author is letting you choose the price you pay for this book!
Step inside the world where code becomes story. Creating Text Adventures in Python is your guide to building interactive fiction from scratch, even if you’re new to programming. You’ll learn how to design rooms, puzzles, and branching choices while mastering Python essentials along the way. With each chapter, your simple prototype grows into a full adventure engine—complete with item interactions, save/load systems, and web deployment so friends can play your game online. Whether you dream of crafting fantasy quests, mystery stories, or sci-fi journeys, this book shows you how to bring those worlds to life line by line. By the final page, you won’t just be reading adventures—you’ll be writing them, playing them, and sharing them with the world.
About
About the Book
Creating Text Adventures in Python
By Mike Gold
Discover the Magic of Coding Through Storytelling
Remember the thrill of exploring dusty dungeons, solving riddles, and uncovering hidden treasures? Now imagine building those worlds yourself—step by step—while learning Python, one of today’s most beginner-friendly (and powerful) programming languages.
Creating Text Adventures in Python is your gateway into both coding and creativity. Whether you’ve never written a line of code or you’re a curious tinkerer looking for your next project, this book takes you by the hand and shows you how to:
- Build interactive rooms, puzzles, and characters that come alive through player choices.
- Master core Python concepts—variables, functions, loops, and object-oriented programming—in a fun, story-driven way.
- Add depth with inventory systems, puzzles, and logic that make your world feel real.
- Save and load game progress, handle commands gracefully, and even design your own unique quest
- Bring your adventure online with modern tools like Streamlit and Gradio, so anyone can play your game right in the browser.
By the end, you won’t just know Python—you’ll have a playable adventure game of your own, ready to share with friends, family, or the world.
This isn’t a dry coding manual. It’s a journey—one where you explore the history of adventure games, create a working engine from scratch, and gradually transform it into a polished, sharable experience.
✨ If you’ve ever dreamed of writing code that brings immersive, interactive stories to life, this is the book you’ve been waiting for.
Price
Pick Your Price...
Minimum price
$19.00
$29.00
You pay
$29.00Author earns
$23.20Author
About the Author
Mike Gold
I have been developing software for over 20 years and worked as a consultant in the banking, manufacturing, healthcare, finance, and military industries. I am a former Microsoft MVP and have a background in Electrical Engineering. I've contributed over 200 articles on .NET/C# technology and have lately been working fullstack with .NET Core and ReactJS

Episode 249
An Interview with Mike Gold
Contents
Table of Contents
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.