Need help creating a BFS using Points in Java

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Need help creating a BFS using Points in Java



I'm having trouble understanding how to implement the BFS.(I do know how it works i just cant get my head around doing this in java).
This code is to do with an AI snake.
I am able to make it move strait to the goal but it does not avoid the walls.



In my method I am passing through:



In my Class I have already passed through the goal Point.



The beginning of my BFS Method is below:




public void BFSQ(ArrayList ClosedList,Point SnakeHead){

LinkedList<Point> Viseted = new LinkedList<>();
Queue queue = new LinkedList();
((LinkedList) queue).add(SnakeHead);
Viseted.add(SnakeHead);
while(!queue.isEmpty()){
Point temp = new Point();
temp= (Point) queue.remove();

/*this is where Im having troubles. i don't know how i would approach the loop

*/


}


}









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

415 Unsupported Media Type while sending json file over REST Template

PHP parse/syntax errors; and how to solve them?