Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How process AI without slow down too much framerate

Author
Message
Hell_666
16
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 29th Jul 2012 20:57
Hi, I'm working on a multiplayer game and I need to have many AI.
I'm beginer in AI system, so my code is not optimised.
My problem happen when I play AI animations, it slows down a lot my framerate.

Can you give me somes advices to process AI without wasting frame rate please ?

Thanks a lot


Sub-routine called every loops :


IA animation function


Eternal suffering ...

I'm french
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 29th Jul 2012 22:54
i never used AI, but i do understand that you must make a path out of it writen into some kind of array, so he will follow that path. those mathematics should be done in 1 frame, then everything else is just following the path that already been made.

thats the way i think its the best for not slowing down the frame rate

Advanced Updater for your games!
Hell_666
16
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 29th Jul 2012 23:08
Sorry, but I don't understand what is this path

Eternal suffering ...

I'm french
Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 30th Jul 2012 06:36 Edited at: 30th Jul 2012 06:49
@sergey, i don't think he's doing any pathfinding here but general AI and setting animations per one of 3 actions.

@hell_666: try loop object vs play object (especially for the walk and sprint animations). as it stands now, you only play the animation once and then have to restart it even if the animation is the same as the last one.

this is going to require tracking of the last animation played so if the AI changes actions, the function will know to loop the next/new set of animation frames. if it's the same action as before, you don't need to do anything with the animation as it will continue to loop on its own.

also, you said "multiplayer". is this online?

and, how many AI entities are we talking about, here? you said "many" which could be dozens to hundreds+.

either way, you should consider updating AI for 1 group at a time (per loop) vs ALL AI entities EVERY loop.

ie, let's say you have 100 enemies running around... fact is, they really don't need to be checked on every single loop/iteration, if you're careful (without knowing more about your game, i can't really suggest anything to watch for but considerations should be made, regardless).

if, instead, you process AI 1-10 in one iteration, then 11-20 in the next loop, etc, until all 100 are looked at (10 loops total), you cut the "work load" by 90% each loop. then you just restart the checks on 1-10, and so on.

finally, what kinda of performance/frame rate do you get if NO animations are playing or being set vs the FPS you're getting with the way you're doing things now?

Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Hell_666
16
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 30th Jul 2012 22:52
Quote: "
also, you said "multiplayer". is this online?
"


Yes, I use multisync.


Quote: "
and, how many AI entities are we talking about, here? you said "many" which could be dozens to hundreds+.
"


I mean hundreds+, that's why I really need to improve AI performances.

Quote: "
finally, what kinda of performance/frame rate do you get if NO animations are playing or being set vs the FPS you're getting with the way you're doing things now?
"


If I don't call the function my frame rate is 60 fps (I set my timer base movement at 60 fps). If I call the function I have around 30~40 fps with 10 AI in screen.


Thanks for this advices, I will do it and continue to search how I can optimise my code.

Eternal suffering ...

I'm french
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 30th Jul 2012 23:06
Calling AnimID AI is very confusing.

Hell_666
16
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 30th Jul 2012 23:09 Edited at: 30th Jul 2012 23:37
What is confusing ?

EDIT : I've instanced objects at the AI model loading, and it runs at 50 fps with 10 AI.

Eternal suffering ...

I'm french
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 30th Jul 2012 23:49
Because AI is Artificial Intelligence, and as far as I can tell you are just using animation frames.

Hell_666
16
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 30th Jul 2012 23:52
I don't mean Animations ID but Artificial Intelligence. The AI source code is on my server source, here is the client side, so we just have the render.
Sorry, I would must say it on my first post

Eternal suffering ...

I'm french
Hell_666
16
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 31st Jul 2012 23:15
I can't use instance object because all instanced objects have the same frame that the source object

Eternal suffering ...

I'm french

Login to post a reply

Server time is: 2026-07-07 12:26:32
Your offset time is: 2026-07-07 12:26:32