import serialize_trace.deserializer as deserializer from model_reader import model_reader if len(sys.argv) != 2: print("Usage: validate_submission.py submission_directory", sys.stderr) sys.exit(1) input_directory = sys.argv[1] if not os.path.isdir(input_directory): print("Input directory \"" + input_directory + "\" does not exist.") sys.exit(1) trace_list = os.listdir(input_directory) trace_list.sort() print("Submission contains " + str(len(trace_list)) + " files.") for trace_name in trace_list: trace_path = os.path.join(input_directory, trace_name) model_path = "./data/problems/" + os.path.splitext( trace_name)[0] + "_tgt.mdl" print("Validating trace \"" + trace_path + "\", against model \"" + model_path + "\".") target_model = model_reader.read(model_path) trace = deserializer.read_trace(open(trace_path, "rb")) (state, result) = trace.validate(target_model) if result: print("Valid") else: print("Invalid")
import model_reader.model_reader as model_reader grid = model_reader.read('./data/problems/LA001_tgt.mdl') model_reader.dump_slices(grid)
from __future__ import print_function import sys import os.path import model_reader.model_reader as mdl import trace_generators.parallel_trace_generator as gen import serialize_trace.serializer as ser if len(sys.argv) < 3: print( "Usage: make_parallel_trace.py some.mdl some.nbt [-f] [--lockstep] [--sort-tiers]", file=sys.stderr) sys.exit(1) lockstep = "--lockstep" in sys.argv sort_tiers = "--sort-tiers" in sys.argv overwrite = "-f" in sys.argv if os.path.exists(sys.argv[2]) and not overwrite: print("%s already exists" % sys.argv[2], file=sys.stderr) sys.exit(1) model = mdl.read(sys.argv[1]) trace = gen.build_parallel_trace(model, lockstep, sort_tiers) with open(sys.argv[2], "w") as f: ser.serialize(trace, f)
print("Usage: validate_destruction_submission.py submission_directory", sys.stderr) sys.exit(1) input_directory = sys.argv[1] if not os.path.isdir(input_directory): print("Input directory \"" + input_directory + "\" does not exist.") sys.exit(1) trace_list = os.listdir(input_directory) trace_list.sort() print("Submission contains " + str(len(trace_list)) + " files.") for trace_name in trace_list: trace_path = os.path.join(input_directory, trace_name) model_path1 = "./data/problems/" + os.path.splitext( trace_name)[0] + "_src.mdl" model_path2 = "./data/problems/" + os.path.splitext( trace_name)[0] + "_tgt.mdl" print("Validating trace \"" + trace_path + "\", against model \"" + model_path1 + "\" and model \"" + model_path2 + "\".") source_model = model_reader.read(model_path1) target_model = model_reader.read(model_path2) trace = deserializer.read_trace(open(trace_path, "rb")) (state, result) = trace.validate(target_model, source_model) if result: print("Valid") else: print("Invalid")
import model_reader.model_reader as model_reader from serialize_trace import deserializer target_model = model_reader.read('./data/problems/LA001_tgt.mdl') trace = deserializer.read_trace(open('./data/LA001_parallel.nbt', "rb")) (state, result) = trace.validate(target_model) print(result) model_reader.dump_slices(state.current_model)
from model_reader import model_reader if len(sys.argv) != 2: print("Usage: validate_destruction_submission.py submission_directory", sys.stderr) sys.exit(1) input_directory = sys.argv[1] if not os.path.isdir(input_directory): print("Input directory \"" + input_directory + "\" does not exist.") sys.exit(1) trace_list = os.listdir(input_directory) trace_list.sort() print("Submission contains " + str(len(trace_list)) + " files.") for trace_name in trace_list: trace_path = os.path.join(input_directory, trace_name) model_path = "./data/problems/" + os.path.splitext( trace_name)[0] + "_src.mdl" print("Validating trace \"" + trace_path + "\", against model \"" + model_path + "\".") source_model = model_reader.read(model_path) trace = deserializer.read_trace(open(trace_path, "rb")) (state, result) = trace.validate(None, source_model) if result: print("Valid") else: print("Invalid")
import os.path import model_reader.model_reader as mdl import trace_generators.inverse_boring_dissassemble_trace_generator as dis_gen import trace_generators.inverse_boring_trace_generator as ass_gen import serialize_trace.serializer as ser if len(sys.argv) < 4: print( "Usage: make_inverse_boring_reassemble_trace.py source.mdl target.mdl some.nbt [-f]", file=sys.stderr) sys.exit(1) if (len(sys.argv) >= 5 and sys.argv[4] != '-f') and os.path.exists( sys.argv[3]): print("%s already exists" % sys.argv[3], file=sys.stderr) sys.exit(1) source_model = mdl.read(sys.argv[1]) target_model = mdl.read(sys.argv[2]) disassemble_trace = dis_gen.build_inverse_dissassemble_boring_trace( source_model) assemble_trace = ass_gen.build_inverse_boring_trace(target_model) disassemble_trace.instructions.pop() # Remove halt with open(sys.argv[3], "w") as f: ser.serialize(disassemble_trace, f) ser.serialize(assemble_trace, f)