CONTESTANTS!!!
def makestrat(mindo = 0, maxtake = float('inf'), minval = 0):
def strat(send, recv, minval):
if recv > maxtake:
return 2
elif mindo > send:
return 1
elif minval > val:
return 1
else:
return 0
return strat
def lincom(objlst):
results = []
for o, n in objlst:
results.extend([copy.deepcopy(o) for x in xrange(n)])
return results
fixstrat = lambda s: (lambda x, y, z: s)
hunter = Obj([.1,.1],[.05,.05],4.0,2.0, makestrat(maxtake = 1.0), 'D', 'hunter')
boulder = Obj([0.1,0.1],[1.0,1.0],1.0,10.0, fixstrat(1), 'D', 'boulder')
needle = Obj([.1,.1],[0.01,0.01],0.5,1.0, fixstrat(0), 'D', 'needle')
DAR = lincom([(hunter,12),(boulder,10),(needle,2200)])
Coy0 = Obj([0.3,0.3],[0.3,0.0], 1.15, 3.0, makestrat(0.5, 1.5), 'K', 'Coy*')
Coy1 = Obj([0.3,0.3],[0.0,0.3], 1.15, 3.0, makestrat(0.5, 1.5), 'K', 'Coy~')
Robe0 = Obj([0.3,0.3],[4.0,0.0], 1.5, 5.0, makestrat(0.5, 1.0, 10.), 'K', 'Robe*')
Robe1 = Obj([0.3,0.3],[0.0,4.0], 1.5, 5.0, makestrat(0.5, 1.0, 10.), 'K', 'Robe~')
KOM = lincom([(Coy0,115),(Coy1,115),(Robe0,8),(Robe1,8)])
best = Obj([1.6, 1.6],[0.1,8.2],1.6, 80.2, lambda x, y, z: random.randint(0,2), 'Z', 'best')
BLO = lincom([(best,1)])
lawn = Obj([1.11,1.11],[5.89,6.11], 2.11, 50.11, fixstrat(0), 'F', 'lawn')
FIA = lincom([(lawn,1)])
boner = Obj([3.,1.],[2.,2.],6.,7.,fixstrat(0), 'T', 'boner')
tuto = Obj([0.,4.],[1.,1.],7.,15.,fixstrat(0), 'T', 'tuto')
TUO = lincom([(boner,3),(tuto,1)])
pain = Obj([0.,0.],[0.,0.],0.,3.03, fixstrat(0), 'B', 'pain')
sword = Obj([0.,0.],[0.,0.],1.02, 5.02, makestrat(maxtake = 2.5), 'B', 'sword')
sebwar = Obj([1.,1.],[2.,2.],5.1, 30.2, makestrat(maxtake = 4.89), 'B', 'sebwar')
BLA = lincom([(sebwar,2),(sword,150),(pain,434)])
def checkcost(objs):
return sum((o.getcost() for o in objs))
assert checkcost(KOM) < 1000
assert checkcost(TUO) < 1000
assert checkcost(DAR) < 1200
assert checkcost(FIA) < 1000
assert checkcost(BLA) < 1000
assert checkcost(BLO) < 1000
allobjs = KOM+TUO+DAR+FIA+BLA+BLO
refset = {o.id:copy.deepcopy(o) for o in set(allobjs)}