Vangard

Yes, that’s a very nice perspective. I considered many times how I would implement something like that, because obviously it takes a huge amount of processing to have a whole world running by itself, with AIs loose around doing as they wish.

My solution, and one I will one day implement (Maybe Exiled Kingdoms II :smiley: ) is to run detailed and real advancement in the areas currently around the player, but only applying a statistical/simplified evolution over the whole world.

Example: you divide the world in blocks, similarly to minecfraft. It can look seamless to the player, of course. In the sector where the player is, game entities actually are updated and have their AIs active, and do as they wish. Level up, steal from neighbor, build a castle, etc. but on the other sector, you make them remain inactive, and only when player visit, you apply a “statistical evolution”. For instance, depending on conditions or circumstances, you make some die, some level up, some cities conquered… it’s like if the world freezes when player leaves, then you can fast-forward when he returns. Instead of polling all gameentities individually, you apply some formulas to see what happened. If you’ve played dwarf fortress, and see how it builds/makes the world evolve over eras, that’s more or less what I mean.

I know it kind of spoils the “purity” of your idea, but when you make things very complex/big, it can be the only way.

I did consider going that route, but I decided to aim for the “pure” implementation first, and only add in the approximations needed to achieve reasonable performance. I think the more approximations you add, the more closed-off the game becomes.

I do have shortcuts galore however. The social structure is hard coded, ecosystems respawn as a steady state, economics are a “managed” free market and so on.

That’s the right approach, be ambitious! Compromise only when you must :wink:

I’m inching forward… I had to rewrite a bunch of core Behaviors so they could play nice with each other. I also implemented psychic powers into my player sprite so that it can see into the heart and soul of the nearest human. Useful for debugging!

In other news logic millis have crept over 22ms so there is a red light on my project dashboard. Render millis are only at 1-10ms (depending on zoom) so no worries there. I should be able to bring the upper bound of rendering down to sub-5ms when I get round to implementing LOD.

You’ll end up needing at least one texture, I guarantee it! :wink:
Other than that, your project does seem very interesting, waiting for you to finish a playable demo so we can wander the Viking lands for ourselves ;D

J0

Just a little update, I’ve been working on the AI code for the past weeks. It’s going well but slowly.

Woah. This little project interests me greatly. I totally understand if your not intending to release the source (ie: you’re making it into a game?), but can you provide some insight as to how you:

a) generate/track/control the entities? (and how they interact with each other?)

b) your behaviour implementation? Are they given out to each entity at random? Or do entities learn/grow them over time?

The world is divided into a 100x100 grid, with each cell representing 100m x 100m. During an update an entity can only interact with its own cell and the neighboring cells. This means that logic updates can be done in parallel as long as each cell being updated is separate from other cells being updated concurrently by two intervening cells in all directions.

All entities have a list of behaviors. They get their behavior list from their current career. Each career has exit careers (so a warrior could become a champion or a berserker). When a character satisfies the various entry requirements and enters a new career, their set of behaviors changes.

Behaviors have a planning component and and an execution component. The planning component is more expensive but is run less frequently, while the execution component is executed each logic tick. The execution logic depends on whether the behavior is the current highest priority behavior. for example, if a woodcutter is chopping wood and is attacked by a bear, fighting has a higher priority, while crafting has a lower priority. In the implementation of crafting, no work is done if crafting is not the top priority.

Other behaviors get executed even when they are not top priority. For example, HungryBehavior increments its needToEat counter each logic tick regardless of what the character is doing.

Behaviors communicate with each other by setting shared properties on the character. For example, the woodcutter’s crafting behavior can only be executed when the character is adjacent to a woodpile, so if the character is not near a woodpile, the behavior sets its priority to -1 (cannot execute) but adds the nearest woodpile to entity.movement.desirables map (the other component of the map entry is the priority of the desirable). The GoToBehavior monitors this collection and if it is not empty tries to move to the desirable with the highest priority. (more accurately, in the planning phase, GoToBehavior selects the highest priority desirable as the target, and sets the behavior priority to the desirable priority).

Likewise if a behavior needs an item from the inventory and the item is absent, the item is added to the inventory.wishlist collection. And this collection is monitored by other activities such as PickUpBehavor.

As I’ve learned, debugging this stuff is a nightmare and I am just writing mountains of test code at the moment. :slight_smile:

By the way, some behaviors are not from the career. I am thinking about adding personality behaviors, like GreedyBehavior or LazyBehavior to make the characters more unique.

The other thing I am working on is asset creation. I have built a simple editor that lets me create assemblies of polygons, which I can move, rotate, scale and color. I just added code to export the models to file, so now I can start building assets more quickly. Here’s an example:


poly : 1
	r : 0.5723464273901672
	g : 0.515528580632166
	b : 0.9967328958884494
	a : 0.2365929697795081
	xPoints : 1.0, 2.921875, 1.234375, -1.96875, -3.375, -1.59375
	yPoints : -3.046875, -0.0625, 2.875, 2.765625, 0.0, -2.890625
	z : 0.0
poly : 2
	r : 0.18566339556255373
	g : 0.3657983597922627
	b : 0.1454039127869604
	a : 0.4126357919159338
	xPoints : -0.140625, 0.90625, 3.90625, 0.953125, 0.125, -0.59375, -3.65625, -0.84375
	yPoints : -3.75, -0.6875, 0.0, 0.40625, 3.546875, 0.953125, 0.609375, -0.65625
	z : 0.0

Just got to add the ability to define animations in the editor and then it is pretty much done :slight_smile:

My brain is a bit fried with debugging the AI logic, so I am focusing on easier parts for now like asset creation (utilities), LOD, Gender, Naming, Frills, and so on. It all needs to get done. This weekend I will have a code blitz and try to add two more career types.

I have a unique problem. Although the simulation runs fine, with the entities selecting what to do and getting on with it, I find it harder to see how to map this back to a human control. The logic has to be something like this:

  1. Player right-clicks on an oak tree.
  2. Player iterates their behaviors asking which can do something with an oak tree. (e.g. invokes plan with a Vicinity collection only including the right-clicked item).
  3. The player has a HarvestResourceBehavior that can chop down trees, so that gets executed.

But what if the player has several behaviors that can process the tree? For example, they might be able to chop it down, or talk to it, or enchant it. Do I pop up a context menu? Obviously I have to hide the context menu at times, like in the middle of a battle: “Do you want to talk to the troll charging you? Or maybe pick its pockets?”

Let’s say the player can chop down trees, or enchant them. I guess you could open a context menu when they first click on a tree, either after launching the game, or acquiring a new ability. Say the player chooses to chop down that first tree. Well then, the player would chop down any right-clicked tree. But then, maybe you could either change the behavior in some kind of menu, or by left-clicking on a tree to open up the context menu. :wink:

J0

Some nice thinking. It has a (few) disadvantages though: You would have to click multiple times to make the player do what you want.

My idea:
That when you press the right-mouse button a context menu opens, with all the behaviors to choose from in a radial menu. If the right-mouse button releases the context menu disappears, and the selected behavior will be executed. In the middle I would put the default behavior (which could be the last selected behavior), so that you can CLICK and not have to HOLD/DRAG the right-mouse button if the default behavior should be executed.

The advantage is that you can right-press the tree, the player goes to the tree already, and while he does you can drag your cursor to the behavior you wish (if you don’t wish it to be the default). All in one clean click, while being able to keep checking on the game, since a radial menu does not cover half of your precious screen. + they are evident (if really needed you could show a description on hover)

An example radial menu:

With this you can just show it in the middle of battle, since it is very fast and does not cover half of your screen. I think the problem is less unique than you think :slight_smile:

Thanks, that’s an excellent suggestion.

I’ve been looking for this kind of game for ages! I can’t wait to play it!

Me too! :slight_smile:

For anyone into early mediaeval / dark ages stuff, I can highly recommend Njal’s Saga. The story ticks along at a great pace, there is a little authentic magic and masses of historical detail. It’s so vivid it’s incredible it was written 700 years ago.

So the social structure will work something like this:

High King/Queen
King/Queen
Earl
Chieftain
Landholder
Peasant/woodcutter etc

Specialists like traders, priests, magic users are all in a parallel structure, but won’t get a status much higher than Earl. Unless they get major bonuses from their items, dwellings, wealth and so forth.

Is this code bad? I would never write stuff like this at work…


thiss.inventory.add(world.encyclopedia.itemLibrary.getInstance(spawnType[i]));

Don’t you mean

this.inventory

? :persecutioncomplex:

Actually no, the bahavior does not have a backreference to the entity, so I pass in a thiss variable to the plan() and execute() methods.

I scaled up villages to the right size this weekend. Villages need about 20 - 25 dwellings to represent all the economic specialties, the warriors in the chieftain’s entourage and to provide a sufficiently large tax base for the chieftain. I expect that there will be maybe 80 villages in the game, some larger and smaller, with the possibility to found new settlements in wilderness areas. With about 4 kingdoms, each kingdom would have about 20 villages (or 16 chieftains and 4 earls).

At the moment villages consist only of peasants and woodcutters, but it is pleasing to see the bustle of the villages as the little people march to and from the market with their produce. With a higher density of buildings, vegetable plots woodpiles and so on, there is a lot more traffic and obstacle avoidance going on.

Logic ticks are at 21ms now on an A10 processor.