chiark / gitweb /
wip lowering
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 20 Nov 2020 22:38:00 +0000 (22:38 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 20 Nov 2020 22:38:00 +0000 (22:38 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/cmdlistener.rs
templates/script.ts

index 0cff517b00e41663d904e1f186a0057b4345c03d..47233f20971c61240c73b5ba035ebffc4ca3e86d 100644 (file)
@@ -477,6 +477,7 @@ fn execute_game_insn<'cs, 'igr, 'ig : 'igr>(
         if let (_, true) = pc.pos.clamped(gs.table_size) {
           throw!(SpecError::PosOffTable);
         }
+        if pc.zlevel.z > gs.max_z { gs.max_z = pc.zlevel.z.clone() }
         let piece = gs.pieces.as_mut(modperm).insert(pc);
         ig.ipieces.as_mut(modperm).insert(piece, p);
         updates.push((piece, PieceUpdateOp::Insert(())));
index 0aeb43efe1842cc14cffc6dfc0b0775dd2453079..e3db1f89a198f994ec20eac079b378690b2d282a 100644 (file)
@@ -433,7 +433,18 @@ function lower_pieces(targets_todo: LowerTodoList):
 
   let walk = pieces_marker;
   for (;;) { // starting at the bottom of the stack order
-    if (Object.keys(targets_todo).length == 0) break;
+    if (n_targets_todo_unpinned == 0
+       && bottommost_unpinned !== null) {
+      // no unpinned targets left, state Z, we can stop now
+      console.log('LOWER STATE Z FINISHED');
+      break;
+    }
+    if (Object.keys(targets_todo).length == 0 &&
+       bottommost_unpinned !== null) {
+      console.log('NO TARGETS BUT UNPINNED !=0', n_targets_todo_unpinned);
+      break;
+    }
+
     let new_walk = walk.nextElementSibling;
     if (new_walk == null) break;
     walk = new_walk as SVGGraphicsElement;
@@ -441,29 +452,30 @@ function lower_pieces(targets_todo: LowerTodoList):
 
     let todo = targets_todo[piece];
     if (todo) {
+      console.log('LOWER WALK', piece, 'TODO', todo.pinned);
       delete targets_todo[piece];
       if (!todo.pinned) n_targets_todo_unpinned--;
       (todo.pinned ? tomove_pinned : tomove_unpinned).push(todo);
       continue;
     }
 
-    if (n_targets_todo_unpinned == 0) // only pinned targets left, state Z
-      continue;
-
     let p = pieces[piece]!;
     if (bottommost_unpinned = null) { // state A
       if (!p.pinned) {
-       // state A -> Z
+       console.log('LOWER WALK', piece, 'STATE A -> Z');
        bottommost_unpinned = { p, piece };
       } else {
+       console.log('LOWER WALK', piece, 'STATE A');
        nomove_pinned.push({ p, piece });
       }
       continue;
     }
 
     // state B
-    if (p.pinned)
+    if (p.pinned) {
+      console.log('LOWER WALK', piece, 'STATE B');
       tomove_misstacked.push({ p, piece });
+    }
   }
 
   let z_top =