This is AI snake : it will avoid the edges and the obstacles that you can place while pressing D and moving your mouse. Have fun!!
All code by @redi2go77