cygni / snakebot

http://snake.cygni.se
MIT License
2 stars 7 forks source link

Remove collision when head follows tail #109

Closed gustavthron closed 1 year ago

gustavthron commented 1 year ago

As I have understood this class, its purpose is to move a snake in a world where it is alone. Before moving the head it checks for collisions with Obstacle, Food and itself. However, the check does not consider that the tail will also move when forceGrowth is false and will incorrectly throw a SnakeCollision when a snake moves to its tail's previous location. An exception is when the snake is 2 parts long, because that would mean that the snake is moving backwards.