Processing 1000s of AI objects

Hi,

I am trying to work out / calculate the feasibility and some of structure and logic of a game before I go all out into it.

What I am trying to work out is how can I manage, track and store the data for 1000s of AI active objects. The game will have 2 screens, a map and combat screen. The combat screen will process you vs ai, up to 3000 objects being rendered with AI.

However the map consists of a 50 x 50 grid = 2500 combat zones.

There will be AIs running which are building units and having their own conflicts in these zones which are unseen but you can navigate to them and watch or send your own units to join in (if you get there in time).

So in theory there could be 100s of grid zones having battles taking place, and only one of them will be visible and active with you interacting with it. Each unit can move to target, combat wont start till in range etc, even have strategic logic attached to the AI.

I also need to maintain state via load and save, I’m thinking dump all variables to xml and parse it for this.

What is the best way to structure and process this amount of data?
How much can be / is typically handled by games like this?

Any suggestions? Any information is much appreciated.

Thanks

Darcey

Hey Darcey,

The off-screen battle’s

For these battle’s you can just make a calculation for them based on units (which one defeats which one)
for example: if 1 horseman can kill 2 swordsmen before dying and:

  • Group A has 101 horsemen
  • Group B has 200 swordsmen

If Group A attacks Group B in theory Group A should win with 1 horseman left,
add some randomness to it and maybe Group A would win with 9 horsemen left or maybe Group B wins with 10 swordsmen left. Based on amount of units you can also make an calculation how long the battles would take!
That is for you to figure out :slight_smile:

The on-screen battle

is a bit more complex and interesting, first you have to list up what you want your AI to be able to do and search the choke points that will be hard for the computer to process and write down/search the way to fix these issues.

One that might be a choke point is the AI path-finding and decision-making.
Usually these type of games divide their units into squads with 1 commander/leader, this leader will handle all the path-finding and decision making and the other AI’s will “follow” their leader, this way the follower AI can still have some basic logic to… for example stay in formation or avoid imminent dead.

Take a look at the game Overlord and the Mount and Blade series, they have something similar.

Good luck with your project, sounds very interesting! Keep us updated!

Hope this helps you further a bit :slight_smile:
Elias

Thanks for the information Elias, useful.

My thinking so far is:

World
1000 to 5000 grid system

Player and AIs
0 to 10,000 variable incrementers based on max possible static unit builds (timer is every 60 seconds)
0 to 5,000 calculations on 60 second tick for time based calculation (unit build time etc), AI will run on this also
Max static non ai calculating units: 15,000
Max active units units player and per ai: 1000 (groups of approx 150, est 20 path calculations per group)
AI Decisions when player is within n tiles of AI will evaluate every 15 seconds, 60 seconds on other

This is max possible end game values, I doubt maximums would be hit however. Weighted random creation of grid zones and what is in each already greatly reduce those numbers, limiting what the player and the AI can have in each grid.

Too much?
Do you think this would be too much load on the CPU?
Is there any way I can load any of this on the GPU? Would it be beneficial?
Multi-threading, is there anything to spread load of available CPU cores? Would I need to build a system that detects and handles this or is there one built into UE4?

Thanks

D

Thanks for the information Elias, useful.

My thinking so far is:

World
1000 to 5000 grid system

Player and AIs
0 to 10,000 variable incrementers based on max possible static unit builds (timer is every 60 seconds)

0 to 5,000 calculations on 60 second tick for time based calculation (unit build time etc), AI will run on this also

Max static non ai calculating units: 15,000

Max active units units player and per ai: 1000 (groups of approx 150, est 20 path calculations per group)

AI Decisions when player is within n tiles of AI will evaluate every 15 seconds, 60 seconds on other

This is max possible end game values, I doubt maximums would be hit however. Weighted random creation of grid zones and what is in each already greatly reduce those numbers, limiting what the player and the AI can have in each grid.

Too much?
Do you think this would be too much load on the CPU?
Is there any way I can load any of this on the GPU? Would it be beneficial?
Multi-threading, is there anything to spread load of available CPU cores? Would I need to build a system that detects and handles this or is there one built into UE4?

Thanks

D

Hey Darcey,

It is indeed smart to balance your load out yourself to avoid huge framedrops.

I could be wrong but I think the unreal pathfinding is not multithreaded right now, it could be that the EQS system is, but also not sure ^^

Take a look at Rama’s pathing system: https://forums.unrealengine.com/showthread.php?25410-Rama-s-Multi-Threaded-Dynamic-Pathing-System-Full-Physics-Support

I would say, just start testing and check yourself how many raytraces you can do each tick, how many calculations you can do, etc. You are the one that knows best what you want so you can test for yourself specifically the areas you want to test.

I have no experience in pushing calculations on the GPU so you’ll have to figure that out yourself, but it could be that you won’t need it so look for this only when you really need it!

You should also take a look at this “Guide” https://software.intel.com/en-us/articles/designing-artificial-intelligence-for-games-part-1/

Good Luck,

Elias