zombies optimization question

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
arnir
Competition winner
Posts: 154
Joined: Sat Jan 20, 2007 4:36 pm
Location: Czech Republic

zombies optimization question

Post by arnir »

Hello, I am making an FPS zombie shooter with lots of enemies at time.
I have completed the game core, and now I am solving optimization problems of the game.
How can I get it run faster?

I have super-simply behavior for AI that use minimal of CPU. Its based on event-driven system that don't need runtime update.
For AI pathing I am using RVO library. Its little bit heavy on CPU usage, but I cannot make anything with it.
For AIs that are far from the player, I am skipping some effects( e.g die sounds & blood particles) but still if I have 30 enemies in the game at time, game is laggy...
I simply need this count of enemies with stable frames per second.

Do you have any ideas how to speed it up? feel free to say theoretical ideas.

e.g. if I set animation speed 0 for zombies that are far from the camera, can I have some CPU usage save? or it will be normally animating by zero speed?
programmer is bad designer
designer is bad programmer
HerrAlmanack
Posts: 52
Joined: Mon Jun 13, 2011 3:50 pm

Re: zombies optimization question

Post by HerrAlmanack »

I am not sure how your framework works internally, but the way I designed a framework I am using right now is by having game object buffers. most everything in the game is derived from IGameObject, game objects have things like status ( sleeping, active ), and execute logic priorities( I use a 0-5 scale, 0 being highest priority ). so then what I do is derive things like IPhysicsManager, IEntityManager, and IItemManager. IGameObjectBuffer works by getting allotted a certain amount of game objects it can "logic tik". for example, if a game object buffer has 500 objects it needs to tik, then it might give 250 tiks to priority 0, 125 to priority 1, etc. etc. also, are you "tikking" every object every *while* loop around? or are you aiming for a certain logic frames per second?

I use a dynamic throttling system in my framework. for the first few frames or so, the main game world class sets a certain frame rate (e.g. 32 ) and then measures the time taken to complete one logic frame. in my system I measure one logic frame as the time it takes for a game object buffer to do a "turn over", which is when all game objects have had their main logic tik() method called. then the game world does some simple math and from then on will allot tiks in the appropriate amount to complete logic frames at the desired rate.


I hope these ideas help. they are tested and work great for me.

I think the most likely problem is maybe you are trying to execute your logic every single while loop?

EDIT:

my game object class tik() method takes a delta time as a parameter. whenever you have game objects that you don't call a "tik()" method, you should call a "skip()" with the delta time, so they have that correctly accumulated delta time.
arnir
Competition winner
Posts: 154
Joined: Sat Jan 20, 2007 4:36 pm
Location: Czech Republic

Re: zombies optimization question

Post by arnir »

good idea with object status!

AI logic is quite simple:
AI is trying to get near to player and attack him.

most of life-time is AI moving somewhere, so I deduce I need tick() every single while loop...
But how I think about it, I can split my AI::update() function to e.g. preUpdate, Update etc
RVO library do pathing so I can skip it while AI is not moving-attacking player.
while AI is attacking player, I don't need e.g. check the distance to the player(to decide if AI can begin attack), I can wait for attack end etc
ok ok, if I fix the AI logic, is any way how can I speed up the drawing of enemies?
programmer is bad designer
designer is bad programmer
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: zombies optimization question

Post by Radikalizm »

I'm sorry, but without knowing how your system actually works in detail we won't be able to tell you how to optimize it, a general description of your project is not enough
Optimization should be done by profiling, profile you code and see where the bottlenecks are; look for the situations which require the most of your hardware and check where you can improve those to achieve better results
Optimization is an artform in itself when you look at it, and a good system for profiling and testing your code is the key for getting it right
HerrAlmanack
Posts: 52
Joined: Mon Jun 13, 2011 3:50 pm

Re: zombies optimization question

Post by HerrAlmanack »

oh yeah I forgot to say something, and it goes with rads post. if you want to start profiling your engine/framework (which is probably a very good idea) then I suggest using bullet physics quickprof. I just love that library. It comes handy with so many things needed to make a proper game. like the game clock, the profiling and lots of other goodies. combine that with irrlicht and making games is pretty fun and relatively easy, if you are organized, anyways, I ramble. so what you want to do is download the bullet source, then compile solo the LinearMath module of bullet. that will contain the "btQuickProf" statics needed to start profiling your system. the documentation doesn't have many "official" tuts afaik, but the source is pretty straightforward and the comments should point you in the right direction. :D good luck in optimizing!

coincidentally I just started an optimizing session today, as well. I created some custom dynamics response for some of my game elements, I don't want full rigid body dynamics for some "dropped items" but I want them to fall with simple gravity, but not get kicked around everywhere. so I was just going to start to optimize those today. another tip: don't start optimizing too early. if you do that just creates a whole 'other branch of possible problems. only optimize AFTER you know what your system does, because optimizing, like radikalizm said, is an art, and can screw you over if you aren't careful.
Post Reply