Example #1
0
def generate_new_round(dframeList, currentBand, this_round, handicap = False):
    dframe = dframeList[currentBand]
    sortedFrame = ppGetMMS.sort_by_mms(dframeList, currentBand, False, handicap)
    oppset = {}
    for i,item in sortedFrame['history'].iteritems():
        os=set()
        if (item!=""):
            for opp in item.split(";"):
                if (opp.lower() != 'bye'):
                    os.add(int(opp[1:-1]))
        oppset[sortedFrame['id'][i]] = os

    finalPairing = {}
    currentIndex = []
    currentSet = set()
    finalList = []
    if (this_round == 0): #special treatment for the very first round for performance consideration
        first_pairing = get_foldpairing(len(sortedFrame))
        finalList.append((0, first_pairing))
    else:
        totalCount = [0]
        get_mutation(sortedFrame, 0, finalPairing, currentIndex, currentSet, oppset, totalCount)
        topPairings = sorted(finalPairing.iteritems())[0]
        random.shuffle(topPairings[1])
        for item in topPairings[1]:
            finalList.append((topPairings[0], item))

    return finalList, sortedFrame
Example #2
0
            for i in range(0, len(dfRound)-1):
                finalPairing, sortedFrame = ppGenRound.generate_new_round(dfRound, i,  r, handicapInfo[i])
                allPairing.append(finalPairing)
                allSortedFrame.append(sortedFrame)

            for i in range(0, len(dfRound)-1):
                finalPairing = allPairing[i]
                resTable = ppIO.print_pairing(finalPairing[0][1], allSortedFrame[i], handicapInfo[i])
                result = gen_winner(resTable)
                allResults.append(result)
            print "Round " + str(r+1) + " results:"
            for item in allResults:
                print item

            for i in range(0, len(dfRound)-1):
                sortedFrame = allSortedFrame[i]
                result = allResults[i]
                dfRound[i] = ppUpdateRound.update_round(sortedFrame, result)
                dfRound[i] = ppGetMMS.sort_by_mms(dfRound, i, dropAux=False, handicap=handicapInfo[i])
                allStanding.append(dfRound[i].copy())
            print "Round " + str(r+1) + " standing:"
            for item in allStanding:
                print item

            for i in range(0, len(dfRound)-1):
                dfRound[i].drop(['mms','soms','sodms'],1,inplace=True)

            print "\n"