Bug 596

Summary: Red Ghost crashes into wall
Product: Group14-Pacman Reporter: Aleksa <ajelaca2-c>
Component: GameAssignee: Alex <alex.scriba>
Status: RESOLVED FIXED    
Severity: enhancement CC: tianxyang3-c
Priority: High    
Version: 0.0.2   
Hardware: PC   
OS: Windows   

Description Aleksa 2021-11-21 01:09:54 HKT
I run Main.java with commands "LEFT" 12 times. I expected the Red Ghost to come and eat PacMan, but instead it crashed into the wall and I got this exception from Eclipse:

Exception in thread "main" java.lang.NullPointerException
        at Game.Moveable.move(Moveable.java:17)
        at Game.Ghost.moveToTarget(Ghost.java:121)
        at Game.ScatterTopRightCorner.behave(ScatterTopRightCorner.java:11)
        at Game.Game.moveGhosts(Game.java:173)
        at Game.Game.handleMovements(Game.java:115)
        at Game.Game.gameTick(Game.java:60)
        at Game.Main.main(Main.java:26)
Comment 1 Aleksa 2021-11-21 01:18:30 HKT
Solution: 


1) Ghost should not use Manhattan distance as a heuristic. We introduce Euclidian distance
2)Ghost cannot change the position when it is surrounded by walls on its 3 sides
A conditional in moveToTarget() in Ghost.java should be used to check whether the next direction of the ghost is null or not
4) Moreover, the coordinates of the maze corners have been substituted. I fixed that

Now, the red ghost does not crash into walls anymore