import random, math, sys, json
total_degrees, degrees_left, total_people, people_left = map(int, sys.argv[1:])
try#try:
# inp_f = open("./data/Eidetic.json", "r")
# out = json.load(inp_f)
except#except (IOError, ValueError):
out = {"last_cake": 0,
"runs": 0,
"total_runs": 0,
"total_rounds": 0,
"training": [[0.0], [0.0], [0.0]12903225806451613], [4[16.0]774193548387096], [400.0], [426.0]83870967741933], [720.0], [1042[995.0]8709677419355], [1042[996.3129032258064]9437634408603], [1044[997.0]6], [1044[997.0]6], [1044[997.0]6], [1044[998.9741935483871]5991397849463], [1045[996.3129032258064]6770967741936], [1051[998.3677419354838]8122580645161], [1056[1011.4022617124394]5467420570814], [1264[1017.1534733441033]7717824448034], [1378[1227.663974151858]155465805062], [1451[1280.5218093699516]7840603123318], [1473[1435.0856219709208]8028540656974], [1662[1553.069466882068]3689822294023], [1828[1793.9919224555736]5330640818527], [2671[2299.3430420711975]178101402373], [4423[3183.720064724919]924709689701], [3625[2231.3333333333335]666666666667], [2619.4789644012944], [1270.9288025889969], [741.2718446601941], [480.4757281553398], [122.66990291262135], [27.54736842105263]]}
else#else: inp_f.close()
def write_out():
out_f = open("./data/Eidetic.json", "w")
out_f.write(json.dumps(out))
out_f.close()
def get_last_winner(): # Find the bid of the last winner
bid = out["last_cake"]
return max(bid, degrees_left) - degrees_left
def train():
# print degrees_left # If you get that much, your probably safe.
# sys.stderr.write("\nEidetic - Training len %s, no runs: %s, no_rounds: %s, last winner: %s\n"%(len(out["training"]), out["runs"], out["total_rounds"], get_last_winner()))
if len(out["training"]) <= out["runs"]: out["training"].append([])
out["training"][out["runs"]].append(get_last_winner())
def get_best_round():
data = out["training"][out["runs"]+1:]
mean = [sum(i)/(float(len(i)) or 1) for i in data]
bid = max(mean+[0]) - 0.5
#syssys.stderr.write("\nEidetic - mean %s\n"%mean)
return bid
def main():
reset = total_people == people_left
if reset:
out["total_rounds"] += 1
out["runs"] = 0
train()
bid = get_best_round()
print bid
# sys.stderr.write('\nEidetic Bid: '+str(bid)+'\n')
out["total_runs"] += 1
out["runs"] += 1
out["last_cake"] = degrees_left
write_out()
main()