Exemplo n.º 1
0
tANDp Tactic::findTarget()
{
    tANDp out;
    out.prob = 0;
    if (!wm->ball.isValid) return out;
    wm->TANDPis.clear();


    int dist_Clearance = 00 ; // 3 cm for opp Robot Reaction displacement
    for(int jj=-10;jj<11;jj++)
    {
        int prob=100;
        Vector2D Point;
        Point.x = Field::oppGoalCenter.x;
        Point.y = Field::oppGoalCenter.y + jj*(Field::oppGoalPost_L.y/10);
        tANDp tp;
        tp.pos=Point;
        int min_prob = 100;
        for(int ii=0;ii<12;ii++)
        {
            if(wm->oppRobot[ii].isValid)
            {
                if(wm->oppRobot[ii].pos.loc.x > wm->ball.pos.loc.x-500)
                {
                    Segment2D ball2Point(wm->ball.pos.loc,Point);
                    double dist2R = ball2Point.dist(wm->oppRobot[ii].pos.loc);
                    if (dist2R < (ROBOT_RADIUS + BALL_RADIUS + dist_Clearance) ) prob=0;
                    else if (dist2R < 500 )
                    {


                        prob = dist2R/5.0;
//                        qDebug() << " prob : " << prob ;
                    }
                    else prob = 100;
                    if(prob < min_prob) min_prob = prob;
                }
            }
            min_prob=min_prob-fabs(jj/3.0);
            if(fabs(jj)>7) min_prob = min_prob*0.9;
            if(min_prob < 0) min_prob=0;
            if(min_prob == 0) break;
        }
       // qDebug() << " Min : " << min_prob;
        tp.prob=min_prob;
       // qDebug() << "tp.prob : " << tp.prob;
        wm->TANDPis.push_back(tp);
    }

    out = wm->TANDPis.at(0);
    for(int i=1;i<wm->TANDPis.size();i++)
    {
        if( out.prob < wm->TANDPis.at(i).prob)
            out = wm->TANDPis.at(i);
    }
    wm->max_TANDPis = out;
    return out;
}
Exemplo n.º 2
0
double Knowledge::oppScoringChance(Vector2D loc)
{
    tANDp out;
    out.prob = 0;

    QList<tANDp> TANDPis;
    int prob=100;
    int dist_Clearance = 30 ; // 3 cm for opp Robot Reaction displacement
    QList<int> our = this->findOurObstacles();
    if( !_wm->kn->IsInsideRect(loc , Vector2D(Field::MaxX/2,Field::MaxY) ,Vector2D(Field::MaxX,Field::MinY)) )
    {
        for(int jj=-10;jj<11;jj++)
        {
            Vector2D Point;
            Point.x = Field::ourGoalCenter.x;
            Point.y = Field::ourGoalCenter.y + jj*(Field::ourGoalPost_L.y/10);
            tANDp tp;
            tp.pos=Point;
            int min_prob = 100;
            for(int ii=0;ii<our.size();ii++)
            {
                if(_wm->ourRobot[our.at(ii)].isValid)
                {
                    if(_wm->ourRobot[our.at(ii)].pos.loc.x < loc.x)
                    {
                        Segment2D ball2Point(loc,Point);
                        double dist2R = ball2Point.dist(_wm->ourRobot[our.at(ii)].pos.loc);
                        if (dist2R < (ROBOT_RADIUS + BALL_RADIUS + dist_Clearance) ) prob=0;
                        else if (dist2R < 400 ) prob = dist2R/4;
                        else prob = 100;
                        if(prob < min_prob) min_prob = prob;
                    }
                }
                if(abs(jj) > 7) prob = prob*((17-abs(jj))/10);
                if(min_prob == 0) break;
            }
            tp.prob=min_prob;
            TANDPis.push_back(tp);
        }
    }
    else
    {
        tANDp tp;
        tp.prob = 0;
        TANDPis.push_back(tp);
    }

    out = TANDPis.at(0);
    for(int i=1;i<TANDPis.size();i++)
    {
        if( out.prob < TANDPis.at(i).prob)
            out = TANDPis.at(i);
    }
    return out.prob;
}
Exemplo n.º 3
0
double Knowledge::scoringChance(Vector2D loc)
{
    tANDp out;
    out.prob = 0;

    QList<tANDp> TANDPis;
    int prob=100;
    int dist_Clearance = 30 ; // 3 cm for opp Robot Reaction displacement
    for(int jj=-10;jj<11;jj++)
    {
        Vector2D Point; // 20 Points Are On OppGoal Line And Each Has a Chance To goal
        Point.x = Field::oppGoalCenter.x;
        Point.y = Field::oppGoalCenter.y + jj*(Field::oppGoalPost_L.y/10);
        tANDp tp;
        tp.pos=Point;
        int min_prob = 100;
        for(int ii=0;ii<12;ii++)
        {
            if(_wm->oppRobot[ii].isValid)
            {
                if(_wm->oppRobot[ii].pos.loc.x > loc.x)
                {
                    Segment2D ball2Point(loc,Point);
                    double dist2R = ball2Point.dist(_wm->oppRobot[ii].pos.loc);
                    if (dist2R < (ROBOT_RADIUS + BALL_RADIUS + dist_Clearance) ) prob=0;
                    else if (dist2R < 400 ) prob = dist2R/4;
                    else prob = 100;
                    if(prob < min_prob) min_prob = prob;
                }
            }
            if(abs(jj) > 7) prob = prob*((17-abs(jj))/10);
            if(min_prob == 0) break;
        }
        tp.prob=min_prob;
        TANDPis.push_back(tp);
    }

    out = TANDPis.at(0);
    for(int i=1;i<TANDPis.size();i++)
    {
        if( out.prob < TANDPis.at(i).prob)
            out = TANDPis.at(i);
    }
    return out.prob;
}