new_surfnew_rect maketext('new game'textcolortilecolorwindowwidth windowheight solve_surfsolve_rect maketext('solve'textcolortilecolorwindowwidth windowheight mainboardsolutionseq generatenewpuzzle( solvedboard getstartingboard( solved board is the same as the board in start state allmoves [list of moves made from the solved configuration while truemain game loop slideto none the directionif anya tile should slide msg 'contains the message to show in the upper left corner if mainboard =solvedboard msg 'solved! drawboard(mainboardmsg checkforquit( for event in pygame event get()event handling loop if event type =mousebuttonup spotxspoty getspotclicked(mainboardevent pos[ ]event pos[ ] if (spotxspoty=(nonenone) check if the user clicked on an option button if reset_rect collidepoint(event pos) resetanimation(mainboardallmovesclicked on reset button allmoves [ elif new_rect collidepoint(event pos) mainboardsolutionseq generatenewpuzzle( clicked on new game button allmoves [ elif solve_rect collidepoint(event pos) resetanimation(mainboardsolutionseq allmovesclicked on solve button allmoves [ else check if the clicked tile was next to the blank spot blankxblanky getblankposition(mainboard if spotx =blankx and spoty =blanky slideto left elif spotx =blankx and spoty =blanky