Architecture of AI Connection
by Colossai Studios · in RTS Starter Kit · 05/06/2005 (7:16 am) · 11 replies
I'm adding an AI to the RTS addon.
What I want to do is to create an AI client that can connects to the server much like the player client, meaning function
RTSConnection::onClientEnterGame(%this)
in gameconnection.cs will be called
and also that the AI client can be accessed by using
%client = ClientGroup.getObject(%i);
Can I do this from script, or do I have to do it from the engine?
What I want to do is to create an AI client that can connects to the server much like the player client, meaning function
RTSConnection::onClientEnterGame(%this)
in gameconnection.cs will be called
and also that the AI client can be accessed by using
%client = ClientGroup.getObject(%i);
Can I do this from script, or do I have to do it from the engine?
About the author
#2
I've been trying for a while to find the best way to add AI. I just want simple AI Units that use the stock RTSUnit actions (set target object, set target location, attack, etc...)
my question is; to make AI units that use those basic actions, should i make a AIConnection type object? or just start spawning them in the mission area?
note: (I did try just spawning a rtsunit and it does what i need it to BUT when the player's units attack it the game crashes. Im wondering if it is because the AI units dont belong to a particular client.)
i appreciate any help...
05/11/2005 (4:58 pm)
This question runs along the same lines of mine so ill post it here...I've been trying for a while to find the best way to add AI. I just want simple AI Units that use the stock RTSUnit actions (set target object, set target location, attack, etc...)
my question is; to make AI units that use those basic actions, should i make a AIConnection type object? or just start spawning them in the mission area?
note: (I did try just spawning a rtsunit and it does what i need it to BUT when the player's units attack it the game crashes. Im wondering if it is because the AI units dont belong to a particular client.)
i appreciate any help...
#3
05/12/2005 (5:05 am)
Well, after doing some research on the subject, I basically use ClientGroup just for human players, and an AIGroup for AI players. I also created a new class for AI players that's based on the RTSConnection (for now at least). Every player get a teamnumber, so when I spawn units I just give the units the teamnumber they should belong to.
#4
05/12/2005 (9:00 am)
Would be nice to see a resource on that. im sure there are a few others that would also want it.
#5
The new AIClient is based on RTSConnection like this
In aiClient.cc I've written a function for adding an AI player: (not finished but works)
So now you can write "addAI" in the console or script and an AI will be created.
Now you can access the AIplayer from the script just like the human players
I might make a resource later when I feel more comfortable with the code and have cleaned it up. Good suggestion.
05/12/2005 (10:38 am)
Well, to create a new named group, you'll have to add it in three different places in the engine. Just search in solution for ClientGroup and you'll see exactly where.ImplementNamedGroup(AIGroup) - simBase.cc DeclareNamedGroup(AIGroup) - simBase.h InstantiateNamedGroup(AIGroup); - simManager.cc
The new AIClient is based on RTSConnection like this
class AIClient : public RTSConnection
{
typedef RTSConnection Parent;
}In aiClient.cc I've written a function for adding an AI player: (not finished but works)
ConsoleFunction( addAI, S32 , 2, 3, "addAI( 'playerName'[, 'AIClassType'] );" )
{
// Create the player
AIClient *aiPlayer = new AIClient();
aiPlayer->registerObject();
aiPlayer->setGhostFrom(false);
aiPlayer->setGhostTo(false);
aiPlayer->setSendingEvents(false);
aiPlayer->setTranslatesStrings(true);
aiPlayer->setEstablished();
// Add the client to the AI group
SimGroup *g = Sim::getAIGroup();
g->addObject( aiPlayer );
return aiPlayer->getId();
}So now you can write "addAI" in the console or script and an AI will be created.
Now you can access the AIplayer from the script just like the human players
for (%i=0; %i<AI.getCount(); %i++)
{
%aiClient = AIGroup.getObject(%i);
%aiClient.doWhatever();
}I might make a resource later when I feel more comfortable with the code and have cleaned it up. Good suggestion.
#6
Would you be willing to share the complete code? This would help me out enormously! and I hope more of us too :) - let me know!
cheers!
08/15/2005 (9:49 am)
Hi,Would you be willing to share the complete code? This would help me out enormously! and I hope more of us too :) - let me know!
cheers!
#8
03/13/2007 (9:56 pm)
@Gurpreet - the previous post to yours is over a year and a half old. Might be best to start a new thread - this is something I am interested in too eventually - I'm no where near the point of computer AI yet however. :P
#9
03/14/2007 (11:46 pm)
If I recall, this is the complete code.
#10
Email:moj.heidari@yahoo.com
11/13/2012 (2:13 pm)
I need RTS Toolkit and FGE(Flight Game Example).Also I need Aiflyingvehicle Class.pls send me any one can do.Email:moj.heidari@yahoo.com
#11
11/13/2012 (5:14 pm)
Um they can't send you paid for code mojtaba
Torque 3D Owner Stephen Zepp
The main problem here is that AIPlayer itself was not part of the RTS-SK release, so any AI work that you do will have to be an experimental port of either the old AIConnection class, or the AIPlayer class.
Since AI is really so fundamentally driven based on your game itself, it might make sense for you to start at the design level, describe the functionality that you want your RTS AI to have (are we talking single unit, squad level, "player" level, etc...and what capabilities do they need to have implemented), and then you can break out the functionality to determine the most appropriate way to implement.