示例#1
0
def democracy(POP, time, LED, strat):
	votes = 0
	dense_factor = 1/25
	board = indv_density(map(lambda x: x[1], filter(lambda x: x[0],LED)),time)
	tot = 0
	for S in POP:
		f = genetic.fitness(S, strat, time)
		tot = tot+f
		k = "no"
		n = indv_density(genetic.expand(S,time),time)
		if n - board> dense_factor:
			k = "yes"
			votes = votes+f
		#print "{} \nround {}.\nvoted:  {}  score:{}\n\n".format(S,time,k,n)
	print "votes: {}".format(votes)#,  board density: {}\nLedger: {}".format(votes, board, LED)
	return float(votes) / tot
示例#2
0
def group_density(POP, time):
	n = 0
	for S in POP:
		n = n + indv_density(genetic.expand(S,time), time)
	return n