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

How to scale/resize CVPixelBufferRef in objective C, iOS

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

SVG with two text elements. When one resizes due to textLength - how to resize the other one to the same character size