[9] Super project

Youtube | Twitter

Hello. It’s been awhile! I got completely fed up with the current state of things several weeks ago and had to perform some major code related surgery before continuing. My GOAP implementation, while technically functional, was a major pain in the ass to use.

I’m pleased to announce that the surgery was successful. I’ve not only greatly simplified it as a whole but it also runs faster as an unexpected plus. This simplification is a big deal because it brought a lot of clarity. I don’t need to sacrifice a goat and consult the oracle anymore when adding new goals/actions or otherwise making changes.

That’s enough talk, though. Let’s get down to business!

Last time I talked about not knowing where to go next. I’ve since decided to continue adding new agents or improve upon existing ones. More specifically I’m going to focus on deeper agent interactions. Less shoot and more think! This is to both leverage my recent GOAP improvements and give the player more interesting things to do.

This isn’t your typical game and as such, I don’t feel comfortable designing it in a vacuum. I want to get the player added as soon as possible for testing purposes. I’ve been talking about all sorts of systems and making all sorts of promises – but none of them are necessarily conducive to fun. I need in-game experience to ensure things feel right. I’m following my gut, after all, rather than some kind of detailed blueprint.

There’s no point adding the player yet, though. The only thing they’d be capable of doing is moving and fighting. I’ve tested these things to death in all my other projects so I know they work. I need to instead expand systems, add mechanics and otherwise just give the player more means of interaction. The easiest answer is more agents. They’re all so unique that with each addition the possibilities exponentially increase.

What do I add next, though? I got stuck on this question for quite a while. It’s harder than you think coming up with non-combat related AI. That’s why almost literally every game in the multiverse revolves around combat. Eventually, though, the concept of problem-solving came to mind. I’m going to give the agents problems and ways to solve them by interacting with other agents. There’s never going to be a dull moment with such a system because it’s inherently anti-balance. The agents will never stop working due to all the action and reaction going on. That’s because in order for one agent to be happy they’ll have to do something that will inherently make others unhappy.

What exactly is a problem, though? More importantly, how do I even represent such a thing to an agent? The answer is my previously mentioned history system. No, I’m not that much of a genius. I didn’t think of something before it was needed. The originally envisioned system was a different beast that I’m going to borrow and repurpose.

The original idea was to give the game a better way of doing behind the scenes things; such as deciding what agents to spawn or what random events to trigger. It would do so by analyzing a huge log of recorded stats and responding accordingly. The purpose of this isn’t realism, by the way. It’s to help build towards a more interesting setting by hopefully letting the player more readily see their or others impact on the world. I’m just mimicking realism because nature already has the answer to lots of design issues.

I’ll still use the above-described system at a later date, especially since talking about it got me excited about making it, but for now, the idea is going to be modified to serve a different purpose. The new idea is very similar but instead of a background system reacting to history its individual agents. I’m going to record all sorts of things that are happening across the city and make certain agent types respond to certain stats.

These stats are what the agents consider problems and they’ll solve said problems by modifying the stat. They do that by doing something in-game. Emphasis on doing! The agents must physically do something in the world. I settled on this extra step of complexity early on as it will make the world feel that much more alive. It will also help combat the issue of massive sandbox games (like daggerfall) feeling empty. If a crime stat threshold is reached, for example, then the police will start looking for criminals to arrest. The process of doing so will lower the crime stat by taking a big chunk out of it.

I say a big chunk because I speculate it’s necessary to have the solvers reduce the stat more than the causers increase it. This is to avoid a potential scenario where the solver is forever stuck trying to fix something that grows faster than they can reduce it. I don’t want endless problems. They need to be resolved so agents are free to do other things! I want it to function more like a back and forth tug of war rather than an infinite loop. If there’s a thousand criminals causing mischief but only one officer to reduce it then they’re obviously never going to get anything meaningful done. It’s not that big of a deal, though, because these kind of untenable situations happen in real life. It’s more of a personal preference right now. I’ll need to do some hard testing to see if it’s better gameplay wise to ensure problems can be resolved or to let some things fester.

The first-ever history stat I’ll be adding is gang violence. This stat increases whenever a gangster attacks another gangster. However, the new stat isn’t worth much on its own. I need to add a new agent that cares about it. This tripped me up for a while because the obvious answer is some kind of law enforcement but that’s the last thing you’ll find in this awful part of the city. They’re going to be corrupt at best or actively evil at worst.

The answer? Civilians. They’re only a indirect answer, though. The civilians themselves will not be taking up arms to fight the gangsters. This is a rough and tumble place so I’ll probably add that as a option sooner rather than later, but for now, I have something else in mind. Like I said near the beginning of this post I want to focus on more complex interactions so I’ll be adding yet another agent: mercenaries. I’m going to sprinkle a few of them around the map. The civilians will hire them to hunt gangsters once enough gang violence has happened. Each kill will reduce the stat by a few points. It might also damage their factions territory. This is free for now but in the future it will cost money.

Implementing this complex chain of agent interactions is what originally caused me to throw my hands up in the air and dedicate a few weeks (months?) to rewriting GOAP.

This is basically what happens. The gangsters fight which increases the gang violence stat. The civilians hire mercenary goal is triggered when said stat gets high enough. This causes them to start walking around the map in search of a mercenary. They’re not allowed to cheat so they have manually find one! Also, they can only hire mercenaries that aren’t already flagged as working. Upon finding a mercenary that’s open for business, they then path to it and flag them as hired once adjacent. Hiring the mercenary then activates the mercenaries hunt gangsters goal. This causes them to start wandering around the map in search of gangsters to blast. Each kill reduces the gang violence stat by 300. That sounds like a lot but every turn potentially hundreds of gangsters are fighting. Each attack from each gangster increases the stat by 1 so it can balloon really fast! The mercenary will keep doing this until they’ve reached 20 kills.

My shiny new rewrite of GOAP made creating this chain of goals/actions a snap. In fact, it was no more difficult than creating anything else despite containing significantly more steps. Even though there’s all this multi-agent interaction going on the goals/actions themselves are still independent. There’s basically no increase in complexity anymore where as it used to be almost exponential. Thus, tying two different agent goals/actions together is no more difficult than a thousand. That’s good news for the future! I can easily see situations where the depth of thought reaches hundreds of iterations deep.

Think about the amount of interactions that might be required to topple the empire, for example. There’s so many potential steps involved that I can’t even make up a number!

I’m going to stop here. This post is beyond late and I need to get some content up! I’ll have some examples to show you in the next post along with some new developments.