for in range(boardwidth) if potentialmoves[ibestmovefitness and isvalidmove(boardi) bestmovefitness potentialmoves[ find all potential moves that have this best fitness bestmoves [ for in range(len(potentialmoves)) if potentialmoves[ =bestmovefitness and isvalidmove(boardi) bestmoves append( return random choice(bestmoves def getpotentialmoves(boardtilelookahead) if lookahead = or isboardfull(board) return [ boardwidth if tile =red enemytile black else enemytile red figure out the best move to make potentialmoves [ boardwidth for firstmove in range(boardwidth) dupeboard copy deepcopy(board if not isvalidmove(dupeboardfirstmove) continue makemove(dupeboardtilefirstmove if iswinner(dupeboardtile) winning move automatically gets perfect fitness potentialmoves[firstmove break don' bother calculating other moves else do other player' counter moves and determine best one if isboardfull(dupeboard) potentialmoves[firstmove else for countermove in range(boardwidth) dupeboard copy deepcopy(dupeboard if not isvalidmove(dupeboard countermove) continue makemove(dupeboard enemytilecountermove if iswinner(dupeboard enemytile) losing move automatically gets the worst fitness potentialmoves[firstmove- break email questions to the authoral@inventwithpython com