14.23 GeneratePreferenceArrayForAnAgent

Generates a vector of type vector<pair<double,int > > which is used to generate a vector which stores the point preferences of a single player. Firstly arr is defined as a vector<pair<double, double> > which keeps track of all the (x,y) coordinates of all the ImportantPositions, these are those specific predefined positions that we need to pair with our players. When then define p which is a pair which stores the (x,y) position of a player. The remainder of the logic involved with generating our preference array is contained within sortArr which will take arr and p and return our sorted arr of preferences. This vector is then used by GeneratePreferenceArrayForTeam to do the same process for each player.

vector<pair<double,int > > NaoBehavior::GeneratePreferenceArrayForAnAgent(vector<VecPosition> ImportantPositions, VecPosition playerpos){
    vector<pair<double, double> > arr;

    for(int i=0;i<NUM_AGENTS;i++){
        pair<double, double> temp = {ImportantPositions[i].getX(),ImportantPositions[i].getY()};
        arr.push_back(temp);
    }
    int n = NUM_AGENTS;
    pair<double, double> p = {playerpos.getX(), playerpos.getY()};

    vector<pair<double,int > > sortedarr;
    sortedarr = sortArr(arr, n, p);
    return sortedarr;
}