if boardwidth or >boardheight return none else return board[ ][ def getdropslots(board) creates "drop slotfor each column and fills the slot with number of gems that that column is lacking this function assumes that the gems have been gravity dropped already boardcopy copy deepcopy(board pulldownallgems(boardcopy dropslots [ for in range(boardwidth) dropslots append([] count the number of empty spaces in each column on the board for in range(boardwidth) for in range(boardheight- - - )start from bottomgoing up if boardcopy[ ][ =empty_space possiblegems list(range(len(gemimages)) for offsetxoffsety in (( - )( )( )(- )) narrow down the possible gems we should put in the blank space so we don' end up putting an two of the same gems next to each other when they drop neighborgem getgemat(boardcopyx offsetxy offsety if neighborgem !none and neighborgem in possiblegems possiblegems remove(neighborgem newgem random choice(possiblegems boardcopy[ ][ynewgem dropslots[xappend(newgem return dropslots def findmatchinggems(board) gemstoremove [ list of lists of gems in matching triplets that should be removed boardcopy copy deepcopy(board loop through each spacechecking for adjacent identical gems email questions to the authoral@inventwithpython com