14.10 isSafeToKick

This method determines whether or not it is safe to use the non DRIBBLE kick modes. The idea here is that if an opponent is within some distance and you are wanting to kick then we should return FALSE or not safe to kick. This is because an opponent is likely to block the kick or interrupt the process of kicking. This is achieved by finding the closest distance an opponent is away from the ball and then checking if that is within some threshold. Currently this is set to 1 but perhaps it would be better to lower this value as very rarely is not another player within that distance.

First approach more optimal uses sorted vector of distances between opponent teams players and the ball, generated by GenerateOppToTargetDistanceVector where the target vector is the ball

bool NaoBehavior::isSafeToKick(vector<pair<double,int > > OppDistToBall){
    double minOppDis = OppDistToBall[0].first;
    if(minOppDis <1){
        return false;
    }
    return true;

}

Second approach requires finding the closest opponent using the array of distances for each player to the ball, generated by DistanceToBallArrayOpponents

bool NaoBehavior::isSafeToKick(double* _opponentDistances){
    double minOppDis = MAXFLOAT; 
    int arrlengthOpp = NUM_AGENTS;
    for(int z=0;z<arrlengthOpp;++z){
        if(_opponentDistances[z]< minOppDis){
            minOppDis = _opponentDistances[z];
        } 
    }
    if(minOppDis <1){
        return false;
    }
    return true;

}