Update.
[picoclvr.git] / tasks.py
index 829eb24..56c2b0f 100755 (executable)
--- a/tasks.py
+++ b/tasks.py
@@ -1874,6 +1874,7 @@ class Escape(Task):
         height,
         width,
         T,
+        nb_walls,
         logger=None,
         device=torch.device("cpu"),
     ):
@@ -1885,7 +1886,7 @@ class Escape(Task):
         self.width = width
 
         states, actions, rewards = escape.generate_episodes(
-            nb_train_samples + nb_test_samples, height, width, T
+            nb_train_samples + nb_test_samples, height, width, T, nb_walls
         )
         seq = escape.episodes2seq(states, actions, rewards, lookahead_delta=T)
         # seq = seq[:, seq.size(1) // 3 : 2 * seq.size(1) // 3]
@@ -1912,7 +1913,7 @@ class Escape(Task):
     def thinking_autoregression(
         self, n_epoch, model, result_dir, logger, deterministic_synthesis, nmax=1000
     ):
-        result = self.test_input[:100].clone()
+        result = self.test_input[:250].clone()
         t = torch.arange(result.size(1), device=result.device)[None, :]
 
         state_len = self.height * self.width
@@ -1936,9 +1937,9 @@ class Escape(Task):
         for u in tqdm.tqdm(
             range(it_len, result.size(1) - it_len + 1, it_len), desc="thinking"
         ):
-            # Put the lookahead reward to -1 for the current iteration,
-            # sample the next state
-            s = -1
+            # Put the lookahead reward to either 0 or -1 for the
+            # current iteration, sample the next state
+            s = -1  # (torch.rand(result.size(0), device = result.device) < 0.2).long()
             result[:, u - 1] = s + 1 + escape.first_lookahead_rewards_code
             ar_mask = (t >= u).long() * (t < u + state_len).long()
             ar(result, ar_mask)
@@ -1954,7 +1955,7 @@ class Escape(Task):
             for v in range(0, u, it_len):
                 # Extract the rewards
                 r = result[:, range(v + state_len + 1 + it_len, u + it_len - 1, it_len)]
-                r = r - escape.first_lookahead_rewards_code - 1
+                r = r - escape.first_rewards_code - 1
                 a = r.min(dim=1).values
                 b = r.max(dim=1).values
                 s = (a < 0).long() * a + (a >= 0).long() * b