public TileStatus Search() { TileStatus status = MazeBot.TileStatus.Undefined; for (int x = 1; x < TileStatus.GetUpperBound(0); ++x) { for (int y = 1; y < TileStatus.GetUpperBound(1); ++y) { if (TileStatus[x, y] == MazeBot.TileStatus.Goal) // if goal is found, move there { status = MoveTo(x, y); } else if (TileStatus[x, y] == MazeBot.TileStatus.Undefined) // else move to first unmapped tile. { status = MoveTo(x, y); } else { status = TileStatus[x, y]; } if (status == MazeBot.TileStatus.Goal) { return(status); } } } return(MazeBot.TileStatus.Undefined); }
private byte[,] BuildPathFinderGrid() { int dimX = TileStatus.GetUpperBound(0) + 1; int dimY = TileStatus.GetUpperBound(1) + 1; byte[,] grid = new byte[dimX, dimY]; for (int x = 0; x < dimX; ++x) { for (int y = 0; y < dimY; ++y) { if (TileStatus[x, y] == MazeBot.TileStatus.Wall) { grid[x, y] = 0; } else { grid[x, y] = 1; } } } return(grid); }