Game Development Community

Maximum number of Ai in game?

by Andy S. · in Torque Game Engine Advanced · 12/29/2012 (5:03 am) · 7 replies

Hi,
I am working on my new project. It's a squad based action-rts, similar to syndicate wars. As I plan to have lot's of Ais wandering about, I am starting to worry about performance. What are your experiences with having lot's of npcs in a map? What is the maximum number? My Ais all use pathfinding, for this I bought walkabout, which so far works very nice.
My levels do not use Terrains, but are constructed completely in a 3d-package. The Level is shown trough a Orbit cam which can be rotated an zoomed. Any advice on how I get the most performance using this approach? One huge object or several smaller objects to construct the level?
Does T3D have built in occlusion-culling? Are there somewhere General tips on how to improve performance in T3D?

Some more questions:
How can I restrict the camera to the mission area, so that it cannot leave the mission area?

Can someone please explain the difference between Basic and advanced lighting? I understand advanced is a deferred renderer and allows unlimited lights. What are the pro's and con's of the two?

Thanks

Andi

#1
12/29/2012 (7:51 am)
I haven't messed with AI all that much yet, but I was able to find out, after setting up an echo at each function that the AI after it was killed was still running a bunch of functions. So I added: cancel(%this.ailoop); at the area of onDamage where it determines the AI is dead.

In order to limit some of the CPU processing you may need to look for situations like this, and streamline it so they are not constantly eating up throughput.
#2
01/08/2013 (12:09 pm)
There's no set maximum, but the more work your AI is putting into thinking, the more overhead there's going to be.

Here's a shameless link to my Tactical AI Kit addon. My AI likes to do a lot of visibility calculations and receive environmental input to keep them on their feet at all times. Given all that potential overhead, I can have about twelve on-screen at any given time before my lousy laptop starts to lag up.

Now, there are a few ways to fix this. This most obvious way is to reduce overhead. TAIK AI players like to do more raycasts and visibility checks for the sake of not "cheating." The object check function could be simplified to your needs, all the way down to simply casting rays to every object and "seeing" the ones with clear line of sight.

I had a civilian AI type working a long time ago. That was just using that simplified object check function, and their only function was to run away from gunfire. I could have about 80 of those on screen before things would lag. That's just to give you an idea of how simple, low-overhead AI will work in a scene.
#3
01/08/2013 (12:20 pm)
Quote:One huge object or several smaller objects to construct the level?
Does T3D have built in occlusion-culling?

I'm assuming your level is one big COLLADA file? In the Torque 3D editor, there's a checkbox field you can set on that object (its name escapes me) that lets you enable culling within itself. Also in the editor, you can drop in zones and portals that restrict rendering to your liking.

Quote:Are there somewhere General tips on how to improve performance in T3D?

Good zoning in your levels and proper LOD on your models is a must. Also, compiling your project in Release mode (instead of Debug) will give you a substantial framerate boost.

Quote:Can someone please explain the difference between Basic and advanced lighting?

Basic lighting doesn't do dynamic shadows. Lights will light things as they should, but they won't cast any shadow. It's a lot faster than advanced lighting, but the end user can change the lighting type they want through the lighting quality in your game's options window.

Using basic lighting, you can still fake shadows in your building by baking them with your modelling application. I personally use Blender to build my levels and bake lightmaps, and I'm fairly certain 3DS Max can bake as well (no personal experience with it). PureLight is great for building beautiful lightmaps, though it's pricetag is a bit of a burden.
#4
01/12/2013 (8:00 am)
Just a note - on a relatively low-end machine, if the AI isn't "thinking" much you can probably handle a hundred at a time - we did this yesterday at the office and got about 130 before framerates dropped below 10-ish, but each unit was doing two full container searches with one line-of-sight test to find enemy units every 200ms. If you make them dumb (or use a "LOD" priority system to keep units far from live players from thinking as often or at all) you can get even more. In this scenario with dumb units (empty "think" function) we got about 400 dumb units and about 40 "smart" units (smart ones were still doing searches) before framerates hit 10-ish fps.

The AI "LOD" system I am using still does a full search from each client connected to the game to every AI unit to determine if that unit should have it's "thinking frequency" changed - units closer to a "live" player camera will have their think method called more frequently than distant units, but if any player is near it must keep its frequency high so it appears responsive.

Bryce's zoning and model LOD optimization advice is very solid as well. The above example was actually in T3D and the AI units used the standard soldier model (so fairly hefty) but the renderer was not the cause of the framerate problems in that case. Never the less, it's always wise to optimize to give your AI more "thinking room" so to speak.
#5
01/12/2013 (9:47 am)
"Just a note - on a relatively low-end machine"

what is the configuration?
#6
01/12/2013 (12:13 pm)
I'll have to check it when I get back in on Monday, but it's about 1/7th the power of my home game rig.

My game rig at home is a little outdated:
AMD Phenom II X6 1055T at stock 2.8 GHz, Win8 64bit, Radeon HD 6700 series with 2GB VRAM, 16GB system memory, assorted Western Digital hard drives (relatively slow). This nets a "Windows Experience Index" of 5.3 (processor and ram at 7.5, graphics and gaming graphics at 7.2 and primary hard disk at 5.3).

I haven't really done much testing of the AI scripts on this machine yet. In this thread I linked the github repo with my scripts in it - if you complete the RTS Prototype and then copy the scripts from that repo over that project you'll have the same thing I do at the moment and can test it at your leisure. I'd actually appreciate it if some people would go ahead and do that - I could use some feedback.
#7
01/14/2013 (11:56 am)
Ok, work rig is AMD Athlon 64 X2, Win7 64bit, NVidia GeForce 8600GT with 2GB VRAM, 4GB memory. Windows rates this machine at 4.9 because of the processor.

On this setup I can get about 100 units searching for targets every 200ms, but I only get about 1.2FPS. On my home setup I can get the same with about 17FPS.

On another note, Bryce's AI kit is probably a little more efficient than the tutorial I'm building.