def gethumanmove(boardisfirstmove) draggingtoken false tokenxtokeny nonenone while true for event in pygame event get()event handling loop if event type =quit pygame quit( sys exit( elif event type =mousebuttondown and not draggingtoken and redpilerect collidepoint(event pos) start of dragging on red token pile draggingtoken true tokenxtokeny event pos elif event type =mousemotion and draggingtoken update the position of the red token being dragged tokenxtokeny event pos elif event type =mousebuttonup and draggingtoken let go of the token being dragged if tokeny xmargin and tokenx windowwidth xmargin let go at the top of the screen column int((tokenx xmarginspacesize if isvalidmove(boardcolumn) animatedroppingtoken(boardcolumnred board[column][getlowestemptyspace(boardcolumn)red drawboard(board pygame display update( return tokenxtokeny nonenone draggingtoken false if tokenx !none and tokeny !none drawboard(board{' ':tokenx int(spacesize )' ':tokeny int(spacesize )'color':red} else drawboard(board if isfirstmove show the help arrow for the player' first move displaysurf blit(arrowimgarrowrect pygame display update( fpsclock tick( email questions to the authoral@inventwithpython com