[Orxonox-commit 3149] r7842 - code/branches/ai/src/orxonox/controllers
jo at orxonox.net
jo at orxonox.net
Mon Jan 31 23:36:18 CET 2011
Author: jo
Date: 2011-01-31 23:36:18 +0100 (Mon, 31 Jan 2011)
New Revision: 7842
Modified:
code/branches/ai/src/orxonox/controllers/AIController.cc
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
code/branches/ai/src/orxonox/controllers/ArtificialController.h
Log:
Console command still doesn't seem to work. botLevel_ is now defined between 0.0f and 1.0f
Modified: code/branches/ai/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/AIController.cc 2011-01-31 20:33:18 UTC (rev 7841)
+++ code/branches/ai/src/orxonox/controllers/AIController.cc 2011-01-31 22:36:18 UTC (rev 7842)
@@ -75,17 +75,17 @@
// search enemy
random = rnd(maxrand);
- if (random < (15 + botlevel_* 2) && (!this->target_))
+ if (random < (15 + botlevel_* 20) && (!this->target_))
this->searchNewTarget();
// forget enemy
random = rnd(maxrand);
- if (random < (5/botlevel_) && (this->target_))
+ if (random < ((1-botlevel_)*5) && (this->target_))
this->forgetTarget();
// next enemy
random = rnd(maxrand);
- if (random < (10 + botlevel_) && (this->target_))
+ if (random < ((1+ botlevel_)*10) && (this->target_))
this->searchNewTarget();
// fly somewhere
@@ -105,12 +105,12 @@
// shoot
random = rnd(maxrand);
- if (!(this->passive_) && random < (75 + botlevel_*3) && (this->target_ && !this->bShooting_))
+ if (!(this->passive_) && random < (75 + botlevel_*25) && (this->target_ && !this->bShooting_))
this->bShooting_ = true;
// stop shooting
random = rnd(maxrand);
- if (random < (25 - botlevel_*2 ) && (this->bShooting_))
+ if (random < ((1 - botlevel_)*25) && (this->bShooting_))
this->bShooting_ = false;
}
@@ -191,7 +191,7 @@
// stop shooting
random = rnd(maxrand);
- if (random < (25 - botlevel_*2 ) && (this->bShooting_))
+ if (random < ( (1- botlevel_)*25 ) && (this->bShooting_))
this->bShooting_ = false;
}
Modified: code/branches/ai/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.cc 2011-01-31 20:33:18 UTC (rev 7841)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.cc 2011-01-31 22:36:18 UTC (rev 7842)
@@ -51,7 +51,7 @@
SetConsoleCommand("ArtificialController", "followme", &ArtificialController::followme);
SetConsoleCommand("ArtificialController", "passivebehaviour", &ArtificialController::passivebehaviour);
SetConsoleCommand("ArtificialController", "formationsize", &ArtificialController::formationsize);
- SetConsoleCommand("ArtificialController", "botlevel", &ArtificialController::setBotLevel);
+ SetConsoleCommand("ArtificialController", "setbotlevel", &ArtificialController::setAllBotLevel);
static const unsigned int STANDARD_MAX_FORMATION_SIZE = 7;
@@ -87,7 +87,7 @@
this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this));
this->bSetupWorked = false;
this->numberOfWeapons = 0;
- this->botlevel_ = 10.0f;
+ this->botlevel_ = 1.0f;
}
ArtificialController::~ArtificialController()
@@ -1068,11 +1068,18 @@
void ArtificialController::setBotLevel(float level)
{
- if (level < 1)
- this->botlevel_ = 1 ;
- else if (level > 10)
- this->botlevel_ = 10;
+ if (level < 0.0f)
+ this->botlevel_ = 0.0f;
+ else if (level > 1.0f)
+ this->botlevel_ = 1.0f;
else
this->botlevel_ = level;
}
+
+ void ArtificialController::setAllBotLevel(float level)
+ {
+ for (ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it != ObjectList<ArtificialController>::end(); ++it)
+ it->setBotLevel(level);
+ }
+
}
Modified: code/branches/ai/src/orxonox/controllers/ArtificialController.h
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.h 2011-01-31 20:33:18 UTC (rev 7841)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.h 2011-01-31 22:36:18 UTC (rev 7842)
@@ -82,6 +82,7 @@
void setBotLevel(float level=1.0f);
inline float getBotLevel() const
{ return this->botlevel_; }
+ static void setAllBotLevel(float level);
protected:
More information about the Orxonox-commit
mailing list