def drawhighlightbox(boxxboxy) lefttop lefttopcoordsofbox(boxxboxy pygame draw rect(displaysurfhighlightcolor(left top boxsize boxsize ) def startgameanimation(board) randomly reveal the boxes at time coveredboxes generaterevealedboxesdata(false boxes [ for in range(boardwidth) for in range(boardheight) boxes append(xy random shuffle(boxes boxgroups splitintogroupsof( boxes drawboard(boardcoveredboxes for boxgroup in boxgroups revealboxesanimation(boardboxgroup coverboxesanimation(boardboxgroup def gamewonanimation(board) flash the background color when the player has won coveredboxes generaterevealedboxesdata(true color lightbgcolor color bgcolor for in range( ) color color color color swap colors displaysurf fill(color drawboard(boardcoveredboxes pygame display update( pygame time wait( def haswon(revealedboxes) returns true if all the boxes have been revealedotherwise false for in revealedboxes if false in return false return false if any boxes are covered return true if __name__ ='__main__'