hintsrect hintssurf get_rect( hintsrect topright (windowwidth while truemain game loop keep looping for player and computer' turns if turn ='player' player' turn if getvalidmoves(mainboardplayertile=[] if it' the player' turn but they can' movethen end the game break movexy none while movexy =none keep looping until the player clicks on valid space determine which board data structure to use for display if showhints boardtodraw getboardwithvalidmoves(mainboardplayertile else boardtodraw mainboard checkforquit( for event in pygame event get()event handling loop if event type =mousebuttonup handle mouse click events mousexmousey event pos if newgamerect collidepoint(mousexmousey) start new game return true elif hintsrect collidepoint(mousexmousey) toggle hints mode showhints not showhints movexy is set to two-item tuple xy coordinateor none value movexy getspaceclicked(mousexmousey if movexy !none and not isvalidmove(mainboardplayertilemovexy[ ]movexy[ ]) movexy none draw the game board drawboard(boardtodraw drawinfo(boardtodrawplayertilecomputertileturn draw the "new gameand "hintsbuttons displaysurf blit(newgamesurfnewgamerect