def think(self, board):
        '''Return best possible move for a given situation.'''
        ### Query Board for Information ###
        while True:
            report = board.fieldReport()
            totalDoubles = board.returnDoubles(report)
            oDoubles = {key:totalDoubles[key] for key in totalDoubles if 'O' in totalDoubles[key]}
            xDoubles = {key:totalDoubles[key] for key in totalDoubles if 'X' in totalDoubles[key]}
            pool = board.blankSpaces()
            if pool == []:
                return

            ### Check for Winning Counters ###
            counterMove = self.counter(xDoubles)
            if counterMove['counter']:
                self.lastMove = counterMove['entry']
                return counterMove['entry']

            ### Check for Losing Counters ###
            counterMove = self.counter(oDoubles)
            if counterMove['counter']:
                self.lastMove = counterMove['entry']
                return counterMove['entry']
            
            ### Check for Trapping Moves ###
            trapMove = self.trapSimulation(board, report, pool)
            if trapMove['trap']:
                self.lastMove = trapMove['entry']
                return trapMove['entry']

            ### Strategize ###
            if self.strategy == '':
                if len(board.blankSpaces()) == 9:
                    self.strategy = 'offensive'
                else:
                    self.strategy = 'defensive'

            if self.tactic == '':
                self.decideTactic(board)

            if self.strategy == 'offensive':
                offenseMove = self.offensiveStrategy(board)
                if offenseMove['offensive']:
                    self.lastMove = offenseMove['entry']
                    return offenseMove['entry']
            else:
                defenseMove = self.defensiveStrategy(board)
                if defenseMove['defense']:
                    self.lastMove = defenseMove['entry']
                    return defenseMove['entry']

            ### Random Guess ###
            if self.reiterate:
                self.reiterate = False
            else:
                debug(d,'Random Entry')
                entry = random.choice(pool)
                self.lastMove = entry
                return entry
Return best possible move for a given situation.
recipes/Python/580723_TicTacToe_text_based/recipe-580723.py