Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GUESS: this is an java implementation of aStar (at least a part of it)
- static int bfs(int i,int j,int k ,int count)
- {
- node node = new node(i,j,k,count);
- node.d= 0; //distance to the source node is initialized to zero
- Queue<node> q = new LinkedList<node>();
- q.add(node); //add the first node to the queue
- while(!q.isEmpty()){
- node u = q.poll();
- for(int v = 0 ; v < 6 ; v++)
- { //check all the neighbours of u, if one of them is not visited, add it to the queue and mark it as visited
- int xx = u.x + dx[v];
- int yy = u.y + dy[v];
- int zz = u.z + dz[v];
- if(xx >= 0 && xx < l && yy >= 0 && yy < r && zz >= 0 && zz < c && !visited[xx][yy][zz] && maze[xx][yy][zz] != '#')
- {
- visited[xx][yy][zz] = true;
- node newNode= new node(xx,yy,zz,u.d+1);
- //v is not visited yet
- q.add(newNode);
- if(eX == xx && eY == yy && eZ == zz)
- {
- flag = true;
- return count;
- }
- }
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement