[7] Super project

Youtube | Twitter

Hello! It’s time to get down to business. The last post was super wordy so I thought it would be nice to balance things out by filling this one with a bunch of serious progress.

I’m going to start by just spawning a bunch of different agent types. I’ll be focusing on stereotypical criminal archetypes for the time being. Gangsters, smugglers, assassins, thieves, pirates, spies, druggies, hackers, outlaws, slavers, fences and so on!

I’m making this city a sketchy place for more than just atmospheric purposes. The long term plan is to use it as a launching point for developing the whole rebellion thing. What better place for rebel sentiment to fester than one full of criminals?

The first thing I need to do is get some proper pathfinding working. The deer you saw moving around in previous videos weren’t doing anything too intelligent when it came to movement. They were just searching their neighboring tiles for the one closest to their target and then moving to it. This lead to them always moving in straight lines since that’s the quickest way between two points. This was fine for an environment with no obstacles but the city is full of obstacles. It’s probably one of the most cramped residential areas the game will ever see. The below video has updated pathfinding. The deer now have to navigate all sorts of complex paths to reach their precious berries.

The pathfinding issue is fixed so now it’s time to start adding new agents. It took me a while to figure out where to start, though. I eventually settled on gangsters since they’ll give me the most bang for my buck. The gangsters, due to how they fight over territory, means that by simply adding one agent I’ll get a city full of activity.

The gangsters will also drag others into their warfare since they’re messy fighters so it will have an accumulative effect as more agents are added. I actually need to do quite a bit of work to add them, though. I’ll need to get a combat, territory and a faction system up and running. Then I’ll have to create a bunch of new GOAP goals / actions for them.

The territory system is a two-dimensional array. That sound’s fancy, but it’s just the computer equivalent of a checkerboard. Each number in the array represents what faction owns it. The number 0 means nobody owns a tile. It’s neutral. Every other number is unique and belongs to a specific faction. I’m going to use Star Wars for some faction examples. I’d use my game, but there’s no official factions yet! The number 1 might belong to the Mandalorians while 2 belongs to the Hutt Cartel.

I couldn’t figure out how to make a grid of numbers to visualize things for you so I made one out of colors instead. It’s pretty ugly but there’s only so much you can do with paint! The left image is the city. You might not remember it, but I went over its creation and other related details in a previous post. The middle image is the city with the territory overlaid upon it and the last image is the territory array on its own. The color white is neutral while the other colors belong to various factions. Feel free to imagine green belonging to the Hutt Cartel, purple to the Mandalorians, cyan to the Trade Federation and red to the Meatlumps. The territory array is the same scale as the local map which means they’ll be fighting over every single inch (or tile, in this case) of land.

The previous example was pretty ugly so let me show you an in-game implementation. This is the city with a better looking color overlay showing who owns what. There’s no actual factions or anything added yet. I’m just using simplex noise to simulate it.

The above example ended up looking like a terrain relief map. It just doesn’t look like what you would imagine a territory control map to look like. I replaced the noise with flood fills instead and got a much better-looking result. The fake factions are now mostly spread into their own regions which is what you would expect. I imagine this is how things will look once I get the agents added and fighting for territory.

I made this on accident but it ended up looking pretty cool. I could use this to simulate clouds, smoke or some other weathery stuff in the far flung future.

Anyway, It’s time for the real deal. I don’t want to overly complicate things so for the time being each agent will be their own faction. I’m going to have them all fighting one another as they work to expand their personal territory. I’ll change this to be groups of agents working together under one banner once the gangster basics are functioning.

Okay, well, here is step one. I’ve spawned 800 agents (because why not) and turned each of them into their own little faction. The factions are visually represented by all the different colors. The colors are random but not unique. If you look close enough you’ll see some similarities and even exact matches. That’s okay, though, because the factions themselves are unique objects. Even if two agents are the same color they’ll still consider each other enemies. The next step is to get them claiming territory.

This is what the random spreading looks like. It’s not as cool as I thought it would be. The video has two examples. The first part is with 800 agents and the last is with 100.

Okay, now I’ve let GOAP take the wheel. I’m blown away by how easy this was. I just made a new goal for spreading territory and a new action for finding the closest valid tile to spread to. Then I passed those to the agent and that was that!

I think that’s enough for today. I have a good bit more to share but this post is becoming unreasonably long. Come back next time for more gangster stuff!

Leave a comment