예제 #1
0
/**
 pickIndex returns best location to move to

 Sorts vector of possible destinations and picks highest ranking one
 @param possibleDestinations :vector of possible destinations
 @returns index of first destination in sorted vector (the best)
 @exception none
 */
int AgentMoveClosest::pickIndex(std::vector<Location*> possibleDestinations)
{
    int best=0;
    for (int i=0; i<possibleDestinations.size(); ++i) {
        if (myCompare(possibleDestinations[i], possibleDestinations[best])>0) {
            best=i;
        }
        else if (myCompare(possibleDestinations[i], possibleDestinations[best])==0) {
            if (sim->getRnd(0,10)>5) best=i;//if equal pick one by coin flip
        }
    }
    //std::sort(possibleDestinations.begin(),possibleDestinations.end(),myCompare);
    return best;
}
예제 #2
0
/**
 pickIndex returns best location to move to
 
 Sorts vector of possible destinations and picks highest ranking one
 @param possibleDestinations :vector of possible destinations
 @returns index of first destination in sorted vector (the best)
 @exception none
 */
int AgentMove::pickIndex(std::vector<Location*> possibleDestinations)
{
    int best=0;
    for (int i=0; i<possibleDestinations.size(); ++i) {
        if (myCompare(possibleDestinations[i], possibleDestinations[best])) {
            best=i;
        }
    }
    //std::sort(possibleDestinations.begin(),possibleDestinations.end(),myCompare);
    return best;
}
예제 #3
0
파일: mylib.c 프로젝트: lljllj122/MyShell
int isInEnvpList(char *en, char **envp)
{
    char **env;
    int index = 0;
    for(env=envp; *env; env++){

        if(myCompare(en, *env)){
            return index;
        }

        index++;
    }

    return -1;
}