Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7842 for code/branches/ai


Ignore:
Timestamp:
Jan 31, 2011, 11:36:18 PM (14 years ago)
Author:
jo
Message:

Console command still doesn't seem to work. botLevel_ is now defined between 0.0f and 1.0f

Location:
code/branches/ai/src/orxonox/controllers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai/src/orxonox/controllers/AIController.cc

    r7840 r7842  
    7676            // search enemy
    7777            random = rnd(maxrand);
    78             if (random < (15 + botlevel_* 2) && (!this->target_))
     78            if (random < (15 + botlevel_* 20) && (!this->target_))
    7979                this->searchNewTarget();
    8080
    8181            // forget enemy
    8282            random = rnd(maxrand);
    83             if (random < (5/botlevel_) && (this->target_))
     83            if (random < ((1-botlevel_)*5) && (this->target_))
    8484                this->forgetTarget();
    8585
    8686            // next enemy
    8787            random = rnd(maxrand);
    88             if (random < (10 + botlevel_) && (this->target_))
     88            if (random < ((1+ botlevel_)*10) && (this->target_))
    8989                this->searchNewTarget();
    9090
     
    106106            // shoot
    107107            random = rnd(maxrand);
    108             if (!(this->passive_) && random < (75 + botlevel_*3) && (this->target_ && !this->bShooting_))
     108            if (!(this->passive_) && random < (75 + botlevel_*25) && (this->target_ && !this->bShooting_))
    109109                this->bShooting_ = true;
    110110
    111111            // stop shooting
    112112            random = rnd(maxrand);
    113             if (random < (25 - botlevel_*2 ) && (this->bShooting_))
     113            if (random < ((1 - botlevel_)*25) && (this->bShooting_))
    114114                this->bShooting_ = false;
    115115
     
    192192                // stop shooting
    193193                random = rnd(maxrand);
    194                 if (random < (25 - botlevel_*2 ) && (this->bShooting_))
     194                if (random < ( (1- botlevel_)*25 ) && (this->bShooting_))
    195195                    this->bShooting_ = false;
    196196
  • code/branches/ai/src/orxonox/controllers/ArtificialController.cc

    r7841 r7842  
    5252    SetConsoleCommand("ArtificialController", "passivebehaviour", &ArtificialController::passivebehaviour);
    5353    SetConsoleCommand("ArtificialController", "formationsize",    &ArtificialController::formationsize);
    54     SetConsoleCommand("ArtificialController", "botlevel",         &ArtificialController::setBotLevel);
     54    SetConsoleCommand("ArtificialController", "setbotlevel",      &ArtificialController::setAllBotLevel);
    5555   
    5656
     
    8888        this->bSetupWorked = false;
    8989        this->numberOfWeapons = 0;
    90         this->botlevel_ = 10.0f;
     90        this->botlevel_ = 1.0f;
    9191    }
    9292
     
    10691069    void ArtificialController::setBotLevel(float level)
    10701070    {
    1071         if (level < 1)
    1072             this->botlevel_ = 1 ;
    1073         else if (level > 10)
    1074             this->botlevel_ = 10;
     1071        if (level < 0.0f)
     1072            this->botlevel_ = 0.0f;
     1073        else if (level > 1.0f)
     1074            this->botlevel_ = 1.0f;
    10751075        else
    10761076            this->botlevel_ = level;
    10771077    }
     1078   
     1079    void ArtificialController::setAllBotLevel(float level)
     1080    {
     1081        for (ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it != ObjectList<ArtificialController>::end(); ++it)
     1082            it->setBotLevel(level);
     1083    }
     1084   
    10781085}
  • code/branches/ai/src/orxonox/controllers/ArtificialController.h

    r7833 r7842  
    8383            inline float getBotLevel() const
    8484                { return this->botlevel_; }
     85            static void setAllBotLevel(float level);
    8586
    8687        protected:
Note: See TracChangeset for help on using the changeset viewer.