always go for corner if available for xy in possiblemoves if isoncorner(xy) return [xy if there is no cornerreturn side move for xy in possiblemoves if isonside(xy) return [xy return getcomputermove(boardtile def getsidebestmove(boardtile) return corner moveor side moveor the best move possiblemoves getvalidmoves(boardtile randomize the order of the possible moves random shuffle(possiblemoves return side moveif available for xy in possiblemoves if isonside(xy) return [xy return getcomputermove(boardtile def getworstmove(boardtile) return the move that flips the least number of tiles possiblemoves getvalidmoves(boardtile randomize the order of the possible moves random shuffle(possiblemoves go through all the possible moves and remember the best scoring move worstscore for xy in possiblemoves dupeboard getboardcopy(board makemove(dupeboardtilexy score getscoreofboard(dupeboard)[tile if score worstscore worstmove [xy worstscore score return worstmove