def _evaluate(self, piece):
        """
        Return a score for how favourable the current board is towards piece.
        """
        state = self.winner()
        if state:
            return (1 if state == piece else 0 if state == 'T' else -1)
        scores = []
        apponent = 'OX'.replace(piece, '')
        for n in self.avail:
            self.play(n, apponent)
            scores.append(0-self._evaluate(apponent))
            self.play(n) # reverse play
        safest = min(scores)
        return safest

        Return a score for how favourable the current board is towards piece.
        
recipes/Python/578563_Tic_Tac_Toe_console_game/recipe-578563.py