At each movement of the snake, it calculates the shortest path to the apple by using the breadth first search algorithm to avoid its own body. This algorithm is somewhat inefficient, because at every movement a new BFS is run, and the snake only uses the first direction and then scraps the rest of the path it is given. This causes the snake to only die when it has trapped itself and can no longer see the apple.
This algorithm can work much faster than the other three, but the snake will probably not survive as long. This algorithm tells the snake where to move based on the closest option to the food regardless of the shortest path. Because of this the snake tends to trap itself a lot more often causing this to be the worst algorithm.
This algorithm combines the two above. When the snake can see the apple normally it will use the BFS algorithm to decide which way to move. The difference between this algorithm and the BFS algorithm is that when this snake cannot see the apple it will decide which way to move using the Greedy algorithm from above. This causes this algorithm to perform better than both BFS and Greedy by themselves.
Similarly to BFS + Greedy this algorithm also uses BFS when it can see the apple, but when it loses sight of the apple instead of using the greedy algorithm from above it does the opposite. The greedy algorithm will move the snake closer to the food regardless of where the rest of the snake body is. The escape portion of this algorithm causes the snake to move away from the apple when it cannot see it. I decided to create this algorithm, because it forces the snake to create an opening for itself to go and get the apple.