Page Header

Brainfuck Puzzle Game

The initial spark for choosing Brainfuck came from the language’s intriguing name. As I explored its syntax and functionality, I became fascinated by its simplicity and unique constraints, making it a perfect fit for a puzzle-based game. While I briefly considered other esoteric languages like Deadfish, Brainfuck stood out as the best choice for this project.
Iterative Development

Development began with creating a working Brainfuck interpreter. Once I was confident in its functionality, I built a simple 2D UI to display information and accept input. The UI includes:
  • A password displayed on-screen.
  • An ASCII table showing character values for the password and output.
  • A text box for entering Brainfuck code (via keyboard or on-screen buttons).
  • A memory cell display to track values during execution.
As the project progressed, I let feature creep happen naturally. For example, I added an ASCII helper that displays ASCII values beneath characters to simplify translations without referring to the table.
Initially, passwords were generated with a fixed length of 8 characters. I realized this was too challenging and implemented difficulties:
  • Easy: 3 characters.
  • Medium: 6 characters.
  • Hard: 9 characters.
This change lets players choose a level suited to their familiarity and provides a manageable learning curve.
To encourage competition, I introduced a "daily word" system. Each day, a word from an RSS feed provided by Wordsmith.org is transformed into a password using a custom "Passwordify" function, which replaces certain characters with numbers, symbols, and capital letters. This ensures everyone receives the same word, fostering a shared challenge.

A leaderboard tracks the shortest Brainfuck code solutions for the daily word. It displays player names and code lengths without revealing solutions, focusing the challenge on optimization.
Initially, code execution was triggered by a button. I later added functionality for real-time execution. The interpreter now runs code as it is typed and updates whenever the text caret moves. This lets players step forward and backward through their code. While loops aren’t visualized in this system, it improves usability significantly.
Infinite Loops

Infinite loops remain a significant technical challenge. Without safeguards, such loops can crash the game. While I’ve included a warning in the help section, accidental infinite loops are still possible. Detecting these loops preemptively is a feature I’d like to explore in the future.

Simplified Help Section

The help section explains each Brainfuck command, highlights limitations, and offers context for new players. Notable deviations from traditional Brainfuck include:
  • Using 16 bytes of looping memory instead of the standard 30,000 bytes or infinite memory.
  • Disabling input commands to maintain the game’s puzzle focus.
While functional, the help section could benefit from a tutorial mode to improve onboarding for new players

This project has been an invaluable learning experience. Key takeaways include:
  • Gaining a deeper understanding of Brainfuck and interpreter design.
  • Learning Razor for UI development.
  • Exploring S&box features like stats and leaderboards.
While I haven’t conducted extensive playtesting yet, I’m eager to gather feedback now that the game is submitted. If time weren’t a constraint, I’d love to expand it into a 3D puzzle adventure with narrative elements and additional challenges.
The core mechanic could easily adapt to other simple programming languages or custom esoteric languages designed specifically for games. There’s immense potential to combine coding puzzles with gameplay for richer, more interactive experiences.

Thanks for reading, and I hope you enjoy playing the game as much as I enjoyed creating it. Let’s see who can write the shortest Brainfuck solution for today’s daily word!

Comments