[Orxonox-commit 5993] r10652 - code/branches/AI_HS15/src/orxonox/controllers
gania at orxonox.net
gania at orxonox.net
Fri Oct 16 15:25:18 CEST 2015
Author: gania
Date: 2015-10-16 15:25:17 +0200 (Fri, 16 Oct 2015)
New Revision: 10652
Modified:
code/branches/AI_HS15/src/orxonox/controllers/AIController.cc
code/branches/AI_HS15/src/orxonox/controllers/ArtificialController.h
code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc
Log:
deleted old behaviour of AIController (partly), forced ships to form a formation, TODO: make tactics for different formation modes, choose one depending on what's better.
Modified: code/branches/AI_HS15/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/AIController.cc 2015-10-13 16:11:01 UTC (rev 10651)
+++ code/branches/AI_HS15/src/orxonox/controllers/AIController.cc 2015-10-16 13:25:17 UTC (rev 10652)
@@ -60,20 +60,27 @@
if (this->formationFlight_)
{
+ //When this is a master and was destroyed, destructor might complain that there are slaves of this, although this was removed from formation
+ //race conditions?
+ //destructor takes care of slaves anyway, so no need to worry about internal_error
+
//changed order -> searchNewMaster MUSTN'T be called in SLAVE-state (bugfix for internal-error messages at quit)
random = rnd(maxrand);
if (random < 90 && (((!this->target_) || (random < 50 && this->target_)) && !this->forcedFree()))
this->searchNewMaster();
// return to Master after being forced free
- if (this->freedomCount_ == 1)
+ if (this->freedomCount_ == ACTION_INTERVAL)
{
this->state_ = SLAVE;
- this->freedomCount_ = 0;
+ this->freedomCount_ = 0; // ACTION_INTERVAL is 1 sec, freedomCount is a remaining time of temp. freedom
}
+ } else{
+ //form a formation
+ if (!this->forcedFree())
+ this->searchNewMaster();
}
-
this->defaultBehaviour(maxrand);
}
@@ -81,29 +88,25 @@
if (this->state_ == SLAVE && this->formationMode_ == ATTACK)
{
// search enemy
- random = rnd(maxrand);
- if (random < (botlevel_*100) && (!this->target_))
+ if ((!this->target_))
this->searchNewTarget();
- // next enemy
- random = rnd(maxrand);
- if (random < (botlevel_*30) && (this->target_))
- this->searchNewTarget();
-
+
// shoot
- random = rnd(maxrand);
- if (!(this->passive_) && random < (botlevel_*100) && (this->target_ && !this->bShooting_))
+ if ((this->target_ && !this->bShooting_))
this->bShooting_ = true;
// stop shooting
- random = rnd(maxrand);
- if (random < (1-botlevel_)*50 && (this->bShooting_))
+ if (this->bShooting_ && !this->target_)
this->bShooting_ = false;
}
if (this->state_ == MASTER)
{
+
+ this->setFormationMode(ATTACK);
+
this->commandSlaves();
if (this->specificMasterAction_ != NONE)
@@ -126,11 +129,13 @@
if (random < 1)
this->followRandomHumanInit();
*/
+ /*
// lose master status (only if less than 4 slaves in formation)
random = rnd(maxrand);
if(random < 15/(this->slaves_.size()+1) && this->slaves_.size() < 4 )
this->loseMasterState();
-
+ */
+
// look out for outher masters if formation is small
random = rnd(maxrand);
if(this->slaves_.size() < 3 && random < 20)
@@ -148,7 +153,6 @@
if (!this->isActive())
return;
-
float random;
float maxrand = 100.0f / ACTION_INTERVAL;
ControllableEntity* controllable = this->getControllableEntity();
@@ -188,9 +192,7 @@
else
{
this->aimAtTarget();
- random = rnd(maxrand);
- if(this->botlevel_*70 > random && !this->isCloseAtTarget(100))
- this->follow(); //If a bot is shooting a player, it shouldn't let him go away easily.
+ this->follow(); //If a bot is shooting a player, it shouldn't let him go away easily.
}
}
@@ -251,85 +253,17 @@
this->setPreviousMode();//If bot dies -> getControllableEntity == NULL -> get out of ROCKET mode
}//END_OF ROCKET MODE
+
SUPER(AIController, tick, dt);
}
//**********************************************NEW
void AIController::defaultBehaviour(float maxrand)
- {
- if (!this->target_)
- this->searchNewTarget();
- if (!(this->passive_) && (this->target_ && !this->bShooting_))
- this->bShooting_ = true;
- /*
- float random;
- // search enemy
- random = rnd(maxrand);
- if (random < (botlevel_* 100) && (!this->target_))
- this->searchNewTarget();
-
- // forget enemy
- random = rnd(maxrand);
- if (random < ((1-botlevel_)*20) && (this->target_))
- this->forgetTarget();
-
- // next enemy
- random = rnd(maxrand);
- if (random < (botlevel_*30) && (this->target_))
- this->searchNewTarget();
-
- // fly somewhere
- random = rnd(maxrand);
- if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
- this->searchRandomTargetPosition();
-
- // stop flying
- random = rnd(maxrand);
- if (random < 10 && (this->bHasTargetPosition_ && !this->target_))
- this->bHasTargetPosition_ = false;
-
- // fly somewhere else
- random = rnd(maxrand);
- if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
- this->searchRandomTargetPosition();
-
- if (this->state_ == MASTER) // master: shoot
- {
- random = rnd(maxrand);
- if (!(this->passive_) && random < (100*botlevel_) && (this->target_ && !this->bShooting_))
- {
- this->bShooting_ = true;
- this->forceFreeSlaves();
- }
- }
- else
- {
- // shoot
- random = rnd(maxrand);
- if (!(this->passive_) && random < (botlevel_*100) && (this->target_ && !this->bShooting_))
- this->bShooting_ = true;
- }
-
- // stop shooting
- random = rnd(maxrand);
- if (random < ((1 - botlevel_)*50) && (this->bShooting_))
- this->bShooting_ = false;
-
- // boost
- random = rnd(maxrand);
- if (random < botlevel_*50 )
- this->boostControl();
- */
-
+ {
+ if (!this->target_)
+ this->searchNewTarget();
+ if (!(this->passive_) && (this->target_ && !this->bShooting_))
+ this->bShooting_ = true;
- // update Checkpoints
- /*random = rnd(maxrand);
- if (this->defaultWaypoint_ && random > (maxrand-10))
- this->manageWaypoints();
- else //if(random > maxrand-10) //CHECK USABILITY!!*/
- if (this->waypoints_.size() == 0 )
- this->manageWaypoints();
-
-
}
}
Modified: code/branches/AI_HS15/src/orxonox/controllers/ArtificialController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/ArtificialController.h 2015-10-13 16:11:01 UTC (rev 10651)
+++ code/branches/AI_HS15/src/orxonox/controllers/ArtificialController.h 2015-10-16 13:25:17 UTC (rev 10652)
@@ -52,7 +52,7 @@
inline float getBotLevel() const
{ return this->botlevel_; }
static void setAllBotLevel(float level);
- //WAYPOINT FUNCTIONS
+ //WAYPOINT FUNCTIONS`
void addWaypoint(WorldEntity* waypoint);
WorldEntity* getWaypoint(unsigned int index) const;
Modified: code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc 2015-10-13 16:11:01 UTC (rev 10651)
+++ code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc 2015-10-16 13:25:17 UTC (rev 10652)
@@ -104,6 +104,7 @@
{
orxout(internal_error) << this << " is still master in " << (*it) << endl;
it->myMaster_ = 0;
+ it->state_ = FREE;
}
while (true)
@@ -471,7 +472,7 @@
Quaternion orient = this->getControllableEntity()->getOrientation();
Vector3 dest = this->getControllableEntity()->getPosition();
- // 1 slave: follow
+ // only 1 slave: follow
if (this->slaves_.size() == 1)
{
dest += 4*orient*WorldEntity::BACK;
More information about the Orxonox-commit
mailing list