The chomping monster has several methods to move around. The character can be controlled using the keyboard, move in a random direction, or use a custom algorithm to complete the map.
The algorithm is named Gluttony and was designed to move across the map as much as possible while eating all of the dots. The code currently doesn’t have any avoidance options. This will come in a future update
The chomping monster uses the following rules to move around.
- It checks if there are any dots in the immediate directions.
- Then counts the number of dots in a line and chooses the largest number to travel.
- Then gets every dots until it reaches the end and then repeats the process.
- If there are no dots visible, it then checks in front and side to side and counts the dots on the entire screen.
- Then takes a “suggestion” of the largest quantity and moves in that direction.
Getting the character unstuck. When Chomp is being directed around the maze there is a possibility of getting stuck into a loop. This can be caused by having the same number of dots in several directions. to address this issue.
- When the chomping monster is at an intersection point where there is more than one direction available. it places down a marker in that cell.
- This marker has the direction that was chosen.
- The next time Chomp hits the same cell it will be forced to make a different choice.