Monday, May 23, 2011

Not the Chemistry I Remember (continued)

My previous attempts at the SpaceChem level Best Left Unanswered left me with an above average result compared to the rest of the SpaceChem players. But I was determined to do even better. The level was simple: nitrogen atoms input, output nitrogen molecules (N2 with a triple bond).

I saw that the best times (measured in cycles) were about twice as fast as mine. There must be something I was missing. And like much of SpaceChem, when I figured it out, it seemed so obvious. Clearly, to get a time that was twice as fast I needed to move two atoms at a time instead of one.

Like the previous attempt, to get the fastest time we'd use a straight line instead of a circuit. Each waldo would be responsible for assembling a nitrogen molecule and moving it across to the output. The two waldos would have to share the responsibility for bonding, inputting atoms and outputting molecules since we'd need to, for example, input a second nitrogen atom in the same cycle as bonding the first to it. To figure out the required placement of instructions we draw up a table and start filling in instructions.

We want red to drop its molecule last so that blue can output in the same cycle (red's instructions are carried out before blue's), so we have blue start building the first molecule on cycle 1.

CycleBlueRed
1Grab
2
3
4
5
6
7Drop
8
9
10
11
12

We then have to input the next atom and triple bond the molecule simultaneously, so constraining our options somewhat in cycles 2-4. Note that since red's instruction is run first, it has to run the in instruction before blue runs the bond+ instruction to ensure the atoms bond.

CycleBlueRed
1Grab
2Bond+In
3Bond+
4Bond+
5
6
7Drop
8
9
10
11
12

Red can't start building its molecule in cycles 3 or 4 because it leads to problems scheduling the in instructions. So the earliest we can start red's construction is in cycle 5.

Red's molecule also has to be assembled with an in instruction from red and three bond+ instructions, one of which must be run by red when blue is running its drop instruction.

CycleBlueRed
1Grab
2Bond+In
3Bond+
4Bond+
5Grab
6Bond+In
7DropBond+
8Bond+
9
10
11OutDrop
12

Now because our waldos are following a back and forth route on a straight line, each waldo's instructions will be mirrored around their grab and drop instructions. Here blue's bond+ instruction in cycle 2 is already mirrored in cycle 6, however the out instruction in cycle 11 must be repeated in cycle 3. This forces red to do a bond+ in that cycle which is already mirrored in cycle 7. Red's in instruction in cycle 6 must be repeated in cycle 4. This forces blue to do a bond+ in that cycle which must be mirrored in cycle 10.

CycleBlueRed
1Grab
2Bond+In
3OutBond+
4Bond+In
5Grab
6Bond+In
7DropBond+
8Bond+
9
10Bond+
11OutDrop
12

In addition, looking at cycle 2, blue's bond+ instruction must be repeated in cycle 12 and red's in instruction must be repeated in cycle 8. This forces blue to do a bond+ in cycle 8 which is already mirrored in cycle 6.

CycleBlueRed
1Grab
2Bond+In
3OutBond+
4Bond+In
5Grab
6Bond+In
7DropBond+
8Bond+In
9
10Bond+
11OutDrop
12Bond+

Only thing missing now is an out instruction for blue's molecule dropped in cycle 7. We have to do this in cycle 9 else there will be a clash of molecules. It doesn't matter who runs this instruction so we give it to red. This out is mirrored in cycle 1.

CycleBlueRed
1GrabOut
2Bond+In
3OutBond+
4Bond+In
5Grab
6Bond+In
7DropBond+
8Bond+In
9Out
10Bond+
11OutDrop
12Bond+

The two instruction lines are:
  • Blue: grab, bond+, out, bond+, -, bond+, drop
  • Red: grab, in, bond+, in, out, -, drop

There isn't space to position the waldo starts where we'd like on the paths, but we can position them off at an angle to run just the instructions we need to get started. The completed setup is below.


"Best Left Unanswered" - best attempt

This reactor outputs 10 nitrogen molecules in just 59 cycles, less than half our previous attempt and snagging a spot in the top bar on the histogram.

No comments:

Post a Comment