Sometimes, an idea gets stuck in my head. It could be nearly anything from an art piece, to woodworking design, a game mechanic, or a story that I want to write. When it’s something that’s really gripped me, the idea can consume my thoughts. I find myself thinking about it over and over. Thinking up new ways of achieving whatever it is. After a while, if the idea matures a bit, I’ll take some notes. More often than not, the simple act of writing the idea down “purges” it from my active thoughts and I can get back to concentrating on whatever it is I should be doing.
Rarely however, note-taking doesn’t help at all. Instead of purging the idea, it gives me opportunity to iterate over ideas and come up with new approaches, or it introduces new questions that I need to think about and answer. When this happens, I prototype.
Welcome to No Rogues Allowed
What is it?
Well, right now it’s not much more than a tech demo for a weapon generation algorithm. When you visit the page, a random weapon is generated with a preset “randomness” and then is presented to you with some numbers that likely don’t mean much. You can choose to adjust the randomness modifier and generate more or less “powerful” weapons, or even generate a list so you can compare a bunch of results at once.
Well, I couldn’t get the idea out of my head. I thought I explained that before!
I’ve been playing rogue-likes and rogue-lites my entire life. Rogue-like is a genre of video game based on the original 1980 Rogue which is a turn-based dungeon crawling game with procedurally generated levels. I discovered Angband in the early 90s and have enjoyed all sorts of games in the genre since.
Roguelike (or rogue-like) is a subgenre of role-playing video games characterized by a dungeon crawl through procedurally generated levels, turn-based gameplay, tile-based graphics, and permanent death of the player character.https://en.wikipedia.org/wiki/Roguelike
The main feature of a rogue-like is permanent death. You progress through levels of an adventure, gathering weapons and other equipment, leveling up, and generally becoming more bad-ass while trying to reach the final boss. If you die, that’s it. Back to the start. You lose all your progress. Earlier rogue-likes (such as Angband) were extremely difficult and would take dozens of hours to reach the lower levels if you were so lucky. I probably played Angband a few thousand times and I’ve never actually beaten the game.
Recently, I’ve been playing some “minimalist” RPG games on my phone. I wouldn’t quite call them rogue-likes, but they are definitely inspired by the genre. While playing some of these games, I realized that their turn-based play meant that they’d be a great genre to experiment with on the web. Did I mention that I am a PHP developer?
That’s where the initial spark came from. I started thinking about how I could take the original rogue formula and strip it down to it’s bare essentials. I took a bunch of notes about this, trying to get the idea out of my head, but one thing kept sticking: how to games like these generate random weapons with cool names and a bunch of different attributes? So, I set to work figuring that out.
Randomized Weapon Names
I like reinventing the wheel. I probably could have looked up some resources, and worked out a “tried and true” solution in a few hours, but I don’t learn much that way. Instead, I decided to tackle the problem myself and see where it takes me. It’s a learning journey that I have set myself on more times than I can count and I would argue that it is well worth the effort. I have learned more about my profession by avoiding the “right” way than any course I’ve taken on the subject. Sure, in the end I come back around and “fix” things to be more conventional, only at the end of all that, I have knowledge of why we do things a certain way instead of just believing the dogma.
I don’t have a set of rules to plug these weapons into yet, but that’s okay. At the start, all I really cared about was generating some cool weapon names.
I settled on a selection of 6 different elements that could be generated and loosely defined some “rarity” for each element.
- Weapon – 100% of the time you’ll get a weapon name.
- Element – 5% of all weapons will have an element.
- Prefix Adjective – 25% of all weapons receive a prefix.
- Abstract Noun – 35% of all weapons receive an abstract noun.
- Associative Adjective – 40% of weapons that receive an abstract noun also receive an associative adjective.
- Bonus – 10% of all weapons receive a bonus which scale from +1 to +5
I’m not going to walk through the technical details in this post, I’ll cover that in a future post, but with this set of rough guidelines, I set out to prototype a name generator.
I was iterating quickly in the beginning and didn’t pause to take screenshots of my progress, but the early versions of this page weren’t even valid HTML documents. I was just building weapon names and dumping them in a list. I had about 15 different words for each of the categories and simply used some PHP built-ins to pick these elements and put them together. That first iteration took only minutes, but it worked well enough for me to continue.
After I figured out names, I wanted to start giving these random words some meaning. Remember, I don’t have a game engine yet. I don’t even know if I’ll ever design the game, but I wanted to have some sort of loose framework to plug some stats into and see what comes out the other side.
I came up with some things I thought would be important:
- Hands – is this a single-handed or two-handed weapon?
- Attack – what’s the base damage of this weapon?
- Defense – does this weapon provide a defense bonus?
- Crit – does this weapon give a bonus to critical hit chance?
I spun up a few SQL tables to hold these numbers and filled the columns with random digits. While working this out, I started adding more and more clarity to what I though the “game engine” would require and expanded on the initial modifiers.
- Multiplier – a special bonus that modifies all rolls for this weapon
- Magic – this weapon might augment the characters’ magic
- Flaming/Freezing/Socking – damage modifiers for foes that are weak to these elements
- Holy/Evil – works like the elements above but also stacks!
- Sneak – your weapon might help you escape combat… or make it harder!
- Str – a relative calculation of the weapon’s bad-assery based on how many of the attributes are assigned to it.
Now, when a weapon name is generated, the engine also compiles a total value for all of these columns based on the attributes of the final weapon. Again, there is no game designed to use these weapons, but adding these numbers really helped me visualize what was possible with a simple randomized generator.
But Why Did You Make the Website?
Did I mention I am a PHP developer by trade? Making websites is what I do for a living. When I got to the point where I had figured out my way to generate these weapons, I thought it would be a cool thing to write about. I was just going to include a bunch of screenshots like the above in my write ups but decided that an interactive demo was more fun.
I have lots of ideas brewing for this demo. Obviously, I have a game design in mind that would use this engine, but I’m not certain I’ll ever actually build it. In the not too distant future, I’d like to make the randomizer more interactive. Maybe I’ll let you submit your own attributes that get added into the database. Right now there are around 30 different attributes for each of the categories (besides Elements, there are only 4… Crippling is an element for the game engine purposes) and it would be great to grow that list exponentially.
I really enjoy the randomness of it and fully intend to incorporate that into whatever game engine this gets used in. Who doesn’t want a Crippling Demonic Knife of Majestic Tolerance +1 ? With more attributes in the database, the names would only have even more potential to be absurd and I like that idea very much.
Where to Next?
I honestly don’t know. The site is “done” for now. I’ve tweaked everything that I want to tweak to keep it safe and make it look nice on most screen sizes. I could to more layout adjustment for mobile, but honestly don’t expect anyone to use the site that often.
Right now, I have about 6 articles that I want to write about the technical challenges I had while working through this process. I may publish the code somewhere for anyone that’s interested. I may tweak the engine some. I may add more functionality.
Go play with it. If you have some ideas about how the site works… or doesn’t work… or you have some features you’d like to suggest, please let me know! I’d love to hear from you.
Pingback: Item Powers – Roguelike Design part 2 – Chevee Dodd
Pingback: Requesting Attributes – Roguelike Design part 6 – Chevee Dodd