exit (1) sz = sys.argv[1] nprobs = int(sys.argv[2]) s = Server() for probi in range(nprobs): prob = s.get_training_problem(int(sz)) print prob["id"] if not os.path.exists("tests"): os.makedirs("tests") opstr1 = "_".join(prob['operators']) opstr2 = " ".join(prob['operators']) inout_file = open("tests/%02d-%s-%s.inout" % (prob['size'], opstr1, prob['id']), 'w') inout_file.write("# %s\n" % prob['challenge']) inout_file.write("%d %s\n" % (prob['size'], opstr2)) inputs = [] while len(inputs) < 256: inputs.append(random.getrandbits(64)) outputs = s.evaluate(problem = prob['id'], arguments = inputs) inouts = zip(inputs, outputs) for (i,o) in inouts: inout_file.write("%d %d\n" % (i,o))
## Some probably useful values inputs = hbv_inputs + [ 0x00000000ffffffff, 0x5555555555555555, 0xaaaaaaaaaaaaaaaa, 0x3333333333333333, 0xcccccccccccccccc, 0x0f0f0f0f0f0f0f0f, 0xf0f0f0f0f0f0f0f0, 0x00ff00ff00ff00ff, 0xff00ff00ff00ff00, 0x0000ffff0000ffff, 0xffff0000ffff0000 ] outputs = [] ############ while True: ## Alternately "evaluate" 256 inputs & "guess" a program using hbv on accumulated in/out pairs while len(inputs) < in_sent + 256: inputs.append(random.getrandbits(64)) new_outs = s.evaluate(problem = prob['id'], arguments = inputs[in_sent : in_sent+256], training = training ) outputs = outputs + new_outs inouts = zip(inputs[in_sent : in_sent+256], new_outs) in_sent = in_sent + 256 for (i,o) in inouts: inout_file.write("%d %d\n" % (i,o)) inout_file.flush() ############# myinput = open(inout_fname) myoutput = open(inout_fname + ".hbv", 'w')