BasketMC

Signal Pattern Detector, Episode 6: TIS-100

  • Published on

Episode 6 skips past the Simple Sandbox, which the commentary calls more of a sandbox than a puzzle, and opens Signal Pattern Detector. Basket gets a six-node program to pass, trims it, then rebuilds the whole thing in four nodes. Both versions pass by the end of the video.

Three zeros in a row

The puzzle text is short: "Read a value from IN. Look for the pattern 0,0,0. Write 1 when pattern is found. If not true, write 0 instead." The commentary looks at the expected output column and notes that each node can only hold one value. After a pause to plan, the node under IN gets the main loop: "MOV UP, ACC", "SAV", "SUB LEFT", "SUB RIGHT", then "JEZ MATCH" to send a 1 down, or "MOV 0 DOWN" and "JRO 2" to skip it. The nodes on either side hold the last two values, and "SWP", "MOV LEFT, RIGHT" and "MOV ACC, LEFT" shift them along.

The first run is right most of the way, then a few outputs turn red near the 3s in the input.

The Signal Pattern Detector screen running test 1 with the first program: the node under IN holds a list starting "START:", "MOV UP, ACC", "SAV", "SUB LEFT", "SUB RIGHT" and "JEZ MATCH", flanked by two nodes that pass values back and forth, while three entries in the output column show in red beside the expected values

Breakpoints and a head start

Basket adds a breakpoint, finds that it stops before its line runs, and steps through watching the registers. The commentary decides subtracting is the problem when the new value matches one of the stored ones, and switches both lines to ADD. "Oh, I lied." It still fails, this time on a later test whose input starts with zeros: the program counts the pattern before three zeros have actually arrived. The fix is "MOV 1, ACC" before the START label, so the stored values begin as something other than zero.

That passes in 502 cycles with 6 nodes and 23 instructions. Removing the second preload from the right-hand node still passes, at 21 instructions, one under the friend's score beside Basket's.

The Signal Pattern Detector editor with the puzzle text at top left and the six-node program: the top left node now begins "MOV 1, ACC" before its START label, and the node under IN uses "ADD LEFT" and "ADD RIGHT" ahead of "JEZ MATCH"

Four nodes

The friend's score uses only four nodes. "How would you even do that?" Basket copies the working program and starts again: a column of three nodes passes the current value and the two before it down to a fourth node, which runs "MOV LEFT ACC", "ADD LEFT", "ADD LEFT" and "JEZ MATCH". The commentary tries leaving out the commas, and the game accepts it.

The Signal Pattern Detector screen running test 1 with a four-node program in a column of three nodes and one node beside the bottom: the bottom right node holds "MOV LEFT ACC", "ADD LEFT", "ADD LEFT", "JEZ MATCH", "MOV 0 DOWN" and "JRO 2", and red entries appear near the top of the output column

The jump that will not land

This version fails too. Stepping through shows "JRO 2" landing somewhere unexpected. Changing the number does not help, and the commentary reads that command's entry from the printed manual, then gives up on it: "Alright, fine. You win." A "START:" label and "JMP START" replace the jump.

The Signal Pattern Detector screen running test 1 with the final four-node program: the bottom right node starts with "START:" and ends its check with "MOV 0 DOWN", "JMP START", "MATCH:" and "MOV 1 DOWN", and the output column fills with no red entries

Where it ends

The four-node program passes every test in 348 cycles, with 4 nodes and 20 instructions. "I still have a lot of cycle counts, but I feel good about that for now." The segment map shows Signal Pattern Detector as nominal, and the video cuts to the end card.