Last time I put together a somewhat rushed post where I discussed my GOAP rewrite and vaguely touched upon a few of the latest additions. I’m going to go into further detail upon some of those additions to clarify things before moving onto the newest stuff. I feel like my writing has improved quite a lot, too, since I’ve found my footing. Time for a refresher!
The first new addition was the history system. This system keeps track of a number of stats that help drive agent behavior and each of these stats is fully integrated into my new GOAP implementation. This means, basically, that each stat behaves as an on and off switch.
The police, for example, will monitor the crime stat. This is a stat that increases when agents do something the game considers a crime – such as murder or stealing. If that stat ever goes beyond a certain threshold then law enforcements’ crime-fighting goal will be activated.
This means they’ll drop whatever they’re currently doing, such as idling at headquarters, to instead go actively search for criminals to arrest. They’ll keep doing this until they’ve brought the crime stat down to a more acceptable level through their own crime-fighting actions.
If any of this sounds familiar than you’re right.
The history system is a larger-scale implementation of the decision weights that my GOAP enabled agents already utilize when trying to decide which action is best. Technically, little has changed. They still use weights, have goals and use actions to accomplish said goals.
The only real difference is that they now have access to a public group of historical stats in addition to their own private stats. Hunger is a good example of a private stat. Each agent is different so they obviously need their own hunger meter. The same goes for health, money and other personal variables. Crime, though, is a historical stat. These stats are something that any agent can look at which is why I interchangeably refer to them as public or global.
The history system being plugged into GOAP means the agents are now super responsive. They’re all going to be reacting to the world around them even more so than they would have with standard GOAP. I’ve basically taken GOAP, which is known for being reactive only to its immediate environment, and dramatically scaled it up. The agents pay attention to the whole map instead of just their current surroundings. Eventually, this will be scaled up even further to include the whole planet and later the galaxy itself once more content is added.

The original purpose of the history system was to give my agents some problems so they’re forced to interact with the world in a more organic manner to solve them. I’ve since realized it has more potential than previously envisioned, though. The history system, for example, lets me influence large numbers of agents for almost literally no cost.
Instead of all the agents having to individually calculate whats going on in the world they can instead just take a peek at the history stats and react accordingly. It’s efficiency on the level of reading about some faraway event in the newspaper versus traveling to it yourself. I didn’t add it for performance reasons, but it’s nevertheless a nice bonus! I find it doubly interesting because the agents themselves are the ones making the gains possible. They modify the stats with their own actions and later reap the rewards by just looking at said stats.
It also makes the whole action and reaction thing I keep talking about much easier to add.
Let’s say the rebels just destroyed some kind of moon like space station. Let’s also say there was a historical stat that represents the rebellions threat level. The destruction of this space station would give that stat a dramatic boost – which, in turn, would activate an empire-wide response. This response would lead to a thousand forms of anti-terrorist activity and likely the rebellions demise if they aren’t prepared to deal with a major empire counter-attack.
Hunting rebel leaders, blockading worlds that support the rebellion, cracking down on pro-rebel politicians, interrogating rebel prisoners, searching for rebel bases, increasing foot patrols and producing anti-rebel propaganda are just a few examples I can think of.
The history system makes this kind of mass response a breeze. If empire affiliated agents see that rebellion stat get too high they’ll all begin autonomously taking anti-rebel actions.
It’s my first step towards adding that tug of war gameplay I want. The more the rebels harm the empire the more seriously the empire will respond. It’s an automatically scaling difficulty slider. If you want to actually take the empire down instead of just being a thorn in their side then you’ll have to start taking more extreme actions – which, in turn, will make them respond in kind. It’s inherently a self-destructive mechanic. The empire isn’t just some final boss that sits around all day waiting for you to come to fight them. It’s a faction that will actively move to protect its own interests. The more you poke at them the more aggressively they’ll react.
This fact passively enforces the need for subterfuge. I envision the game having a slow burn feel where you operate in the shadows to build up the rebellion’s strength. You have to treat the empire like a frog in boiling water. Turn up the temperature slowly to avoid attracting too much of their attention. Strike, let things cool off, then strike again. If you act like Rambo and start senselessly blowing shit up then you and the resistance will be dead before you know it. I actually have such a long-term vision that winning will likely require multiple characters.
Dismantling the empire should require several lifetimes due to the colossal amount of effort required. In other words, if you’re not killed in combat then your character will probably die of old age before your task is complete. The game will have one of those save systems where you generate a single world and can then play multiple characters in it. Your character might be dead, but his effects on the world still remain. This way your next character can build upon the success of the last. It’s eerily realistic because such a mechanic would reward you for doing the whole going down in a blaze of glory thing terrorist groups are known for.
I’ll probably make aging an option that can be disabled for those who dislike it. I’m a big supporter of letting people play how they want instead of forcing them to play my way.
Every single agent is goal-driven due to how GOAP works and as a result, the history stats are constantly changing. This results in a conflict of interest since there are so many agent types that prefer certain stat values. I like the way I put it in my previous post. In order for one agent to be happy they’ll have to do things that will make other agents unhappy.
I’m hoping this will help keep things interesting despite the project’s vast scope. I don’t want a Daggerfall-like situation where the game world is huge but empty. I think relying on AI, as in boots on the ground agents, is the best way to avoid the boring sandbox phenomena. I want a gigantic sandbox full of fun stuff. I was once thought procedural generation could be used to fix this problem, but I no longer believe it to be the holy grail I once thought it was.
Ironically, procedural generation probably causes the problem in the first place.
Thus, I’m going to try relying on the AI themselves for content instead. They’ll be the meat and potatoes of gameplay. They’ll make the game so damned interesting that you’ll ignore the repetitive map generation flaws. I think Bethesda and Stalker had the right idea with their Radiant AI and A-Life systems. Living worlds are better than pretty ones! These systems are a major personal inspiration of mine but I’ll talk about them later when they’re more relevant.
The player, of course, can also alter the history stats. This is the first of many steps towards allowing the player to have long-term impacts on the game – which is, of course, necessary for simulating a proper rebellion. Those empire troops you kill, for example, won’t just be magically re-spawned. This isn’t a call of duty match. Each of them will require recruitment, training, equipping and deploying. It takes time and money to replace those losses so even really low-end rebel behavior can have some small effect on the overall status quo. You’re not going to topple the empire by killing random troopers but you might free a town or two!
I’d also like if agents went through entire life cycles. This would make the above example even more important because now the empire doesn’t have an infinite supply of adults to pull from. It’s unrealistic to assume you’ll ever cause enough damage to stop recruitment entirely due to sheer number of people available in a galactic setting, but you’ll definitely be able to empty out small towns or garrisons.
This churn would also help keep the setting fresh by preventing stagnation. Let’s say some talented empire commander has been annihilating the rebels. His death by natural causes would be a huge relief to rebel kind. Lifting that boot from their neck would allow a dynamic resurgence of activity that even the player could notice due to the shift in difficulty.
I’ll probably end up adding such a feature because there are all sorts of sketchy side effects I can explore. Let’s say, for example, that agents are influenced by what they experience while growing up. If you’re willing to be manipulative, then you could go out of your way to cause a brutal empire crack-down on some poor town. This sounds counter-intuitive until you think about the long-term implications. If people grow up in harsh conditions due to said crack-down then they’ll naturally come to hate the empire. They may not join the rebellion itself, but they definitely won’t join or otherwise help the empire! It’s a double-edged sword, though, because those people can just as easily develop empire sympathies.
I like to support morally grey concepts, so the questionable guerrilla tactics such a mechanic would enable pleases me. You don’t have to be a man-slaughtering nutjob, but the option is there! I want the player to be able to fight the empire however they want and I intend to give them all the tools necessary to do so. You can be a bunker-busting commando, trade ship looting pirate, empire headhunting assassin, computer hacker and who knows what else.
I’ve also been thinking about how to give all the agents their roles. I don’t like the idea of just spawning a bunch of gangsters or soldiers. If I’m specifically spawning certain amounts of certain agents then all my work to make a dynamic setting is for naught. I think it’d be better to go for a job approach. Everyone could start as a civilian, for example, but later pick a job for themselves based on their experiences. If someone grows up in a crime-ridden city then they’ll become a police officer. If someone is scarred by rebel terrorism then they’ll sign up to join the empire. That kind of thing. This reactivity gels perfectly with all my previously stated goals so you can expect this to show up sooner rather than later.
Anyway, back to stats. That was a whole spiderweb of tangents.
The first actual stat I added was gang violence. Like I said earlier, all stats are modified by real-world interactions – and as such, it increases by 1 whenever a gangster attacks another gangster. That doesn’t sound like much but when there are hundreds of gangsters attacking each other every single turn that number sure goes up quick!
The next thing I added was two new agent types: civilians and mercenaries. I wanted to put my rewritten version of GOAP through the wringer so I decided to take a more complicated approach to countering the gang violence stat. The solution I came up with is two-fold. The civilians monitor gang violence and once it reaches a certain point they’ll look for a merc to hire. Then, upon finding a mercenary they’ll hire them to go blow up a bunch of gangsters.
This is the point where I decided to handle agent activity in a realistic manor and as such the game doesn’t just tell the civilian where a mercenary is at. Instead, they have to manually find a mercenary. I want the agents to follow the same rules as the player! Thus, to find a mercenary, the civilian just starts exploring the map by pathing to random locations.
I like this because it means there are agents out in the world actually doing things. You could be out in the middle of nowhere and still encounter some agents going about their business. They’re not randomly generated agents that were spawned just to populate the map. They’re actually members of the world on some kind of mission just like you! I think that’s pretty neat.
The civilian, upon stumbling across a mercenary, walks up to them and tells them what faction to hunt. This activates the mercenaries hunt goals which causes them to start searching the map for compatible targets. The gangster factions, in this case.

They’ll keep doing this until they’ve racked up 20 gangster kills. This is a hard limit I added just so the mercenary will eventually stop and give a different civilian the opportunity to hire them. In the future, though, the amount of money provided will dictate how many targets the mercenary will hunt. The mercenaries currently work for free since I haven’t added money.
Here is a video of everything discussed in action. Like I said, the civilians will start searching for mercenaries once gang violence is more than or equal to 1000. The mercenaries, when hired, then wander off and start annihilating gangsters until their quota is met. If you watch long enough you’ll notice the gang violence eventually starts getting out of control.
This is due to a bug that I’ve since resolved. It was caused by mercenaries being unable to detect when a gangster they’re targeting occupies the same tile. This, in turn, meant that the gangster couldn’t be killed. Eventually, all the mercenaries would get stuck and without them constantly mowing gangsters down that crime statistic would skyrocket out of control.
Also, you might have noticed the two graphs in the bottom right corner. They’re tracking gangster population levels. The problem I’m running into is that I need a more long-term view of whats going on. My usual method of displaying live debugging stats just isn’t helpful enough. I need to be able to track trends over longer periods of time in order to get a feel of what’s going on under the hood. I’ve thus started building fancier in-game visualizer tools.
This is a nice two birds with one stone situation because I’ll be able to let the player access most of these graphs. They won’t just be tools for me but tools for thee! I think I mentioned this in the past, but it’s critically important to give the player the means to view their impacts on the world. If they’re constantly raiding empire supply lines, for example, then they should be able to see a downward trend on some kind of economic report. It’s unlikely they’ll ever notice an impact through gameplay alone. This game is all about the long-term so changes will occur gradually enough that most people just aren’t going to notice. This means graphs and any other sources of information are vital. If people don’t understand how in-depth the game is then they aren’t going to enjoy interacting with it and otherwise get immersed.
That’s a pretty decent summary of the last post, I think! Let’s move onto the shiny new stuff.
I added a complex interaction last time but there still wasn’t a whole lot of decision making going on. The civilians hire mercenaries when upset and the mercenaries go kill stuff when hired. That’s it. There are no alternative options and as such GOAP’s fancy potential is being squandered. The whole point of GOAP, after all, is that the AI have options and they choose the one that’s right for them based on their current circumstances. The first thing I did to fix the situation was give civilians the ability to take matters into their own hands.
However, before we get into that, I need to explain the new personality system.
I ran into a problem when adding multiple paths of action to choose from. That problem was due to how GOAP works. It uses weighted values to decide which goals to focus on and what actions should be taken to do said goal. The system is too perfect and I was noticing all my agents acting like a hivemind. If there was too much crime, for example, then all the civilians would simultaneously begin searching for mercenaries to hire. This is a flaw with the history system that needs fixing. The agents sharing a single stat means they all react the same way. I could lessen the visibility of this issue by distracting the agents with things like hunger and other personal issues so they’re not always on the same wavelength – but I decided to just buckle down and perform some brain surgery instead of relying on bandaids.
The problem is that hiring mercenaries is objectively the best option. It’s the most effective tool the civilians have for dealing with gangsters. This meant that civilians were refusing to pull out a gun and dish out some much-needed vigilante justice. There are some obvious ways to fix this: such as fine-tuning the weights or adding more goal preconditions for additional granularity but that’s all a bunch of fiddly work!
I refuse to get bogged down with this kind of micromanagement. There might someday be thousands of agent types and god knows how many goals/actions – not to mention whatever other horrifically complicated things I add later! If I change one thing it will absolutely affect countless others. Trying to balance anything would be like untangle a pile of cords or herd cats. It’s possible but tedious and ultimately pointless since the game is still in development and thus constantly changing. Furthermore, I don’t want my game being predictable. If every single thing is perfectly balanced then players will be able to metagame their way into finding the best possible way to win. Introducing some random noise will keep them on their toes.
I’m also bad at balancing things in general. It’s a flaw I discovered several years ago when tinkering with some abandoned RPG concepts. The sheer amount of monsters and items I had to balance was a nightmare. I can do it, but I don’t find that kind of spreadsheet work fun. That experience is probably why I focus so much on sandbox games now. It’s not that sandbox games don’t need balancing, by the way, but people are generally more accepting of balance issues due to its open-ended and ultimately unpredictable freeform nature.
Hence, the personality system. It removes the problem with automation. The agents can now individually decide what they care about. I don’t have to perfectly balance things to ensure they consider all the options. The end result is that some civilians will now prefer to take up arms instead of relying on the mercenaries. The system itself is pretty simple.
It’s just a bunch of random numbers. In fact, as of right now it’s just one random number that I currently refer to as aggression. The higher this aggression stat is the more likely an agent is to prefer more violent options. It works by multiplying the weight of compatible goals and actions by the personality stat. Example below.

They’re still technically choosing the best option but now said options are tailored to each agents’ randomly generated preferences instead of them all sharing the same hard-coded universal response. I’ll still need to do some degree of balancing, of course, but now the line is kind of blurred and anything I add should at least get used by someone.
I wanted to point out before moving on that personalities aren’t just random numbers. They used to be, but I foresaw a potential issue with that and tried to preemptively take care of it. They’re now gaussian numbers. The problem is that randomization, despite the sound of it, isn’t very random. It tends to have an averaging phenomenon where the random numbers land in the same general area. Unfortunately, I couldn’t show enough lines on the visualizer to show you this problem. It takes a massive sample size before any noticeable patterns emerge in the random numbers. This phenomenon might be due to how pythons pseudo-random number generator works but it doesn’t matter now. I’ve found a better method.
Here is an example of 10,000 rolls between 1-3. I saved each roll and tallied them for a total.
1 = 3259 rolls
2 = 3429 rolls
3 = 3312 rolls
See? They’re all in the three thousand range. The numbers are different, sure, but they’re too similar for my liking. It’s not just bad luck, either. I could roll the dice a billion more times and you would always notice some kind of pattern. If I were to use these rolls there wouldn’t be enough deviation. The personalities might be randomized but each agent would act so similarly that you probably wouldn’t notice any substantial differences. It’s like mixing several colors of paint together. Instead of something cool looking you just get generic old brown.
I fixed this by using a gauss based random number generator. In the above example, I was rolling a number from 1 to 3. This means the result will always be 1, 2 or 3. That’s not how it works with gauss, though! Instead of those two numbers controlling the min and max roll they instead control the mean and variance. The mean can be thought of as the starting point while the variance is how far you can wander from it.
Example random rolls. They stay within the supplied range.
(1, 3) = 3
(1, 6) = 6
(1, 9) = 4
(1, 12) = 8
Example gauss rolls. The results can go beyond the supplied range.
(1, 3) = 5
(1, 6) = 4
(1, 9) = 7
(1, 12) = 17
I’m going to stick with gauss because of that boundary-breaking ability. I like the idea of some personalities going beyond a strict 1-100 roll. There could be a civilian that gets an aggression stat of 320 or something like that which would make them absurdly violent. It’s especially interesting because that number has the potential to get legitimately out of control if the moon aligns correctly and the RNG god decides to bless a particular agent. This will hopefully allow for some more unique characters to stand out from the crowd that can have a more interesting impact on the setting. Heroes and villains, basically.
I’ll probably also apply this technique to whatever form attributes eventually take. This way you could encounter agents that are unusually strong since they’re gifted with a bunch of strength or intelligence. It’s the code equivalent of being born with good genes. If there’s an agent with a strategic personality and supporting attributes, for example, then they could end up becoming some great rebel general. Or maybe they’re blessed with a combat-oriented mindset and end up becoming a great bounty hunter that’s feared throughout the galaxy?
I might be incidentally creating a basic form of natural selection. Survival of the fittest agent!
I could also make personalities act like a gatekeeper. If an agent isn’t strong, for example, then they can’t use the action that lets them break down a door. It will limit their potential in regards to GOAP. Let me use the above bounty hunter for an even better example. If that bounty hunter is an idiot then they’ll just randomly explore the entire universe for their target. That’s obviously a horrible idea. They’ll die of old age before they find that needle in a galaxy sized haystack. If they were smart, though, then they’d have a lot more options!
There’s also the possibility of inheriting bad genes. I haven’t talked about this yet, but gauss actually generates numbers that can be negative as well as positive. What does this mean? Attribute wise, it means agents can suck at things. They could end up with -200 strength!
Personality-wise, though, it means agents can be extremely for or against for something. If I take away the negatives then it means all the agents are neutral at worse. That’s because 0 is the minimum base-line, which just means they have no skill instead of negative skill. The inclusion of negatives, though, allows for qualities on the opposite end of the spectrum. If a civilian has -100 aggression then they’ll almost assuredly never do anything violent.
The above gif examples might not make sense since the agents have been abstracted to a graph, so here is an in-game example of gauss based personalities being turned on and off.
Anyway, a few paragraphs ago I started talking about civilians taking up arms. They do that now! Civilians with high aggression will take matters into their own hands and start attacking gangsters instead of looking for mercs to hire. That gives them two options now for dealing with out of control gangsters. They do it smoothly, too, due to the blurring effect personalities have in regards to their gang violence tolerance levels.
I’m going to go ahead and end the post here. There’s a lot more I want to talk about, but this post has been in the pipeline for months now. I had a lot of annoying things happen at once so it really messed up my schedule but things have finally normalized. Come back next time!
I’m going to continue adding more agents and maybe incorporate some basic gameplay.




glad to see you back!
– history stats will be localized ? For example rebellion level on a regional level, planet level and so on ? Otherwise a cop could react to a change on planet level and try to travel to other side of the world to fight a rebellion…
– I like the idea to simulate things, but if soldiers/rebels are recruited/trained/equipped/deployed, it’s really a game of planning between ais, where one side has nearly-unlimited resources (empire), a long deploy phase (move a lot of stuff around ) and other side a small force of rebel with low resourcs ( few men, equipment ) and a smaller deploy phase. For example empire ai could decide to create a new base in a region rebel ai try to attack always there and on the other side rebel ai can plan to steal weapon from empire warehouse, I’m getting the point ?
– I found these ideas really cool, but for player is crucial to understand where to interact and possible outcomes, otherwise is really hard to find a proper action
– do you plan to add “neutral zones” ? where agents can interact without goal to fight for territory ?
– about balance: consider to a feature for players to provide a “report” for balance porpuse, for example a copy of game world agents and a description, so is more easy to understand what is going on
– you should also get weight for agent’s personaly from agent’s histories. For example a civilian after get robbed many times start to seek mercenary help more often and so on ?
LikeLike
1. Yes. I refer to this as stat granularity. Town, region, planet, sector, etc. There will be difficult levels of stat accuracy so agents can make micro (or macro) stat-based decisions. I talked about it in an early draft of this post but later removed it since I already went on dozens of tangents.
2. I don’t understand your question exactly, but I think you’re correct and we’re on the same page. The empire is strong, but they have a million things distracting them. There’s a universe threatening invader they’re keeping at bay, for example! The rebels, on the other hand, are weak but they’re laser-focused with one goal. They also have billion angles to attack from. Politics, combat, hacking, etc. Also, the rebels won’t be one faction. They’re going to be hundreds of thousands of individual cells all working independently towards the same goal. The empire might be able to crush one of these cells, but they’re like a hydra and will grow new heads. You’ll be able to create your own cell or join an existing agent lead one.
3. I agree completely. I’m not exactly sure right now on how to make the player aware of how dynamic the setting is. They’ll be severely limited gameplay-wise if they are not able to realize its potential and take advantage of or otherwise interact with it. I plan to add an in-game ‘news’ feature that will alert the player to events in the galaxy to help a little bit. Then I’ll add all sorts of informational graphs. Other than that, though, I don’t have many ideas yet, unfortunately. :(
4. Probably no neutral zones. I’m not sure how to implement this in a non-artificial way. This game is all about freedom, after all. Even if the player is a rebel in a rebel base, for example, then they should have the option of being a jerk and killing their allies. The AI themselves won’t always be in combat mode, though. That’s just happening right now due to a lack of other options. If things go my way then combat won’t be a major driving force for the player anyway.
5. I’m not exactly sure what you mean about a report. Do you mean something like Dwarf Fortress’s legend mode? Like a way to “look” at stuff, such as agents, in the game to examine or watch it from an outside cheat-like perspective? I’ll need to implement these kind of tools for debugging so they could make it into the game as a player option.
6. I already plan to do this. It will help give agents more interesting personalities due to them accumulating life experiences that modify future decisions.
I think I answered them all. Thanks for reading!!
LikeLike
Thanks for answers, is cool to see your progress in this huge project, so keep going!
2. wasn’t a question, more a way to see if I understand correctly how games works
3. I think problem is more deep in this kind of project. Think about real world. To fight an evil empire as individual your most important power is information. You must do connections with other people, understand them, trust them, share a common goal, organize some kind of plan and then act. In all these phases there are so much things can go wrong ( on galactical, planet, regional level, or even personal, your buddy get hurt at work.. so no more buddy! ).
Given that, player should be able to understand what is going on on the news, right, but also in the underground. So for example at regional level you can “unlock” some kind of underground news on things you normally don’t know ( for example where buy mass destruction weapons ).
But I think this issue should trigger a more “bigger question”: do you plan to create a game or a simulation ? If you answer on this as simulation, use real world as example
4. neutral zones can be also zones where AI don’t want to fight, because there is almost high chance to trigger a bigger fight, for example in middle of a town
5. sorry! with a report I mean, when I as a player see something not working way I think is right, “dump” world/agent state to a file, so you as developer can investigate about the issue
6. this is for sure the main “manipulation point” for me. Trigger a change in agent personality and beliefs ( even if is hard ) can unlock a lot of interesting decisions, most of them are emerging ( not decided on design time )
LikeLike