def getGuessFitnessScores(self):
        guessesAndFitness = []
        currentOptionCount = len(self.board)

        for option in getBoardAsList():
            # calculate how much a yes or no would reduce our option set, then apply the fitness function to that
            noReduction = len(
                self.stripBoardOfItemsWithAnythingInCommon(
                    option, self.board)) / currentOptionCount
            yesReduction = len(
                self.stripBoardOfItemsWithNothingInCommon(
                    option, self.board)) / currentOptionCount
            knownWrong = self.getKnownWrongAttributes(option) / 4
            yesLikelihoodFuzzy = self.getYesLikelihoodFuzzy(option) / 4

            guessesAndFitness.append({
                'cell':
                option,
                'fitness':
                self.fitnessFunc(yesReduction, noReduction, knownWrong,
                                 yesLikelihoodFuzzy),
            })
        # for guess in guessesAndFitness:
        #     print(guess)
        return guessesAndFitness
Beispiel #2
0
    def __init__(self):
        self.board = getBoardAsList()

        self.usedInAnnealing = []
        self.yes = []
        self.no = []

        # used for testing different fitness functions
        # default finds yes and no with lowest range
        # i.e. closest to .5
        # i.e. gives most balanced performance for either a yes or no answer
        self.fitnessFunc = lambda yes, no: abs(yes - no)

        # how bold we want to be -- randomly pick an answer when we have this or fewer options left
        # 1 == certainty
        self.answerAtNOptions = 1
Beispiel #3
0
    def getGuessFitnessScores(self):
        guessesAndFitness = []
        currentOptionCount = len(self.board)

        for option in getBoardAsList():
            # calculate how much a yes or no would reduce our option set, then apply the fitness function to that
            noReduction = len(
                self.stripBoardOfItemsWithAnythingInCommon(
                    option, self.board)) / currentOptionCount
            yesReduction = len(
                self.stripBoardOfItemsWithNothingInCommon(
                    option, self.board)) / currentOptionCount
            guessesAndFitness.append({
                'cell':
                option,
                'fitness':
                self.fitnessFunc(yesReduction, noReduction),
            })
        return guessesAndFitness
    def __init__(self):
        self.board = getBoardAsList()

        self.usedInAnnealing = []
        self.yes = []
        self.no = []

        # used for testing different fitness functions
        # default finds yes and no with lowest range
        # i.e. closest to .5
        # i.e. gives most balanced performance for either a yes or no answer
        self.fitnessFunc = lambda yes, no, knownWrong, knownRight: abs(
            yes - no)  # 8.6
        # self.fitnessFunc = lambda yes, no, knownWrong, knownRight: abs(yes - min(no * knownWrong, no)) # 12.13
        # self.fitnessFunc = lambda yes, no, knownWrong, knownRight: abs(yes - (no * knownWrong)) # 12.09
        # self.fitnessFunc = lambda yes, no, knownWrong, yesFuzzy: abs((yes * yesFuzzy) - (no * knownWrong)) # 9.49

        # how bold we want to be -- randomly pick an answer when we have this or fewer options left
        # 1 == certainty
        self.answerAtNOptions = 4
Beispiel #5
0
 def __init__(self):
     self.board = getBoardAsList()
     print(len(self.board))
     self.yes = []
     self.no = []