From: Ian Jackson Date: Fri, 20 Nov 2020 22:38:00 +0000 (+0000) Subject: wip lowering X-Git-Tag: otter-0.2.0~459 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=68f3183b789ebb824f48eb85530d8eeeb11373f0;p=otter.git wip lowering Signed-off-by: Ian Jackson --- diff --git a/src/cmdlistener.rs b/src/cmdlistener.rs index 0cff517b..47233f20 100644 --- a/src/cmdlistener.rs +++ b/src/cmdlistener.rs @@ -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(()))); diff --git a/templates/script.ts b/templates/script.ts index 0aeb43ef..e3db1f89 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -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 =