This site requires JavaScript, please enable it in your browser!
Greenfoot back
dangwang
dangwang wrote ...

2014/5/12

AI and Intersections (pacman)

dangwang dangwang

2014/5/12

#
How could i check to make sure the Ghost has passed the intersection it is currently at before running the code to choose a direction at an intersection? I used random numbers to randomize direction at an intersection for the ghosts but it sometimes just hangs at the intersection.
davmac davmac

2014/5/12

#
You need to introduce an instance variable which tracks whether the decision for the direction has been made yet. Only choose a new direction if it is false. You will need to clear it back to false once your Ghost moves past the intersection.
You need to login to post a reply.