# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1464563101 14400 # Node ID 305b7361a5bd7094f7dc672cc9981462aaf6a3a2 # Parent f81a65086498ca94eeb70a482fcb53abb6cb44e2 showalgo: save a snapshot instead of waiting for keyboard input diff --git a/talk/code/showalgo.m b/talk/code/showalgo.m --- a/talk/code/showalgo.m +++ b/talk/code/showalgo.m @@ -20,7 +20,14 @@ graphics_toolkit fltk; figure -pause + + +function snapshot() + persistent x = 1; + fname = sprintf("%02d.png", x); + print("-dpng", fname); + x++; +endfunction for iter = 1:length(Am) if iter > rows(L) @@ -42,7 +49,7 @@ printf("Remaining: %d\n", remaining(iter)) imshow(imgH); - pause + snapshot; ## Make the guess yellow [i,j] = find(Am(iter) == H); @@ -50,7 +57,7 @@ imgH(i,j,3) = 0; imshow(imgH); - pause + snapshot; if iter == length(Am) break @@ -80,7 +87,7 @@ imgH(i,j,3) = 0; imshow(imgLeft); - pause + snapshot; ## Check the right side imgRight = imgH; @@ -105,16 +112,16 @@ imgH(i,j,1) = imgH(i,j,2) = 1; imgH(i,j,3) = 0; imshow(imgRight); - pause + snapshot; imshow(imgH); printf("rank is between %d and %d (target: %d)\n", Ptot(iter), Qtot(iter), medc_idx) - pause + snapshot; endfor if (jackpot) printf("Jackpot!\n") endif -pause +snapshot;