def updateRatingsAI(self, table, setFound, the_time): '''AI was faster, so all sets involved are actually harder than we thought, ie increase their rating Please call whenever an AI finds a set ''' allSets = Deck.allSets(table) for the_set in allSets: try: self.ratingList[Deck.idOfSet(the_set)] += 50 except: self.ratingList[Deck.idOfSet(the_set)] = 1550 self.dumpData()
def updateRatingsHuman(self, table, setFound, the_time): '''updates the ratings of all sets involved in this round Please call whenever a human finds a set ''' initialRating = 1500 setFoundKey = Deck.idOfSet(setFound) try: setFoundRating = self.ratingList[setFoundKey] except KeyError: # first time this set shows up setFoundRating = initialRating losingSets = set(Deck.allSets(table)) - set(setFound) for the_set in losingSets: losingSetKey = Deck.idOfSet(the_set) try: losingSetRating = self.ratingList[losingSetKey] except KeyError: # first time this set shows up losingSetRating = initialRating newWinnerRating, newLoserRating = self.newRatings(setFoundRating, losingSetRating) self.ratingList[setFoundKey] = newWinnerRating self.ratingList[losingSetKey] = newLoserRating self.dumpData()
def get_difficulties(self, the_set): try: return self.ratingList[Deck.idOfSet(the_set)] except KeyError: return 1500