X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=rpl.py;h=7f7dcfc247e72d5e5592e4933e6b9febb77bb61b;hb=5703df4c32a0856c8fa4b1ff97810cdc1fb76253;hp=155bc69cc76b4b88a3bd05c75cb2ce977e762df9;hpb=0c47d4d8ef8c4938f4765af816349cf30da14cb1;p=culture.git
diff --git a/rpl.py b/rpl.py
index 155bc69..7f7dcfc 100755
--- a/rpl.py
+++ b/rpl.py
@@ -53,13 +53,13 @@ rpl_ops = ["add", "min", "max", "swp", "rep", "dup", "del"]
######################################################################
-def generate(nb_values=3, max_input=9, prog_len=6, nb_runs=5):
- prog_len = 1 + torch.randint(prog_len - 1, (1,)).item()
+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_values,))]
+ stack = [x.item() for x in torch.randint(max_input + 1, (nb_starting_values,))]
result_stack = rpl_exec(prog, stack)
result = result + [""] + stack + ["