Exemplo n.º 1
0
def localBrute(base, best, indices):
    candidate = generateNext(list(base), indices)
    i = 0
    maxTotalScore = -1
    maxTotalScores = []
    bestScores = []
    maxCandidate = base
    #print "In local brute, base is : ",base
    while candidate != base:
        if i % 1000 == 0:
            print "i=", i
        i += 1
        candidateScores = []
        testScores = []
        for test in best:
            (rounds, score1,
             score2) = _PyPacwar.scorebattle(candidate, test[0][1])
            candidateScores += [score1]
            testScores += [score2]
        if sum(candidateScores) > maxTotalScore:
            maxTotalScores = candidateScores
            maxTotalScore = sum(maxTotalScores)
            maxCandidate = list(candidate)
            bestScores = testScores
            print candidate, maxTotalScore
        candidate = generateNext(candidate, indices)
        #print "Candidate is: ", candidate
    return maxCandidate, maxTotalScore, maxTotalScores, bestScores
Exemplo n.º 2
0
def localBrute(base,best,indices):
	candidate = generateNext(list(base),indices)
	i=0
	maxTotalScore=-1
	maxTotalScores=[]
	bestScores=[]
	maxCandidate=base
	#print "In local brute, base is : ",base
	while candidate!=base:
		if i%1000==0:
			print "i=",i
		i+=1
		candidateScores=[]
		testScores=[]
		for test in best:
			(rounds,score1,score2) = _PyPacwar.scorebattle(candidate, test[0][1])
			candidateScores+=[score1]
			testScores+=[score2]
		if sum(candidateScores)>maxTotalScore:
			maxTotalScores=candidateScores
			maxTotalScore=sum(maxTotalScores)
			maxCandidate=list(candidate)
			bestScores=testScores
			print candidate,maxTotalScore
		candidate=generateNext(candidate,indices)
		#print "Candidate is: ", candidate
	return maxCandidate,maxTotalScore,maxTotalScores,bestScores
Exemplo n.º 3
0
def battle(s1,s2):
	(rounds,score1,score2) = _PyPacwar.scorebattle(s1,s2)
	#(rounds,c1,c2)=_PyPacwar.battle(s1,s2)
	return rounds,score1,score2
Exemplo n.º 4
0
def battle(s1, s2):
    (rounds, score1, score2) = _PyPacwar.scorebattle(s1, s2)
    #(rounds,c1,c2)=_PyPacwar.battle(s1,s2)
    return rounds, score1, score2