I’m developing a snake AI and trying to prevent the snake from trapping itself in corners or dead ends. My approach involves using Breadth-First Search to evaluate potential moves before making them.
The main challenge I’m facing is determining the minimum number of reachable empty cells that should be available after making a move. I want to ensure the snake has enough space to continue moving without getting stuck.
For example, if I’m considering moving the snake head to a particular position, I need to calculate how many connected empty tiles will be accessible from that new position. But I’m not sure what threshold value would be safe enough to avoid self-collision.
Has anyone worked on similar pathfinding logic for snake games? What’s a good minimum count of accessible spaces to check for?