def next_move(self, piece):
        """
        Return the next best move for piece as cell number.
        """
        if all(map(lambda x: len(set(x)) == 1, self.board)):
            return random.choice((1, 3, 7, 9)) # Corners are best first play.
        scores = []
        avail = list(self.avail)
        for n in avail:
            node = TTTGame(self)
            node.play(n, piece)
            scores.append(node._evaluate(piece))
        best = max(enumerate(scores), key=lambda x: x[1])[0]
        return avail[best]

        Return the next best move for piece as cell number.
        
recipes/Python/578563_Tic_Tac_Toe_console_game/recipe-578563.py