示例#1
0
文件: IA.cpp 项目: Marechal-L/TronGL
void IA::move()
{
    int **grid=_grid->getGrid();
    Position direction=_directions[_direction];

    int posWallF = hasWall(_pos, direction, 100)+1;

    if(posWallF==1 || (rand()%(posWallF*20)==1))
    {
        int dG = (_direction + 1 + 4) % 4;
        int dD = (_direction - 1 + 4) % 4;

        int posWallG=hasWall(_pos, _directions[dG], 100);
        int posWallD=hasWall(_pos, _directions[dD], 100);

        if(posWallG>posWallD)
            turn(1);
        else
            turn(-1);

        return;
    }

    /*if(rand()%150==1)
    {
        int dG = (_direction + 1 + 4) % 4;
        int dD = (_direction - 1 + 4) % 4;

        int posWallG=hasWall(_pos, _directions[dG], 10);
        int posWallD=hasWall(_pos, _directions[dD], 10);

        if(posWallG > posWallD && posWallG>1)
            turn(1);
        else
            turn(-1);
    }*/
}
示例#2
0
文件: Board.cpp 项目: Jmgiacone/CS153
bool Board::isValid(const int x, const int y)
{
  return inBounds(x, y) && !hasClam(x, y) && !hasWall(x, y) && !haveVisited(x, y);
}