I almost wrote a snake game, but I still can’t get one of the main ideas. I would like for random walls to appear on the map during the game, as it happens in google snake game in wall mode. Here is the link to game.
My question is only about the idea of the algorithm and it's disconnected from a specific programming language.
The problem is that absolutely random walls could create “unreachable” places in the level, such as enclosed spaces, where the snake could not get theoretically. So how to check such "unreachable" places on a level and not create incorrect walls?
PS: Sorry for my poor English.
Just do a google search for the "A*" Algorithm. The head of the snake is your starting point, the apples your end point and the walls your obstacles. (of course you would have to think about, how to get around the problem of interfering with your tail)