X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=rpl.py;h=7e865a56556110b36e871a75451c72708807e45a;hb=439c597d409c344283f8996f042daf79d3f24de2;hp=7f7dcfc247e72d5e5592e4933e6b9febb77bb61b;hpb=5703df4c32a0856c8fa4b1ff97810cdc1fb76253;p=picoclvr.git
diff --git a/rpl.py b/rpl.py
index 7f7dcfc..7e865a5 100755
--- a/rpl.py
+++ b/rpl.py
@@ -55,16 +55,26 @@ rpl_ops = ["add", "min", "max", "swp", "rep", "dup", "del"]
def generate(nb_starting_values=3, max_input=9, prog_len=6, nb_runs=5):
prog_len = (1 + torch.randint(2 * prog_len, (1,))).clamp(max=prog_len).item()
- prog = [rpl_ops[k] for k in torch.randint(len(rpl_ops), (prog_len,))]
- result = []
- for _ in range(nb_runs):
- stack = [x.item() for x in torch.randint(max_input + 1, (nb_starting_values,))]
- result_stack = rpl_exec(prog, stack)
- result = result + [""] + stack + ["