AIManager
by Jeff Trier · in Torque Game Engine · 04/08/2004 (1:49 pm) · 9 replies
Hi all,
I was wondering what the thinking was behind AIManager. (no pun intended)
Is it supposed to centralize all bot instruction into one running function, or should each bot run it's own instance of the function? I am sure I can go either way with this, but I would like to stick with the original idea of this scriptObject for ease of future integration... plus I am new to AI and I want to do this the most efficient way. ;)
Thanks all!
-Jeff
I was wondering what the thinking was behind AIManager. (no pun intended)
Is it supposed to centralize all bot instruction into one running function, or should each bot run it's own instance of the function? I am sure I can go either way with this, but I would like to stick with the original idea of this scriptObject for ease of future integration... plus I am new to AI and I want to do this the most efficient way. ;)
Thanks all!
-Jeff
About the author
Originally a Classical/Metal musician, I've always been attracted to anything involving computers, including: Networking, PC Building and Repair, software design and coding. I've been involved with game design and development for over 10 years.
#2
What did you mean by "taken out AIManager into a separate file"? Do you mean that you made something like an "AIManager.cs" file which contains all the AIManager functions? Also, with your method, how many bots do you run at a time?
I would really like to know what was intended originally with AIManager. After reading a bit on Gamasutra, it seems that GG may be doing something similar to an article I read about having a function that manages when the other bots are supposed to think.
Hmmm...
-Jeff
04/09/2004 (10:32 am)
Thanks Thomas!What did you mean by "taken out AIManager into a separate file"? Do you mean that you made something like an "AIManager.cs" file which contains all the AIManager functions? Also, with your method, how many bots do you run at a time?
I would really like to know what was intended originally with AIManager. After reading a bit on Gamasutra, it seems that GG may be doing something similar to an article I read about having a function that manages when the other bots are supposed to think.
Hmmm...
-Jeff
#3
E.g.
In the MissionInfo part of the mission file I now can add a "treasureChest = 1;" and then the AIManager spawns a chest for me. THat way I can have different "bots" in different missions based on whats in the mission file.
04/10/2004 (12:39 am)
I moved it into a AIManager.cs file yes. Inside the think method I then do a lot of "if" statements.E.g.
// Shark
if (!isObject(%this.player))
{
if (MissionInfo.aiShark == 1) {
%this.player = %this.spawnBridgeShark();
}
}
if (MissionInfo.aiShark == 1) {
%this.player.scanForPlayer();
}
// Treasure chest
if (MissionInfo.treasureChest == 1) {
if (!isObject($treasurechest))
{
$treasurechest = %this.spawnChest();
}
}In the MissionInfo part of the mission file I now can add a "treasureChest = 1;" and then the AIManager spawns a chest for me. THat way I can have different "bots" in different missions based on whats in the mission file.
#4
07/07/2004 (10:08 am)
I think the term AIManager is a mis nomer it's just a label name it's not a manager unless you have management code in there. Change the name to foo() and it still works. So references to "the" AIManager are really wrong. This confused me alot. AIManager.think() is just a label to jump to to create a schedule event. But then again I might be completely wrong......
#5
07/07/2004 (10:35 am)
Nah, you're pretty much on track, Howard.
#6
MyBot::think()
{
do something...
}
MyOtherBot::think()
{
do something else...
}
for i = 1 to 10
{
bot[i] = new myBot;
bot[i].think();
}
07/07/2004 (6:10 pm)
And I've deleted AIManager. All my bots have their own think schecudule thread. MyBot::think()
{
do something...
}
MyOtherBot::think()
{
do something else...
}
for i = 1 to 10
{
bot[i] = new myBot;
bot[i].think();
}
#7
07/07/2004 (6:21 pm)
AIManager is a good idea and was a convient way to just call a simple wrapper to handle bots. Okay, it's not really "management" but it wouldn't take much to continue to build on an AIManager (separating it out into it's own file is a good start and have it load AI files). Just give it the smarts that a manager should have (keeping track of all the bots, making sure they have something to do, communicating with the player(s) and updating bot priorities). I'm sure with a few days of tweaking you can bring AIManager up to something more useful.
#8
Take a peek here : www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5939
By using this intelligently you can have lots more bots doing way more advanced AI with lesser overhead. Then you can turn the AIManager into a "real" manager. Like Bill says - make sure bots have somethign to do etc.
07/08/2004 (12:47 am)
And I would suggest taking a look at my resource with subscription based messaging if you want to remove the overhead of scheduled AITake a peek here : www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5939
By using this intelligently you can have lots more bots doing way more advanced AI with lesser overhead. Then you can turn the AIManager into a "real" manager. Like Bill says - make sure bots have somethign to do etc.
#9
I killed AIManager for a strange reason : It was killing my bots.
Sometimes bots would spawn, sometimes not, sometimes they would reach their path destinations, sometimes not.
I don't know why but AIManager seemed to be the cause of that. Maybe I didn't know then what I know today so it was only bad programming. But my game works better without it.
07/08/2004 (6:10 pm)
I'll give a look at that subscription manager.I killed AIManager for a strange reason : It was killing my bots.
Sometimes bots would spawn, sometimes not, sometimes they would reach their path destinations, sometimes not.
I don't know why but AIManager seemed to be the cause of that. Maybe I didn't know then what I know today so it was only bad programming. But my game works better without it.
Torque Owner Thomas \"Man of Ice\" Lund