I tried to add the ability of the snake to pass through the walls. There were several problems.
The snake loses one part of the body as it passes through the wall, Until it disappears.
Food becomes inactive.
If the length of the snake is less than 2 through the walls, it passes but not
come back on the other side.
Solutions are probably completely crooked, because sometimes nothing works at all. Please indicate the errors, I will be grateful for the example how it was necessary b.