Exemplo n.º 1
0
Standard_Real distanceTwoShapes(TopoDS_Shape &shape_1, TopoDS_Shape &shape_2, bool &inside)
{
    BRepExtrema_DistShapeShape dist_calc(shape_1, shape_2);

    dist_calc.Perform();

    inside = dist_calc.InnerSolution();

    return dist_calc.Value();
}
Exemplo n.º 2
0
int best_option(char* Maze, int start)
{
    int* U_$;
    int* Add_$; 
    int U_R = sdistance(Maze, start, 2650), min;   
    U_$ = (int*)malloc(sizeof(int)*100);
    Add_$ = (int*)malloc(sizeof(int)*100);
    int i =0,j=0;
    while(i<2704)
    {
        if(Maze[i] == '$')
        {
            U_$[j] = sdistance(Maze, start, i);
            Add_$[j] = i;
            j++;
        }
        i++;
    }
    U_$[j] = -10;  //termination constant
    j = 0;
    min = U_$[j];
    int minadd = Add_$[j];
    for(j=0; U_$[j] != -10; j++)
    {
        if(min > U_$[j])
            {min = U_$[j]; minadd = Add_$[j];} 
    }
    int E = posn(Maze, 'E');
    int E_R = sdistance(Maze, E, 2650);
    int* E_$;
    E_$ = (int*)malloc(sizeof(int)*100);
    i =0,j=0;
    while(i<2704)
    {
        if(Maze[i] == '$')
        {
            E_$[j] = sdistance(Maze, E, i);
            j++;
        }
        i++;
    }
    E_$[j] = -10;  //termination constant

    
    
/*
 * Now here, starts the bot algorithm The decisive part of the bot which decides
 * which point towards should the move be intended for
 */
 
/*
 * If distance between U and R is less than that between E and R
 * and provided E cant take 5 $ before U reaches R, go straight for R
 */ 
    if(U_R < dist_calc(E_$,5) && U_R < E_R)
        return 2650;

/*
 * If distance between U and R is less than that between E and R
 * and provided E can reach 5 $ before U reaches R.
 */
    else if(U_R < E_R && U_R > dist_calc(E_$,5))
    {
    // If U can reach a $ and still be close to R than E go take that $
        if(min + sdistance(Maze,minadd,2650) < E_R)
            return minadd;
    // Going towards R while collecting random $ near it (radius 4)               
//        else
//            return standard(Maze,start);
    }
    else if(U_R == E_R)
        return standard(Maze, start);
    else if(U_R > E_R)
    {
            return minadd;          
    }    
    return 2650;
}