14.6 GenerateOppToTargetDistanceVector

Like GenerateTeamToTargetDistanceVector this is a new and improved version of DistanceToBallArrayOpponents that makes use of vectors rather than pointers as well as being more generalisable.

vector<pair<double,int > > NaoBehavior::GenerateOppToTargetDistanceVector(VecPosition target){

    vector<pair<double,int> > distances;
    target.setZ(0);

    for(int i = WO_OPPONENT1; i<WO_OPPONENT1+NUM_AGENTS;i++){ //OUR PLAYERS
        WorldObject* opponent = worldModel->getWorldObject(i);
        VecPosition temp;
        temp = opponent->pos;
        temp.setZ(0);

        float distance = temp.getDistanceTo(target);

        pair<double, int> temppoint = {distance,i};
        distances.push_back(temppoint);


        //worldModel->getRVSender()->drawText("distTEAM",std::to_string(distance),temp.getX(),temp.getY()+2*mynum,1,1,1);

    }

    sort(distances.begin(), distances.end());
    /* for (int i = 0; i < distances.size(); i++) {
        cout << "("
             << distances[i].first << ", "
             << distances[i].second << ") ";
    }
    cout << "\n"; */

    return distances;

}