Adding Flocking & Herding to Bot AI
by James Daniel · 03/18/2005 (9:49 am) · 24 comments
Herding is an advanced form of flocking that allows a group of bots to emulate the movement of a herd. In addition to the classic rules of flocking (Cohesion, Alignment, Separation), two new rules are added for Station Keeping and Drifting.
To add Herding to the AIPlayer class, the PlayerData datablock used to create the Bots to be herded need to have the following items added: minSeparation, maxSeparation, sightRange, and viewField. These four data items need to be added to the Shapebase code (Shapebase.cc and Shapebase.h).
Open the ShapeBase.h header file and search down to the ShapeBaseData structure and just after the entry for
To add Herding to the AIPlayer class, the PlayerData datablock used to create the Bots to be herded need to have the following items added: minSeparation, maxSeparation, sightRange, and viewField. These four data items need to be added to the Shapebase code (Shapebase.cc and Shapebase.h).
Open the ShapeBase.h header file and search down to the ShapeBaseData structure and just after the entry for
#2
02/25/2005 (6:57 am)
Sorry about the way the code looks. I'm still new at this and don't real know how to make the code easier to read.
#3
like
"[code ]" to start it and "[/code ]" to end it... I put a space in the end so you could see the tag, take the space out when you add yours
btw seems like a very cool resource, hopefully tonight or tomorrow I can test it :)
02/25/2005 (8:07 am)
use code blocks....like
"[code ]" to start it and "[/code ]" to end it... I put a space in the end so you could see the tag, take the space out when you add yours
btw seems like a very cool resource, hopefully tonight or tomorrow I can test it :)
#4
GG should consider adding this to the base code, as it could be very effective in many types of games. And currently the state of NPC AI is. pretty bad.
02/25/2005 (10:29 pm)
Kudos, and thanks for a very well written resource.GG should consider adding this to the base code, as it could be very effective in many types of games. And currently the state of NPC AI is. pretty bad.
#5
While editing aiplayer.h
You said "Next search down to the entry for 'processTick' and before it enter the following:..."
There is no processTick in aiplayer.h nor is there one in aiplayer.cc
Help please?
02/25/2005 (11:24 pm)
Found an error...While editing aiplayer.h
You said "Next search down to the entry for 'processTick' and before it enter the following:..."
There is no processTick in aiplayer.h nor is there one in aiplayer.cc
Help please?
#6
02/25/2005 (11:35 pm)
Just curious but what code base are you building from? There seems to be quite a few entries you appear to be expecting, in various files, which just aren't there.
#7
Our base code is Version 1.1.2
We also have two other resources used
1) aiPlayer extensions - Stefan Beffy Moises
2) aiSpawnAIPlayer - J. Donavan Stanley
Hope that helps.
02/26/2005 (10:23 am)
Boy is my face red.Our base code is Version 1.1.2
We also have two other resources used
1) aiPlayer extensions - Stefan Beffy Moises
2) aiSpawnAIPlayer - J. Donavan Stanley
Hope that helps.
#8
02/26/2005 (10:40 am)
1.1.2? Wow thats some old code, I at first thought it was the latest from the installer, umm 1.3.4 then I thought it might be from the RTS code base, which I have no idea what version that is in. But 1.1.2? Wow, I'll try to find it.
#9
Then I followed the tutorial as best as I could, however there were still some missing bits, so I kind of had to guess as to where things went sometimes.
I'm getting ALOT of compile time errors
game/aiPlayer.cc: In member function `virtual bool AIPlayer::getAIMove(Move*)':
game/aiPlayer.cc:188: error: `datablock' undeclared (first use this function)
game/aiPlayer.cc:188: error: (Each undeclared identifier is reported only once
for each function it appears in.)
game/aiPlayer.cc:201: error: `Bot' undeclared (first use this function)
game/aiPlayer.cc: In member function `VectorF AIPlayer::VRotate2D(Point3F)':
game/aiPlayer.cc:380: error: `MathUtils' undeclared (first use this function)
game/aiPlayer.cc:380: error: parse error before `::' token
game/aiPlayer.cc: In function `S32 cAIPlayergetAimObject(AIPlayer*, int, const
char**)':
game/aiPlayer.cc:510: warning: converting of negative value `-1' to `unsigned
int'
game/aiPlayer.cc: In member function `S32 AIPlayer::getTargetDistance() const':
game/aiPlayer.cc:571: warning: converting to `int' from `float'
game/aiPlayer.cc: In member function `void AIPlayer::doFlocking()':
game/aiPlayer.cc:798: error: parse error before `*' token
game/aiPlayer.cc:843: error: no matching function for call to `AIPlayer::
setMoveDestination(Point3F, bool)'
game/aiPlayer.cc:96: error: candidates are: void
AIPlayer::setMoveDestination(const Point3F&)
game/aiPlayer.cc:847: error: no matching function for call to `AIPlayer::
setMoveDestination(Point3F, bool)'
game/aiPlayer.cc:96: error: candidates are: void
AIPlayer::setMoveDestination(const Point3F&)
game/aiPlayer.cc:871: error: `PI' undeclared (first use this function)
game/aiPlayer.cc:889: error: `getActiveThreadSequenceID' undeclared (first use
this function)
game/aiPlayer.cc:902: error: no matching function for call to `AIPlayer::
setMoveDestination(VectorF&, bool)'
game/aiPlayer.cc:96: error: candidates are: void
AIPlayer::setMoveDestination(const Point3F&)
game/aiPlayer.cc: In member function `void AIPlayer::doDrift()':
game/aiPlayer.cc:924: error: 'class AIPlayer' has no member named 'getDataB'
game/aiPlayer.cc:924: error: parse error before `(' token
game/aiPlayer.cc:928: error: `getActiveThreadSequenceID' undeclared (first use
this function)
game/aiPlayer.cc:932: error: parse error before `>' token
game/aiPlayer.cc:941: error: no matching function for call to `AIPlayer::
setMoveDestination(VectorF&, bool)'
game/aiPlayer.cc:96: error: candidates are: void
AIPlayer::setMoveDestination(const Point3F&)
game/aiPlayer.cc: In member function `AIPlayer* AIPlayer::FindNearestLeader()':
game/aiPlayer.cc:972: error: parse error before `*' token
game/aiPlayer.cc: In member function `bool AIPlayer::checkLOS(Player*, Player*)
':
game/aiPlayer.cc:1004: error: `StaticShap' undeclared (first use this function)
game/aiPlayer.cc:1004: error: parse error before `|' token
game/aiPlayer.cc:1012: error: `n' undeclared (first use this function)
game/aiPlayer.cc:1012: error: parse error before `return'
game/aiPlayer.cc:1030: error: `ottom' undeclared (first use this function)
game/aiPlayer.cc:1030: error: parse error before `the'
game/aiPlayer.cc:1040: error: `RayE' undeclared (first use this function)
game/aiPlayer.cc:1040: error: parse error before `)' token
game/aiPlayer.cc: At global scope:
game/aiPlayer.cc:1047: error: parse error before `}' token
game/aiPlayer.cc:1048: error: ISO C++ forbids declaration of `enableCollision'
with no type
game/aiPlayer.cc:1050: error: parse error before `if'
game/aiPlayer.cc:1053: error: syntax error before `.' token
game/aiPlayer.cc:1054: error: `objVector' was not declared in this scope
game/aiPlayer.cc:1054: error: `eyeVector' was not declared in this scope
game/aiPlayer.cc:1056: error: parse error before `if'
game/aiPlayer.cc: In member function `S32 AIPlayer::getDistance(SimObject*,
SimObject*) const':
game/aiPlayer.cc:1109: warning: converting to `int' from `float'
Can anyone maybe get this resource going on 1.3 please?
02/26/2005 (7:56 pm)
Well I took the latest release 1.3.0 and added the aiPlayer extensions and aiSpawnAIPlayer patches.Then I followed the tutorial as best as I could, however there were still some missing bits, so I kind of had to guess as to where things went sometimes.
I'm getting ALOT of compile time errors
game/aiPlayer.cc: In member function `virtual bool AIPlayer::getAIMove(Move*)':
game/aiPlayer.cc:188: error: `datablock' undeclared (first use this function)
game/aiPlayer.cc:188: error: (Each undeclared identifier is reported only once
for each function it appears in.)
game/aiPlayer.cc:201: error: `Bot' undeclared (first use this function)
game/aiPlayer.cc: In member function `VectorF AIPlayer::VRotate2D(Point3F)':
game/aiPlayer.cc:380: error: `MathUtils' undeclared (first use this function)
game/aiPlayer.cc:380: error: parse error before `::' token
game/aiPlayer.cc: In function `S32 cAIPlayergetAimObject(AIPlayer*, int, const
char**)':
game/aiPlayer.cc:510: warning: converting of negative value `-1' to `unsigned
int'
game/aiPlayer.cc: In member function `S32 AIPlayer::getTargetDistance() const':
game/aiPlayer.cc:571: warning: converting to `int' from `float'
game/aiPlayer.cc: In member function `void AIPlayer::doFlocking()':
game/aiPlayer.cc:798: error: parse error before `*' token
game/aiPlayer.cc:843: error: no matching function for call to `AIPlayer::
setMoveDestination(Point3F, bool)'
game/aiPlayer.cc:96: error: candidates are: void
AIPlayer::setMoveDestination(const Point3F&)
game/aiPlayer.cc:847: error: no matching function for call to `AIPlayer::
setMoveDestination(Point3F, bool)'
game/aiPlayer.cc:96: error: candidates are: void
AIPlayer::setMoveDestination(const Point3F&)
game/aiPlayer.cc:871: error: `PI' undeclared (first use this function)
game/aiPlayer.cc:889: error: `getActiveThreadSequenceID' undeclared (first use
this function)
game/aiPlayer.cc:902: error: no matching function for call to `AIPlayer::
setMoveDestination(VectorF&, bool)'
game/aiPlayer.cc:96: error: candidates are: void
AIPlayer::setMoveDestination(const Point3F&)
game/aiPlayer.cc: In member function `void AIPlayer::doDrift()':
game/aiPlayer.cc:924: error: 'class AIPlayer' has no member named 'getDataB'
game/aiPlayer.cc:924: error: parse error before `(' token
game/aiPlayer.cc:928: error: `getActiveThreadSequenceID' undeclared (first use
this function)
game/aiPlayer.cc:932: error: parse error before `>' token
game/aiPlayer.cc:941: error: no matching function for call to `AIPlayer::
setMoveDestination(VectorF&, bool)'
game/aiPlayer.cc:96: error: candidates are: void
AIPlayer::setMoveDestination(const Point3F&)
game/aiPlayer.cc: In member function `AIPlayer* AIPlayer::FindNearestLeader()':
game/aiPlayer.cc:972: error: parse error before `*' token
game/aiPlayer.cc: In member function `bool AIPlayer::checkLOS(Player*, Player*)
':
game/aiPlayer.cc:1004: error: `StaticShap' undeclared (first use this function)
game/aiPlayer.cc:1004: error: parse error before `|' token
game/aiPlayer.cc:1012: error: `n' undeclared (first use this function)
game/aiPlayer.cc:1012: error: parse error before `return'
game/aiPlayer.cc:1030: error: `ottom' undeclared (first use this function)
game/aiPlayer.cc:1030: error: parse error before `the'
game/aiPlayer.cc:1040: error: `RayE' undeclared (first use this function)
game/aiPlayer.cc:1040: error: parse error before `)' token
game/aiPlayer.cc: At global scope:
game/aiPlayer.cc:1047: error: parse error before `}' token
game/aiPlayer.cc:1048: error: ISO C++ forbids declaration of `enableCollision'
with no type
game/aiPlayer.cc:1050: error: parse error before `if'
game/aiPlayer.cc:1053: error: syntax error before `.' token
game/aiPlayer.cc:1054: error: `objVector' was not declared in this scope
game/aiPlayer.cc:1054: error: `eyeVector' was not declared in this scope
game/aiPlayer.cc:1056: error: parse error before `if'
game/aiPlayer.cc: In member function `S32 AIPlayer::getDistance(SimObject*,
SimObject*) const':
game/aiPlayer.cc:1109: warning: converting to `int' from `float'
Can anyone maybe get this resource going on 1.3 please?
#10
02/28/2005 (3:52 pm)
I just upgraded to version 1.3.0 with no problem. If you like to talk to me direct just drop me an email at jsdaniel@bellicode.com
#11
04/01/2005 (1:55 pm)
Thanks for posting this.
#12
In both the methods doFlocking and doDrift, there is a call like this:
I suppose from the posts above that Dreamer and James Daniel sorted that problem out privatly by mail without telling us other poor people about it ;)
09/07/2005 (10:00 am)
This is potentially awsome, and I'v egot it all in with only one remaining exception:In both the methods doFlocking and doDrift, there is a call like this:
NearestLeader->getActiveThreadSequenceID(0);...and there is no method even remotely close to that.
I suppose from the posts above that Dreamer and James Daniel sorted that problem out privatly by mail without telling us other poor people about it ;)
#13
09/09/2005 (12:48 pm)
You should find the 'getActiveThreadSequenceID' in the 'ShapeBase' class which is in the ShapeBase.cc file. It is just after the 'pauseThread' method in my version of the engine code.
#14
02/15/2006 (6:17 am)
What about this to vehicles? Is it possible to use with AIWheeledVehicle of TGE 1.4?
#15
05/02/2006 (1:21 am)
This resource seem to have been cut of. Anyone has it? Then please send me an email at "endasil at hotmail dot com"
#16
02/11/2007 (10:48 am)
Does anyone have this resource sitting around ? Would love to have a look at it ...
#17
02/11/2007 (11:07 am)
I'd love to see the code for this too!
#18
what do we do and what follows next is not been shown here
thus i request you to once again upload it so that new peoples like me can use it
thanks
04/18/2007 (7:16 am)
hey this post seems to be having some problem 'coz i do not get to see anything after the line "Open the ShapeBase.h header file and search down to the ShapeBaseData structure and just after the entry for ...."what do we do and what follows next is not been shown here
thus i request you to once again upload it so that new peoples like me can use it
thanks
#19
04/18/2007 (11:37 am)
Thanks for the heads up Ryan. If nothing is done by GG I'll see about updating everything RSN.
#20
05/24/2007 (2:34 pm)
James, that would be great. I would like to get this working also. 
Torque Owner Robert Pierce
I'll put this in tommorrow during the weekend, yay.