add more logic to snake.m and tested.