movey blanky elif direction =left movex blankx movey blanky elif direction =right movex blankx movey blanky prepare the base surface drawboard(boardmessage basesurf displaysurf copy( draw blank space over the moving tile on the basesurf surface moveleftmovetop getlefttopoftile(movexmovey pygame draw rect(basesurfbgcolor(moveleftmovetoptilesizetilesize) for in range( tilesizeanimationspeed) animate the tile sliding over checkforquit( displaysurf blit(basesurf( ) if direction =up drawtile(movexmoveyboard[movex][movey] - if direction =down drawtile(movexmoveyboard[movex][movey] if direction =left drawtile(movexmoveyboard[movex][movey]- if direction =right drawtile(movexmoveyboard[movex][movey] pygame display update( fpsclock tick(fps def generatenewpuzzle(numslides) from starting configurationmake numslides number of moves (and animate these moves sequence [ board getstartingboard( drawboard(board'' pygame display update( pygame time wait( pause milliseconds for effect lastmove none for in range(numslides) move getrandommove(boardlastmove slideanimation(boardmove'generating new puzzle 'int(tilesize )email questions to the authoral@inventwithpython com