src/drone.cpp
/*
  Preferred actions RO policy
  NOTE: This incomplete and most likely useless.
*/
Preferred actions RO policy
NOTE: This incomplete and most likely useless.
Preferred actions RO policy NOTE : This incomplete and most likely useless .
void DRONE::GeneratePreferred(const STATE& state, const HISTORY& history,
                               vector<int>& actions, const STATUS& status) const
{
    const DRONE_STATE& droneState =
            safe_cast<const DRONE_STATE&>(state);
    COORD pose = droneState.AgentPos;
    int person;
    int room = Grid.Index(pose);
    bool roomPhoto = false;
    bool identify = false;
    for(int i=0; i<NumCreatures; i++){
        person = i;
        if(droneState.Features[person].measured < 3 &&
           std::abs(droneState.Features[person].count) < 2 &&
           droneState.Features[person].ProbTarget != 1.0 &&
           droneState.Features[person].ProbTarget != 0.0 &&
           droneState.Features[person].ObservedPosition == pose){
            identify = true;
            actions.push_back(E_IDENTIFY + person);
        }
        if(droneState.Features[person].ProbTarget > 0.7 &&
           std::abs(droneState.Features[person].count) > 2 &&
           droneState.Features[person].measured > 2 &&
           droneState.Features[person].ObservedPosition == pose &&
           !roomPhoto) {
            roomPhoto = true; 
            actions.push_back(E_PHOTO + room);
        }
    }
    bool moveN = false;
    bool moveS = false;
    bool moveE = false;
    bool moveW = false;
    bool stay = false;
    for(int i=0; i<NumCreatures && !roomPhoto && !identify; i++){
        if(droneState.Features[i].ObservedPosition != COORD::Null && droneState.Features[i].Target >= 0.5){
            if(droneState.Features[i].ObservedPosition.Y > pose.Y) 
               moveN = true;
            if(droneState.Features[i].ObservedPosition.Y < pose.Y) 
               moveS = true;
            if(droneState.Features[i].ObservedPosition.X > pose.X) 
               moveE = true;
            if(droneState.Features[i].ObservedPosition.X < pose.X) 
               moveW = true;
            if(droneState.Features[i].ObservedPosition == pose) 
               stay = true;
        }
    }
    if(moveN) actions.push_back(COORD::E_NORTH);
    if(moveS) actions.push_back(COORD::E_SOUTH);
    if(moveE) actions.push_back(COORD::E_EAST);
    if(moveW) actions.push_back(COORD::E_WEST);
    if(stay) actions.push_back(A_WAIT);
    if(droneState.TargetPhotosTaken >= PhotosNeeded)
        actions.push_back(A_LEAVE);
    int posX, posY;
    for(int j=0; j<NumCreatures; j++){
        if(droneState.Features[j].ObservedPosition != COORD::Null &&
           droneState.Features[j].ProbTarget >= 0.5) {
            posY = droneState.Features[j].ObservedPosition.Y;
            posX = droneState.Features[j].ObservedPosition.X;
            if(posY < Size-1) 
                actions.push_back(E_CHECK + Grid.Index(posX, posY+1));
            if(posY > 0) 
                actions.push_back(E_CHECK + Grid.Index(posX, posY-1));
            if(posX < Size-1) 
                actions.push_back(E_CHECK + Grid.Index(posX+1, posY));
            if(posX > 0) 
                actions.push_back(E_CHECK + Grid.Index(posX-1, posY));
        }
    }
}
void DRONE :: GeneratePreferred ( const STATE & state , const HISTORY & history , vector < int > & actions , const STATUS & status ) const { const DRONE_STATE & droneState = safe_cast < const DRONE_STATE & > ( state ) ; COORD pose = droneState . AgentPos ; int person ; int room = Grid . Index ( pose ) ; bool roomPhoto = false ; bool identify = false ; for ( int i = 0 ; i < NumCreatures ; i ++ ) { person = i ; if ( droneState . Features [ person ] . measured < 3 && std :: abs ( droneState . Features [ person ] . count ) < 2 && droneState . Features [ person ] . ProbTarget != 1.0 && droneState . Features [ person ] . ProbTarget != 0.0 && droneState . Features [ person ] . ObservedPosition == pose ) { identify = true ; actions . push_back ( E_IDENTIFY + person ) ; } if ( droneState . Features [ person ] . ProbTarget > 0.7 && std :: abs ( droneState . Features [ person ] . count ) > 2 && droneState . Features [ person ] . measured > 2 && droneState . Features [ person ] . ObservedPosition == pose && ! roomPhoto ) { roomPhoto = true ; actions . push_back ( E_PHOTO + room ) ; } } bool moveN = false ; bool moveS = false ; bool moveE = false ; bool moveW = false ; bool stay = false ; for ( int i = 0 ; i < NumCreatures && ! roomPhoto && ! identify ; i ++ ) { if ( droneState . Features [ i ] . ObservedPosition != COORD :: Null && droneState . Features [ i ] . Target >= 0.5 ) { if ( droneState . Features [ i ] . ObservedPosition . Y > pose . Y ) moveN = true ; if ( droneState . Features [ i ] . ObservedPosition . Y < pose . Y ) moveS = true ; if ( droneState . Features [ i ] . ObservedPosition . X > pose . X ) moveE = true ; if ( droneState . Features [ i ] . ObservedPosition . X < pose . X ) moveW = true ; if ( droneState . Features [ i ] . ObservedPosition == pose ) stay = true ; } } if ( moveN ) actions . push_back ( COORD :: E_NORTH ) ; if ( moveS ) actions . push_back ( COORD :: E_SOUTH ) ; if ( moveE ) actions . push_back ( COORD :: E_EAST ) ; if ( moveW ) actions . push_back ( COORD :: E_WEST ) ; if ( stay ) actions . push_back ( A_WAIT ) ; if ( droneState . TargetPhotosTaken >= PhotosNeeded ) actions . push_back ( A_LEAVE ) ; int posX , posY ; for ( int j = 0 ; j < NumCreatures ; j ++ ) { if ( droneState . Features [ j ] . ObservedPosition != COORD :: Null && droneState . Features [ j ] . ProbTarget >= 0.5 ) { posY = droneState . Features [ j ] . ObservedPosition . Y ; posX = droneState . Features [ j ] . ObservedPosition . X ; if ( posY < Size - 1 ) actions . push_back ( E_CHECK + Grid . Index ( posX , posY + 1 ) ) ; if ( posY > 0 ) actions . push_back ( E_CHECK + Grid . Index ( posX , posY - 1 ) ) ; if ( posX < Size - 1 ) actions . push_back ( E_CHECK + Grid . Index ( posX + 1 , posY ) ) ; if ( posX > 0 ) actions . push_back ( E_CHECK + Grid . Index ( posX - 1 , posY ) ) ; } } }
Preferred actions RO policy
NOTE: This incomplete and most likely useless.
Preferred actions RO policy NOTE : This incomplete and most likely useless .
//Process the people in the room // Identify people if their target status is not well known // and its location IS the current room //Photograph the room if this person appears to be the target //Add action only once //Move in the direction of potential targets only if no picture can be taken //If interesting people are spotted, follow them //determine relative direction //North //South //East //West //Wait //Check the rooms adjacent to the last known location of potential targets //for(int i=0; i<NumCells && !identify && !roomPhoto; i++) { //int roomN = droneState.Features[j].ObservedPosition.Y+1 //North //South //East //West //            actions.push_back(E_CHECK + room); //} //}