Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6696


Ignore:
Timestamp:
Apr 12, 2010, 4:52:01 PM (15 years ago)
Author:
solex
Message:

Master now limiting its formation size and revokes it with a probability based on its size

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

Legend:

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

    r6695 r6696  
    7777        if (this->state_ == MASTER)//MASTER
    7878        {
     79
    7980            // command slaves
    8081            this->commandSlaves();
     82
     83
     84            // lose master status (only if less than 4 slaves in formation)
     85            random = rnd(maxrand);
     86            if(random < 5/(this->slaves.size()+1) && this->slaves.size() < 5 )
     87                this->loseMasterState();
     88
     89            // look out for outher masters if formation is small
     90            if(this->slaves.size() < 3)
     91                this->searchNewMaster();
    8192
    8293            // search enemy
  • code/branches/ai/src/orxonox/controllers/ArtificialController.cc

    r6695 r6696  
    132132            if (static_cast<ControllableEntity*>(*it) != this->getControllableEntity()) //&& it->getPosition().squaredDistance(this->getControllableEntity()->getPosition()) < 1000
    133133            {
     134                if(controller->slaves.size() > 9) continue;
     135
     136                this->freeAllSlaves();
     137                this->slaves.clear();
    134138                this->state_ = SLAVE;
     139
    135140                this->myMaster_ = controller;
    136141                controller->slaves.push_back(this);
     142
    137143                break;
    138144            }
     
    170176    {
    171177
     178
     179        for(std::list<ArtificialController*>::iterator it = slaves.begin(); it != slaves.end(); it++)
     180        {
     181            (*it)->state_ = FREE;
     182        }
     183/*
    172184        for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
    173185        {
     
    178190            controller->state_ = FREE;
    179191        }
    180 
    181     }
    182 
     192*/
     193    }
     194
     195    void ArtificialController::loseMasterState()
     196    {
     197        this->freeAllSlaves();
     198        this->state_ = FREE;
     199    }
    183200
    184201    void ArtificialController::setTargetPosition(const Vector3& target)
  • code/branches/ai/src/orxonox/controllers/ArtificialController.h

    r6695 r6696  
    6666            void commandSlaves();
    6767            void freeAllSlaves();
     68            void loseMasterState();
    6869
    6970            ArtificialController *myMaster_;
Note: See TracChangeset for help on using the changeset viewer.