This is adapated from the Snake Game on pygame.org
http://pygame.org/project-Snake+in+35+lines-818-.html
It has been slightly modified to allow an AI interface in the future.
Copy random_ai.py to add an AI
dirs is the next move of the snake. 0=Up, 1=Left, 2=Down, 3=Right
sg.xs and sg.ys are the current positions of the snake sg.applepos is the position of the apple