new simulator/turtle.cpp
bool turtle::get_next(int &new_x, int &new_y, const int game_map[][150])
{
    // record passing on
    if (last) delete last;
    last = now; now = NULL;
    // same place - stop
    if (game_map[x][y] == 4)
    {
        now = new turtle::record(last, x, y, this);
        new_x = x; new_y = y;
        return true;
    }
    // human in robot's sight?
    int hx, hy;
    bool around = turtle::scan(x, y, r, hx, hy, game_map);
    if (around) turtle::cheak_wall(x, y, hx, hy, game_map);
    now = new turtle::record(last, hx, hy, this);
    // human in sight - track
    if (now -> insight)
    {
        if (plan) delete plan;
        x += sgn(now->hx - x);
        y += sgn(now->hy - y);
        new_x = x; new_y = y;
        return true;
    }
    // human out of sight - search
    else
    {
        if (!plan) plan = new turtle::search_plan(this);
        if (!plan->move(this)) return false;
        new_x = x; new_y = y;
        return true;
    }
}
//the result should be passed by the pointers. The inner state of x and y should also be updated.

the result should be passed by the pointers. The inner state of x and y should also be updated.
the result should be passed by the pointers . The inner state of x and y should also be updated .
bool turtle::get_next(int &new_x, int &new_y, const int game_map[][150])
{
    if (last) delete last;
    last = now; now = NULL;
    if (game_map[x][y] == 4)
    {
        now = new turtle::record(last, x, y, this);
        new_x = x; new_y = y;
        return true;
    }
    int hx, hy;
    bool around = turtle::scan(x, y, r, hx, hy, game_map);
    if (around) turtle::cheak_wall(x, y, hx, hy, game_map);
    now = new turtle::record(last, hx, hy, this);
    if (now -> insight)
    {
        if (plan) delete plan;
        x += sgn(now->hx - x);
        y += sgn(now->hy - y);
        new_x = x; new_y = y;
        return true;
    }
    else
    {
        if (!plan) plan = new turtle::search_plan(this);
        if (!plan->move(this)) return false;
        new_x = x; new_y = y;
        return true;
    }
}
bool turtle :: get_next ( int & new_x , int & new_y , const int game_map [ ] [ 150 ] ) { if ( last ) delete last ; last = now ; now = NULL ; if ( game_map [ x ] [ y ] == 4 ) { now = new turtle :: record ( last , x , y , this ) ; new_x = x ; new_y = y ; return true ; } int hx , hy ; bool around = turtle :: scan ( x , y , r , hx , hy , game_map ) ; if ( around ) turtle :: cheak_wall ( x , y , hx , hy , game_map ) ; now = new turtle :: record ( last , hx , hy , this ) ; if ( now -> insight ) { if ( plan ) delete plan ; x += sgn ( now -> hx - x ) ; y += sgn ( now -> hy - y ) ; new_x = x ; new_y = y ; return true ; } else { if ( ! plan ) plan = new turtle :: search_plan ( this ) ; if ( ! plan -> move ( this ) ) return false ; new_x = x ; new_y = y ; return true ; } }
the result should be passed by the pointers.
the result should be passed by the pointers .
// record passing on
 // same place - stop
 // human in robot's sight?
 // human in sight - track
 // human out of sight - search
