SpaceCells - Solution

Written by Brian Shimanuki

Answer: HISTOGRAMS

This puzzle consists of a series of assignments, for each of which the player can design a system of cells and instructions to produce the intended outputs. There are a total of 12 assignments, with the later assignments being unlocked by solving previous ones. The assignments target a number of constructs, from information flow to basic logic gates to a full adder. See the Appendix for example solutions and guidelines for solving each assignment.

In each assignment, the player places cells and instructions on a 10x10 grid. The background of these grids can be separated into gray tiles and brown tiles, and each grid has one special brown tile. These are purely cosmetic to the actual assignment, and are part of the extraction. The brown tiles in each grid uniquely identify a part of the periodic table. This becomes more obvious in later assignments, and reaching the Epilogue also hints towards looking for elements of the periodic table. (Solvers who recognize that this puzzle is themed after SpaceChem may also notice the thematicness of using chemical elements for the extraction.) Taking the special element designated from each grid yields KINdOFSTaTsCHArTs.

H
10
He
Li
Be
B
C
9
N
O
4
F
5
Ne
Na
Mg
Al
Si
P
S
6
Cl
Ar
11
K
1
Ca
Sc
Ti
V
Cr
Mn
Fe
Co
Ni
Cu
Zn
Ga
Ge
As
Se
Br
Kr
Rb
Sr
Y
Zr
Nb
Mo
Tc
Ru
Rh
Pd
Ag
Cd
In
Sn
Sb
Te
I
2
Xe
Cs
Ba
Hf
Ta
7
W
Re
Os
Ir
Pt
Au
Hg
Tl
Pb
Bi
Po
At
Rn
Fr
Ra
Rf
Db
Sg
Bh
Hs
Mt
Ds
Rg
Cn
Nh
Fl
Mc
Lv
Ts
8,12
Og
La
Ce
Pr
Nd
3
Pm
Sm
Eu
Gd
Tb
Dy
Ho
Er
Tm
Yb
Lu
Ac
Th
Pa
U
Np
Pu
Am
Cm
Bk
Cf
Es
Fm
Md
No
Lr

This is a cluephrase for the “kind of stats charts” displayed after each completed assignment in this puzzle (as well as in Zachtronics games), or HISTOGRAMS.

Author's Notes

SpaceCells was inspired by Zachtronics games, most notably SpaceChem and SHENZHEN I/O. This knowledge was not necessary for solving the puzzle, but some of the concepts and mechanics are similar.

The physics of the cells came from Quantum Dot Automata, with the caveat that diodes are used as a replacement for the clocking mechanism and the interaction model was simplified to make simulation fast.

I hope this mix of mechanics came out to something unique and interesting. The stats page showed statistics of actual submissions during the hunt, and I know there were solvers who continued to improve their solutions after they finished the puzzle!

This puzzle was mostly done in 5 weeks, and took me around 200 hours to design and implement (possibly largely because this was my first experience using React, or really webdev in general). I wrote the simulation engine in C++ and compiled that to both WebAssembly and a Python library, which worked nicely for being able to run the same performant code in browser clients and on the server.

Fun fact: I first decided to write a SpaceChem puzzle, and then I decided to start SpaceChem. Before this, I had only played EXAPUNKS and SHENZHEN I/O.

Appendix

In this module, you can see and run an example solution for each assignment. Below it, we describe some general approaches to each assignment.

Assignment 1: Inversion
Goal:

Turn the output (on the right) green when the input (on the left) is blue and blue when the input is green.

This is the first assignment, whose purpose was to familiarize solvers with the basic interactions between cells. cells that are 1 or 2 away in the same horizontal or vertical line are become the same polarity and ones that are diagonal or a knight's move away become the opposite polarity. This assignment can be solved by stringing together a path of cells which crosses diagonally once.

Assignment 2: X Crossing
Goal:

Propagate the top input to the bottom output and the bottom input to the top output.

We have 2 inputs and 2 outputs. We want to direct the input to the output and the input to the output . Fortunately, and do not interact with each other, so we can string along a series of each from one side to the other, hopping over each other as they cross. This is the first assignment with cells, and we learn that the polarity interactions are reverse that of cells. The circuit analog of this assignment is wire crossings.

Assignment 3: Unity
Goal:

Given two inputs, output blue if they are both blue and green otherwise.

If we designate blue as 1 and green as 0, this assignment is to construct an AND gate. The note in the preface to the instructions gives an interesting schematic, which turns out to be a majority (MAJ) gate (with 3 inputs). The AND gate can be constructed by hooking up the 2 given inputs and a green cell to a MAJ gate.

Assignment 4: Memories
Goal:

Output blue on the first step. For all other steps, output the color of the previous input.

We get to the first assignment that utilizes the bots beyond just advancing the input and output. There are multiple ways to complete this assignment.

One way is to use the two bots to alternate and carry the value of the previous input to the output while the other bot goes back to get the value of the current input.

The more efficient method is to use RESET to latch a pair of locked cells in sequence which hold the current and previous input values. This is what the example solution does.

Assignment 5: Power It Up
Goal:

Switch the output between blue and red whenever the input is blue. The output should start as blue (unless the first input is blue).

This is the first assignment that uses two outputs. Colors are additive, and so because we want to output blue or red, we must toggle the powers to the output cells when the input is blue. We utilize the BRANCH instructions to determine when to use the power instructions. Beyond that, when each output is active, it always outputs the same color so we can just keep a locked cell next to the output.

Assignment 6: Differences
Goal:

Given two inputs, output green if they are the same or blue if they are different.

If we designate blue as 1 and green as 0, this assignment is to construct the XOR gate.

One simple way to construct this is to use a bot to branch and perform casework based on the values of the two inputs. (See the example solution to Assignment 12 for an example that does this as part of a more complex system.)

The example solutions solves the problem using just the cells by constructing the XOR as (A AND NOT B) OR (NOT A AND B). We know how to do inversion from the first assignment, and an OR can be constructed using a MAJ gate just like AND but using a blue cell as the third input instead of green.

Assignment 7: Storage Unit
Goal:

You have a blue/green input and a red/orange input. You should output the color of the top input the previous time the bottom input was that color. The first time red is input and the first time orange is input, you should output blue.

This assignment is somewhat similar to Assignment 4, but now we have to mux between two memory units depending on what the bottom input is. The example solution uses the red bot to reset the correct memory cell and the blue bot to propagate the old value of that memory cell to the output.

Assignment 8: Wheel of Fortune
Goal:

The wheel starts with the blue circle activated. The wheel turns clockwise on a blue input and counterclockwise on a green input. Output the new active color.

We want to determine whether the sequence of clockwise and counterclockwise rotations ends with the blue color on bottom. There are a variety of approaches that can be taken here, but the most intuitive is to move three locked cells around depending on the color of the input. In the example solution, this is done using red bot when needing to rotate clockwise and the blue bot when needing to rotate counterclockwise.

Assignment 9: Colors of the Rainbow
Goal:

No inputs. Output red, orange, yellow, green, blue, and purple in order and repeat.

This assignment is more about utilizing the addition of colors and cycling through states than needing to branch or perform computations. It is perhaps the most straightforward of the later assignments. The primary considerations are determining when each output needs to be powered and setting up the states so that the colors work out. Color mixing appeared in Assignment 2, but solvers did not have to care about how the combinations worked until now.

In terms of the color addition, combinations work in the following way. (N represents brown as all the other letters in BROWN are already taken.)

B + R = P
B + O = W
G + R = Y
G + O = N
Assignment 10: Median Filter
Goal:

Given one sequential input, output the majority of the past 3 inputs. The first 3 inputs will be blue.

We know how to delay inputs, and we know how to compute the majority. To complete this assignment, we stagger memory units similar to Assignment 4 and Assignment 7, and combine them with a MAJ gate.

Assignment 11: Vending Machine
Goal:

You are running the display for vending machine. The input is blue when a user tries to insert a coin and green when trying to remove one. The output should indicate the number of coins: green for 0, blue for 1, and orange for 2. If a user attempts to remove a coin when there are 0 or add one when there are already 2, the count does not change and you should output a red warning light.

The last two assignments are the most difficult. This one requires keeping track of which of 3 states the vending machine is in (0, 1, or 2 coins). This can be tracked by cell polarities or by the position of the bots. The example solution encodes state using the position of the red bot. From each state, the bots need to toggle the appropriate PWR instructions, set the colors, and potentially move to a different state depending on the input.

Assignment 12: Quick Maths
Goal:

Given two sequential inputs, let green represent a 0 bit and blue represent a 1 bit. The inputs are given from low bit to high bit. Output the corresponding color for the addition of these numbers in base 2.

The last assignment makes players implement a 1-bit full adder. This involves keep track of the carry bit between inputs, and performing a 3-way XOR of the 2 input bits and the carry bit.

It is possible but very difficult to use cells for all of the logic and the bots just to latch the state of the carry bit.

A simpler solution is to use bot movement and branching to compute the XOR and use a MAJ gate for the carry. Notice that the carry bit is simply the majority of the previous carry bit and the input bits. In the example solution, the red bot branches off the values of the input and carry bits to compute the XOR and the blue bot latches the state of the carry bit between inputs.