Wholly Random Game Generator

Published on 10 May 2025 at 22:26

"Goals transform random walks into a chase" - Mihaly Csikszentmihalyi

 

Introduction

 

This is my weird software development blog where I often try to take fringe ideas and develop them as a way to try different things. 

 

If your not following Hello World skip this section.

 

I have been working on the hello world which is a mammalian brain simulation written in python but I have found that the accuracy drops off as I gather more data. 

There is a interesting story where I might have messed it up and need to spend some time fixing it. It involved a bug where if the brain showed no EEG activity it would output the right answer because of a bug in how it picks what it thinks is the right answer. That's pretty bad but I put it through a genetic evolutionary algorithm type process and what do you know it evolves to kill all brain activity. Therefore I need probably need some time to work out that bug when I introduced it and what real accuracy looks like.

I basically figured it out when it jumped up nearly to 90% accuracy and went well either I need to use this to predict the lottery or it is broken. It was broken but that was £2.50 well spent to figure that out. Jokes aside it is back to working but I am not sure when that bug came in so I have to disavow previous accuracy and that I am not sure how accurate the build is but it has already back to saying it's first word point so it does work but I have to say I am not going to be opening to a competitor to Open AI any time soon. 

I think there is a life lesson there can build a brain simulator but judged it by the wrong heuristics; ruined it and killed it. Judging something by the wrong heuristic kills all future growth.

Life lesson the heuristics you use to judge the world are often more important than anything else. Luckily this blog is very much in the experimental side of coding it is not like I was a major CEO on a billion dollar company saying I was going to replace everyone's job in a set timetable of months. I am just glad after all this the brain simulator still works at all there was a moment I found the bug and thought id just wasted weeks of time on this until I saw some words turn up after a few tries.

I had not just made a mistake I had by chasing that mistake; gone in the wrong direction and in many cases when fixing found myself undoing what earlier I had thought was the right way. 

There was a moment I felt quite depressed as a coder because of this but I think you should not hide your mistakes but make monuments out of them to help others. If you build anything, out of anything measure twice then cut/programme/code once...

 

While I figure that out I am just going to share about another side project. 

 

My Cosy Game 

 

This is the game I made and play to unwind its a wholly random game generator attached to a random language generator so that all the items, enemies, character options such as ancestries, and classes are all randomised with a economic driven system for buying and selling goods like new weapons, training etc.

 

You can watch a quick play here:

 

https://www.youtube.com/watch?v=D5NOFq3nEdI&feature=youtu.be 

 

It is something that I find oddly compelling to play. Your probably going Joe that's a bunch of coloured squares where's the 3D graphics. Joe where is the VR?

 

Ok I get it....but every game every time someone plays it they will get a completely different world, a completely different game. It is wholly random. It feels that it ought to have at least niche appeal (maybe just me).

 

Everything is random and there's a certain charm to not knowing what the world is like and figuring out enemy behaviours from nothing.

I keep coming back to it.

 

Language system

 

 The code has a lot of object oriented design, a Demiurge creates the world builds the language and then stores all the data into a system called Bestiary that stores the patterns for what given items or monsters do and how they behave.

The language generator has multiple functions that call out to each other. It does some intense work up front and its a bit spidery. But ultimately deletes itself having created major phonemes and built it into a whole language.

The code for it uses the same ideas you find here 

 

Artificial Language Generator | A Logic Called Joe

 

My idea was that Tolkien created a random language for Elvish and largely a lot of the subsequent ideas around it developed from there. 

The whole code base has some very bespoke pseudo random number generator code. I wanted to be able to have precise control on how they would be seeded and stored.

The levels are persistent but that's just stored in two numbers and it's all just fractals and clever pseudo random number generation.

A whole world is stored in two numbers if you know what to do with them.

 

I really just used this project to get my design pattern skills a bit better in some ways. Its a lot of abstract factories and in some sense the whole game is spun ff factories building game tools that build other game tools mimicking a game developer so I could abstract the whole process down to where I could randomise it.

 

It is simulations all the way down

 

in deciding I wanted to write a whole random game generator everything has to be stacked simulations. In fact what Demiurge does is take the random seed from the player and build the world then neatly store the now randomised data into nice neat data structures. 

 

It might seem easy to do but most games can write a function that tells the game that item X is special and it follows different rules. Every permutation has to follow the same rules the same way. It means that every item can have no special edge case, no clever code that handles something off camera. 

 

I made a Tolkien Fantasy Generator 

 

Yeah so my vision for this work was the idea that a lot of fantasy has become stale because everything is Orc this, Elf that... People have become a bit obsessed.

I wondered if you just took the ideas of generate a whole world, a language like Tolkien created his elf language well you could abstract the whole thing down to a system that could generate new enemies on the fly.

If you go back to a lot of Tolkiens work seem to be in writing these fake languages and then building the world from them. So I was thinking how close could you get to randomly generating a whole fantasy world.

This game does not do Orc this or Elf that it generates whole races on the fly, completely different enemy types with their construction. In this way I just can say generate me X antagonists they will be all named according to the same language phoneme system, different abilities and weapons.

Using the same phoneme system ensures that the language sounds like one language and shares sounds. It's again scaleable so you can go mad and make as many enemies as needed.

 

Everything that comes from the language in this game shares similar phonemes i.e. sounds and this was important in order for it not to feel random or strange (or at least it does feel strange at first but that goes as you learn the phonemes). I felt this could create wholly unique worlds without a orc or elf in sight. 

You would play 1 game in a wholly different world from , unique to you. Because of how the random seed system works there is more random dungeons, each with a unique language, enemy types, items wholly unique to your play through.

 

Tolkien made different metals. Woods and often giving them names coming from the initial language system. So I made the language first then everything spiders out from a world generation algorithm. 

There's alot of different niche generators a city generator. Elemental generators are nice as it can make things from different materials and then themes them off those materials.

A downside of this approach is really any game feature then requires a lot of planning and multiple generators. The nice thing is when it works it doesn't produce one new feature but near infinite.

I am going to say this a lot but that hits different. I end up playing a lot just to see all the oddities it creates.

 

There is a certain magic blinking and this whole game was made handed over to these simulations and now your playing in it. The core rules are the same for every play through but a lot of the items, combos and ideas will be unique to you. I still feel this is a area that I have overpromised and underdelivered on though. Though this is the first blog post on this and I am sort of testing the waters to see what peoples response is to this prototype. 

 

What do you think if a game was random down to the very language it used was random Would that be fun?

 

My other inspiration 

 

I really like the idea from the berlin interpretation of what a roguelike is. I wanted to make a roguelike for a long time. I started with the object of the game is just to get to the end of a dungeon. I though a big world could come later but I wanted to go really old school and back to the 1980s. 

 

Rogue is a game so old so niche it not only named the genre it comes from they wrote a definition for that genre that is names as if it was a religious schism - the berlin interpretation. 

 

Berlin Interpretation - RogueBasin

 

Truth be told I ended up on rogues basin another guardian of the interpretations of what a roguelike is and this is somewhat a result of trying to do their coding challenges. 

 

RogueBasin 

 

There was a odd moment where the game system generated a whole world, infinite possibilities stretched forth and then your character died and the game wow...deletes the whole world, a whole language system. That hit differently. 

 

 

==General Principles== "Roguelike" refers to a genre, not merely "like-Rogue". The genre is represented by its canon. The canon for Roguelikes is ADOM, Angband, Crawl, Nethack, and Rogue. This list can be used to determine how roguelike a game is. Missing some points does not mean the game is not a roguelike. Likewise, possessing some points does not mean the game is a roguelike. The purpose of the definition is for the roguelike community to better understand what the community is studying. It is not to place constraints on developers or games.

 

This is how my game maps:

 

==High value factors==

 

====Random environment generation==== The game world is randomly generated in a way that increases replayability. Appearance and placement of items is random. Appearance of monsters is fixed, their placement is random. Fixed content (plots or puzzles or vaults) removes randomness.

 

====Permadeath==== You are not expected to win the game with your first character. You start over from the first level when you die. (It is possible to save games but the savefile is deleted upon loading.) The random environment makes this enjoyable rather than punishing. plus on mine the whole world dies with you. It is quite poignant the first time it happens by surprise. 

 

====Turn-based==== Each command corresponds to a single action/movement. The game is not sensitive to time, you can take your time to choose your action. IU implemented a energy system. It is quite invisible to the player but all the actions you take take energy

 

. ====Grid-based==== The world is represented by a uniform grid of tiles. Monsters (and the player) take up one tile, regardless of size. Its squares all the way down to the Z level.

 

====Non-modal==== Movement, battle and other actions take place in the same mode. Every action should be available at any point of the game. Violations to this are ADOM's overworld or Angand's and Crawl's shops. # Mine is most likely a Angband like. 

 

====Complexity==== The game has enough complexity to allow several solutions to common goals. This is obtained by providing enough item/monster and item/item interactions and is strongly connected to having just one mode. It does but its mostly stealth versus charge. I think this is a area that over time I would build on for this prototype. 

 

====Resource management==== You have to manage your limited resources (e.g. food, healing potions) and find uses for the resources you receive. Yep 

 

====Hack'n'slash==== Even though there can be much more to the game, killing lots of monsters is a very important part of a roguelike. The game is player- vs-world: there are no monster/monster relations (like enmities, or diplomacy). This is one that I am kind of playing with the most it is a hack and slash as a game you do bump into monsters you do take damage and die but I consciously down played this.,

 

====Exploration and discovery==== The game requires careful exploration of the dungeon levels and discovery of the usage of unidentified items. This has to be done anew every time the player starts a new game. Everything is random, light matters, 

 

==Low value factors==

 

====Single player character==== The player controls a single character. The game is player-centric, the world is viewed through that one character and that character's death is the end of the game. In fact t is quite sad when a whole language goes out the window.

 

====Monsters are similar to players==== Same code for both

 

====Tactical challenge==== I focused on stealth systems. Enemies have sense of smell, sight and hearing that radically changes how they patrol for you. The AI is not amazing but it feels sensible when you stand in front of a enemy they see you and charge, even if you turn the light off they will continue looking. 

 

====ASCII display==== I used colours but probably will implement the Asci characters at some point.

 

====Dungeons==== Roguelikes contain dungeons, such as levels composed of rooms and corridors. ====Numbers==== The numbers used to describe the character (hit points, attributes etc.) are deliberately shown.

 

 

 

I found during my research that I felt that it would follow the classic Angband style and specifically there was a sub group of Angband players called delvers that continue to play and compete in this 1980s game to not fight their way to the finish but sneak... They play a hack and slash monster killing game like their solid snake... I mean I do a blog on weird software development, but building a game based on a niche group of playstyle for a genre from the 1980s was something even I found.... I just did it.... I just made the whole game one day....

 

Do not ask me why but a whole summer of watching people play the original rogue, Net hack, Angband then bam just decided to make one... Like you do!

 

This was the result a game that I set myself the target of not writing a roguelike but randomly generating one whole. Hit generate everything just pops up.

 

 

Problems Arise Almost Immediately

 

 

There are reasons that whole games are not routinely randomly generated and it is game balance. It was a very "interesting" thing realising this that actually random is not so much fun if you cannot fight your way of level 1. I think this is why most games are so carefully built by hand because imbalance and balance have to be fine tuned to be fun.

Though then you start working through these problems and I really enjoyed the shift in thinking that came with it...

 

 

So the thing about wholly random games is well they are random. There was a lot of starting a game realising the enemies where too tough. My two approaches to this was to work out a rough level scaling system in the background. Roughly speaking you will not encounter enemies too high unless you go too deep and frankly if you go too deep that your problem.

 

Made stealth the focus the game in the backend is very interested in enemy sense and they have everything from sight, hearing and smell and different systems work for each. But this is really to allow the player top find sneaking around enemies interesting. If enemies can be snuck past then the fact they where randomly generated stronger is less of a issue 

 

Make the game Loooong... random spikes tend to work themselves out over a long enough time. Thanks to the magic of fractal pseudorandom number  generation its a infinite dungeon.... probably a tad excessive... but that dungeon is infinite. I probably do want to add in a end game if I realeased it. But for now infinite scaling challenge has a certain charm.

 

Decoupled growth from combat you sell things to buy training. I have noted the primary game loop of a lot of games is somewhat of a murder hobbo system you go places kill things eventually your strong enough to kill the area boss. This game was a bit of a experiment and so i used capitalism and economic theory.  Everything has a gold price , how much of what you can carry ends up being a opportunity cost. 

 

I had endless fun in my own game realising kukri where very light and could be sold because they where metal. I patched that but it was a interesting inversion. Most games killing means points, points mean power so you end up playing walking mega death. It was interesting how implementing different incentives changes the whole approach to the game. Now enemies are obstacles that cost health to interact with and as such the typical male hyper violence game loop is stymied. Fighting is a risk so every battle avoided is better than the battle won which costs health. It was quite interesting encountering a antiviolent Nash equilibrium in a game. 

I think it's a small thing but it made it fun to realise the whole game shifts when you change the incentives for the player.

 

Though feel free to kill everything in sight but i think you get more if you focus on stealth. The very feel of the game meant that i built the controls around making it feel slick to run around which is why you see in the video i run around a lot. It feels like Pacman but with RPG elements. 

 

Though its pro stealing. If your not incentivised to kill things then what rewards you is what you will do. So every chest is something to nick. I am definitely going to spend some time thinking about more mechanics around theft; traps on chests etc seem what will happen next. 

 

In deference to the Angband Delver the game focuses on going down floors and escaping the dungeon. I tool the idea from darks souls that any rest or healing reset the dungeon. The game loop involves trying to find enough loot to escape the dungeon until tough enough to go further down. 

 

It is also a data analyst like me game. So many items are randomly generated some items can change your characters stats poisoning them or healing them. It is often really odd not knowing what anything does and it ends up in being a game in itself just knowing the things and enemies and how they work in your game.

 

 

Its not a game its a philosophy

 

 

This is the first time I am sharing this game it is a real niche and strange side project that I just code one day and kind of a oddity that I am unlikely to ever give a release. It is not a game it is a philosophy change; Or at least that is why I built it. I have plenty of side projects but I genuinely enjoyed this as being a odd learning experience on how all these small changes added up to a different experience than the original game I took inspiration from. 

Though what I found really delightful in it was how much it changed my thoughts on game design. It really is best played without fighting. Combat is oddly trivialised in multiple ways. You might think there is not a game after removing all that. In the typical game everything is a blocker to progression and your forced to fight every orc.

The fact you must fight means the game must be balanced because if something can kill you it becomes a impossible blocker in the path and that would be unfun.

Because something can block your path your game requires you to hand craft every element to make sure its fair. 

To make sure progression does not stagnate and keep the game fun you reward every act of fighting with experience and eventually a level up. You did this because by tying progression to doing the core game you make sure people play the core mechanic and can grind to eventually get enough experience to strangely trivialise the actual core mechanic. 

Most games are actually a grind loop for you to spend enough time killing things to get to the point where killing things has been trivialised so you can progress the story. 

Because you hand crafted it you had to give it a name and a backstory, you wrote a whole world to describe its backstory and situate the player character in that world and why they have to kill that orc right there and now. 

Because it was easiest you used the idea of Orcs, Elves and stuff to write you made a generic fantasy world, a generic sci fi world, a generic horror world for your game about fighting. So oddly it might not need to be a Orc but the aforementioned requirements probably mean your very likely to have Elves fighting Orcs because you have hand fine tuned all these mechanics designed the whole thing and now you have to make it memorable and ironically after building that whole thing your more likely to generate the combat and not the story. 

Because you need to have something to fight your very likely to need to design everything about that game loop to make it fair. 

 

But a interesting thing happens when you say their just obstacles and its not all that goes away you can do anything you want, you can fight you can do stealth you can do anything you want the whole thing can be randomised..

Trade systems and other incentives can be used for personal growth. I quite like this money system it makes you have only one currency for everything and what 

Because it does not need to be a Orc, it does not need to be balanced. Life does not need to be fair as soon as you accept it does not need to have violence in your game.

After that the whole world can be randomised, if it generates a monster too hard. Then there are other solutions available. 

 

I thought that was interesting that I got all that from a game that simple that it was wholly just colours and text... I mean I am not especially proud of the game it is very simple and a lot of people could manage it (the LOS though I really did that maths on that; Bresham eat your heart out) but it just felt different....

 

Infinite fantasy worlds generated on the fly. Different items, different people, different languages. Why not just randomise the whole game, its systems for everything though that gets excessive it does have a charm.

 

Add comment

Comments

There are no comments yet.