One of the great things about SpaceChem is that you're completely free in the approach to a solution, so you can let your creativity run wild. At the same time, one of the worst things about Spacechem is that you're completely free in the approach to a solution, so you have to let your creativity run wild. This means that, at first, you might have no idea where to start. And even if you do, the solution you come up with might be, well, let's be generous and say‘not exactly brilliant’. For that reason, I'd like to show a few common patterns that can serve as starting points for efficient solutions.
For this, I will use the assignment shown in SpaceChem's introduction video, where you use hydrogen (α) and oxygen (β) to create water (ω). This is ideal for two reasons. First, like any good introduction video, it shows the building process and what happens when a command is activated, so you should have some idea of how things work in this game. Second, it's also actually a terribly inefficient solution, so we can try to optimize it :).
I would classify this as an beginner-intermediate level tutorial. I expect you to understand at least the basics of the game: how waldos move, what the different instruction symbols mean, what bonders do, and that by activating the right symbols at the right time and space (I'm not talking about what that right sequence is, just the principle of the thing) you can solve a mission.
In other words, I expect you to understand the video linked to above.
2 Varying solutions for water
2.1 Ground rules
Before we go into the actual solutions, here are a few notes on nomenclature. Note that as far as I know, there is no standard nomenclature for elements and patterns. What I'm using here is mostly based on terms I've found on the web and my own terms. If you think you know of terms that better suit the situation or are more common, please say so.
- A reactor is basically a 10×8 matrix with two 4×4 input zones on the left called α and β, and two 4×4 output zones on the right called ψ and ω.
- I will refer to a specific cell on the grid using Excel's cell-referencing. That is, the top-left cell is (a1), and the bottom-right is (j8). Sometimes it's also useful to name a cell by its relation within an input or output zone. For example, cell (a5) is also the top-left cell in β, so it may also be referred to as (β:a1).
- A reactor is essentially a dual-threaded computer. The red and blue paths are essentially scripts of commands. The big red/blue circles running around are the instruction pointers called waldos. The smaller red/blue circles with text are symbols. If a waldo runs into a symbol, the command belonging to that symbol is executed. The gray elements in the background are reactor features. Interesting things happen when atoms are over a feature at the same time as a waldo executes the right command. A specific feature instance is also referred to as a plate.
There are also a few ground rules and tips that you need to be aware of before even starting.
- All elements in a reactor can be moved. Not only the symbols you've placed yourself, but also the start symbols and the reactor feature plates.
- All symbols have a right-click menu for more options. For instance, the start-symbols can get a different starting direction. You can also switch colors of each symbol (including inputs and outputs), or switch between similar types of commands (again, like α ↔ β or ψ ↔ ω). DO NOT FORGET THIS!!! Check the right-click menu for each symbol to learn its variations.
- Each command has a keyboard shortcut, and many of the standard mouse/keyboard UI commands apply. Ctrl+Z/+Y undo and redo and Del deletes. You can drag-select, a Shift+click does multi-select and Ctrl+drag copies symbols. Just toy around a bit to see what else is possible.
- There is no true simultaneous command execution. When red and blue perform a command at the 'same' time, red will execute first. We'll see how this can be used to our benefit. (There is also a certain order in which the bonders are executed, but how it works exactly is currently unknown.)
- The input molecules will appear exactly as shown on the input. Or, in case it comes from another reactor's output, exactly as it was outputted there.
- The output molecules do not need to match the target molecule's position or orientation. As long as all the correct bonds are in place, it will be accepted.
- A feature activator-symbol does not have to be placed on top of the feature plate. For example, you can activate the bonders when the waldo isn't anywhere near the plates. Also, you don't have to drop an atom to bond or unbond it.
The thing about the items listed above is that they're not all that obvious from playing the game (although some do appear in the trainings). A more extensive list can be found at reddit: tips_and_tricks_for_new_players.
Annnnnd … oh yeah! If you want to play along with these solutions, you'll have to create it in researchNet, because there's no actual assignment for it. Or you can also use the following code:
Technically, ResearchNet only opens up once you solved mission 7-1, but for those who would benefit the most from this exercise, that's probably a long way away. No matter, you can also just hack it. I don't think there are any adverse consequences. You can find an ‘Import’ button under ‘Create or Import an Assignment’.
Here is a list of the solutions we'll be looking at. There's the original, of course, and a version where the circuits are compressed as much as possible. There's a single-loop version for least-symbols, and one where both waldos do that loop to optimize for speed. Finally, a solution where the paths are just single lines, which if available decreases the number of symbols and can be quick to boot.
- 2.3 Original: base solution
- 2.4 Cycle optimization: tight loop
- 2.5 Symbol optimization: single loop / parked waldo waldo
- 2.6 Cycle optimization: parallel execution / twin loop
- 2.7 Symbol optimization: bouncers
I've also made an instructional video, so that you can view the following solutions in action. It's much easier to see what a solution is doing if you can follow the waldos over time.
2.3 Original : base solution
With that out of the way, let's begin. Fig 1 is a picture of the solution in the intro video (click to get a blowout). This is our base solution. the first thing you should notice is that both red and blue paths are closed. This is important, because we need to make more than one H2O, so we need to loop back to the beginning of the routine again. Also note that for a single H2O, red brings two H's to the table(2) but blue only brings one O, and that red's path is also considerably longer. This would result in timing problems, but the sync symbols at (d5) for red, and (b7) for blue mean that everything works out. By the time blue can continue on its path, red will have already placed two H's on the plates for blue's O to bind with. After that, blue will drop the finished H2O at the output zone at (ω:b2) and then actually output it via the ω symbol at (ω:a3). Note that the output molecule is actually rotated 180° from the target, but is still accepted.
The whole process is as follows.
- Red α-ins (c2) and grab H (b2). Blue β-ins and wait (b7).
- Red drops at (e4).
- Red α-ins (c1) grabs H (b2).
- Red syncs (d5), which releases blue. Blue grabs O (b6).
- Red drops (f5).
- Blue binds to O (e5) to two H's (e4,f5).
- Blue drops H2O at (ω:b2) and then ω-outs at (ω:a3). Loop complete.
The results for this solution are 323 cycles, 1 reactor, and 24 symbols(3). Which, is alright I suppose, but as we'll see, we can do a lot better on both cycles and symbols.
2.4 Cycle optimization: tight loop
First, let's take a look at cycle optimisation. If you look at Fig 1, and/or run the solution, you'll notice that the waldos spend a lot of time doing nothing but moving. the first order of business should be to shorten the path lengths as much as possible.
For example, the two right-most symbols of red's path are the two grab-drops at (e4,f5), but the path continies to the right one more step before going up again. Tightening that up so that red goes up right at the grab-drops reduces the path length by 2×2=4, saving 40 cycles.
And that's just one spot where we can tighten the loop. By moving the bonders a little, red's path can be fitted entirely into the α zone, creating a really compact loop. At the same time, blue's right side can be move left by one – only one, mind you, as blue still needs to be able to drop the water molecule into the output zone. The final design can be seen in Fig 2.
The algorithm is actually exactly the same as before; only the positions have moved.
- Red α-ins (c2) and grab H (b2). Blue β-ins (c6), grabs O (b6) and waits (b5).
- Red drops at (c3).
- Red α-ins at (c2) again, then loops around and grabs H (b2).
- Red syncs (c4), which releases blue.
- Red drops (d4).
- Blue binds to O (c4) to two H's (c3,d4).
- Blue drops H2O at (g6) and then ω-outs at (f6). Loop complete.
Wahey, 166 cycles! That's half the time we used before, and all we've done is made the paths shorter. If you're going for least cycles, keep your path lengths as low as possible.
By a happy accident, the symbol count is also one lower. Because the red path crosses itself at (c2), the α-in there is executed twice in one loop. You could have also done this in the base solution at (f2), for example, but you'd have to move the red start back as well.
There is also the opportunity to get rid of both syncs. The reason for the sync is to keep the red and blue loop-times the same – that's basically what syncing means. However, the red and blue loops are now 16 and 14 cycles long, and it's rather trivial to make blue's 2 cycles longer. You'll also have to move the blue start back to ensure that blue's O won't collide with red's second H at (c4). Fig 3a,b show how that can be done efficiently.
There are a few other things that you might try in Fig 2, but which won't work.
- In an attempt to speed things up by one cycle, you could move the blue sync up to (b5). However, this would block red's path as the latter brings the second hydrogen, so that won't work.
- Alternatively, you could move the red sync left to (b4). This won't work either, as blue's O will bump into red's H as they move into (b4) and (c4), respectively.
- Blue's path seems a little long. While the lower line must be at row 6 (because that's where the O spawns), you could move the upper line down by one. However, you'd need to lengthen red's path to compensate, and since red's path is already the longer of the two, this move would actually cost you time instead of speeding things up. When optimizing, concentrate on the rate-limiting factor first.
- You could also try moving blue's drop up to (g5), but now H2 doesn't entirely fall into ω, so yeah … no.
As you can see, there are always things you can try to squeeze just a little bit more out of a solution. Even if most of them don't work, the experience of the attempt will teach you what to look out for, and what works and what doesn't.
2.5 Symbol optimization: single loop / parked waldo
Now let's take a look at symbol optimization. First, think of what you need for the reaction. In this case, that's one β, two α's, one grab, two bonds, one drop and one ω-output. So that's 8 symbols. As we've seen earlier, sometimes you can use a symbol multiple times, so you could potentially have a minimum of 6. Now look at the results for the previous examples: 23 symbols. Where the hell are all the other symbols coming from?!?
In short: arrows. Well, arrows, syncs and useless drops, but mostly arrows. Optimizing for symbols usually comes down to reducing the amount of arrows, and eliminating syncs.
In most cases, the best way to get rid of arrows is do do everything with a single waldo – which, obviously, gets rid of syncs at the same time. The only question is whether that's possible for the task at hand. In this case, it happens to work out. Now, I could show you how to do it with just a single waldo, but instead I'm going to introduce something better: the parked waldo.
Take a look at Fig 4, which shows the single-waldo design in red. It's just a simple loop with 4 arrows, and 2 α's, 1 β, 1 grab, drop, and ω. Note that the bond+ symbols are conspicuously absent on the red line, but there is one –and only one– on blue. What's up with that?
The blue path is a pattern known as the parked waldo. When a path
leads the waldo into the side of the reactor, it will just get stuck there. More
precisely, it will get stuck there and continuously issue the
command on that square, which in this case means a
In other words, every cycle, blue will activate the bonder plates, so when red issues an α-in, at (b3) and (c2), the H spawned at (b2) will immediately bond with the O. Please look closely at how this happens. Remember that red always comes before blue, meaning that the spawn occurs before the bond+. If the colors were reversed, it wouldn't work. But in this arrangement, it will. The first α happens at (b3), which spawns an H at (b2). Normally, the grabbed O would just run into the stationary H, but thanks to blue's bond+, the atoms will bond together on the same cycle as the spawn, and everyone's happy.
11 symbols. Again, about half that of the base solution, nice. Now I'll be honest, I initially envisioned this to be a least-cycle trial, and it is pretty fast, but in the end it's the symbol-count that's the more impressive here.
As I mentioned before, it is also possible to do a pure one-waldo solution for this. However, in that case you can't take advantage over the in/bond combo that the parked waldo provides. Also, you'd now need two bond symbols, so it's actually less efficient anyway.
Another thing you might try is using a single α. For that, you'd need to make a little loop so that the α is activated twice. In doing so, however, you'd have to use two extra arrows to lose the one α, so that's not worth it.
So anyway: parked waldo FTW.
2.6 Cycle optimization: parallel execution / twin loop
In the previous section, I showed how you can how you can do the reaction using only a single waldo. Now, it stands to reason that if you used two single-waldo paths, you'd be twice as fast. This is the parallel execution pattern. As usual, though, it won't be quite that simple.
Fig 5 shows a solution where red and blue both create their own water. Both loops are essentially copies of Fig 4, with a few key differences.
The main reason you can't use an exact copy is because you can't use a parked
waldo anymore, so you'll have to add a few
bond+ symbols here and
there. As it happens, you need to be very specific about where these are placed.
To create a tight loop, the second hydrogen must be bonded in the same cycle,
or the HO will miss it. This means
bond+s at (b3) and (c2).
And now we run into a second snare, namely that we also need an
α-in at (c2). To make this work, you need to have one waldo
do the input, and the other should then bond it immediately. Now, remember:
red goes before blue! This means that red should do the
α-in, and blue the
Getting the timings just right for this is a little tricky, because now the two
waldos have to work together, while still doing their own rounds. For these
situations, first concentrate on getting a
working, and design the rest of the solution around it.
The red-first rule is used in two other ways as well. We can use it to create
β-in/grab combo at the start, and a
drop/ω-out at the end. This saves two cycles in the overall
The last little trick is to rotate the molecule so we can drop it in column G instead of H. The rotate costs an extra cycle, but the shorter path saves two, so overall it's a 1 cycle/loop gain.
The final result of all this is Fig 5. I focussed on
making blue's loop as quick as possible. This meant I had to have a
β-in on cycle 2, and
α-ins at cycles 5 and 7.
Taking the required grabs, drops and outputs into account, the earliest position
I had for red's start was (g4); I'd liked to have placed it further along, but
then I'd run into a conflict with other symbols.
As you can see, running a twin-loop is not a beginner's technique. It relies on a very careful interaction between two waldos and you have to carefully count out the cycles to make it work. But if you do get it to work, it is very powerful.
Because we're now interleaving two waldos, a single process iteration doesn't stop until both waldos have done their paths. This produces two H2O instead of just one.
Cycle 2 : red
β-ins O (g6) and blue
grabs it immediately (b6).
Cycle 5 : red
α-ins the first H (e6) and blue
Cycle 6 : red
β-ins its own O (d6).
Cycle 7 : red
α-ins the second H (c6), which blue bonds to immediately (c2). Blue's H2O is complete. Red then picks up its oxygen.
Cycles 11 & 13 : red
α-ins its hydrogens (b3,c2), which blue
bond+s at (g2,g4).
Blue rotates, drops and
ω-outs its cargo (g5,g6,f6).
Red rotates and drops its water (g3,g6), which blue immedately outputs (b5).
Right before this, however, the second iteration has already started as well
As expected, running both waldos on a single-waldo solution pretty much doubles the speed. It also doubles the symbols, though, but we were't going for that here anyway. The tight-loop solution took 166 cycles, so we're beating that by some 40%.
A slightly faster alternative
There is actually a way to tighten it up by a few extra cycles. The final time is decided by the tenth H2O, which is red's responsibility. Notice that there is quite a gap between blue and red, so if red were to start closer you could gain a bit of time.
This isn't quite a small a thing as it sounds, though. Moving red up means that a lot of other
symbols have to move up with it, particularly the ones involved in combos. And you still have
to make sure the new positions aren't already taken. Look at the
before the O spawn-point for example. These need to be two apart to make the binding
with H to work, but you can't more them up by 1 or 3, because then they'd conflict with red's
grab. So, let's try 2. The fact that now the
β-in conflicts with the
grab doesn't matter, as the input can occur at an earlier time as well. A bigger
problem is that now red's start will conflict with its
drop. Fortunately, there's
a way around that to: put red's start (and initial
β-in) in a separate
The process is largely the same, so let's go straight to the results. As expected, we've gained
another two cycles overall, at the expense of two symbols because of the extra branch. One of
these symbols is actually unnecessary in this case, because the additional
could also be put on the main line at (f6), removing the need for the blue
This is as close as red can get to blue – any faster and you'll get a collision with blue at the curve back down or during the ro…ta…tion …
No wait, that's not true. Hang on …
Eh, doesn't matter; I can't move red up more because of
Or … oh wow.
… I'll … be right back. (sounds of *SCIENCE* in the background)
And another alternative
Right! So you can move red up one more space. While it's true that there's a potential
α-in/grab clash, that particular
has quite a bit of freedom: as long as it's before blue's first
bond+ you're good.
The final design can be found in Fig 9. Moving
α-ins about allows the gaps to be one cycle smaller, and I've also removed
β-in. The gap between H2O's is now reduced to
1, and after blue's rotation it's actually 0. you need to be very careful where you do these
rotates, otherwise you'll get collisions when the waldos move down again. Important to note
is that blue's H2O stays in the system for one cycle because it has to do its own
output. Since there's barely enough room for this now, it means that this is the theoretical
limit. Usually it's Andy or Sahishar that find that extra cycle, but this time I caught
it in time :).
Nothing too exciting anymore, just the one extra cycle and symbol gain.
2.7 Symbol optimization: bouncers
And finally, the bouncer pattern, but unfortunately I have to cheat a little here. It requires the output to be at ψ, which technically falls outside of the parameters of the level, but the bouncer pattern is so good that I'll allow it here.
The core principle of the bouncer is to have an arrow that reflects the waldo back in the direction it came from. This allows everything to be placed on a single line and uses two arrows less than if you used a loop. It is also the shortest path between two points.
The tricky thing about a bouncer line is that, aside from the corners, every square is passed twice. This usually means that inputs need to be at the ends to avoid collisions. The exception is to use parallel bouncers, but that way madness lies (of course, that's where this game eventually leads to anyway, but there's no need to rush).
In this particular case, there is one
β-in for the O and one
α-in for both H's. Red starts with creation of HO, and then blue picks that
up, adds an extra hydrogen and drags it to ψ. Both waldos follow single lines, the lines
are of equal length so there's no need for syncs.
- Cycle 2,4: Red spawns an O and carries it upwards (b8,b6).
- Cycle 6,7: Red spawns an H and bonds it itself (b4,b3).
- Cycle 8: Red drops OH at (b2); blue is now at (c2).
- Cycle 9: blue picks up the OH.
- Cycle 10: blue is now at (c2) again, so that (b2) is free to hold the second H. Red spawns that H (b4), and blue bonds it in the same cycle.
- Cycle 16,17: blue drops and outputs the H2O.
124 cycles is actually pretty damn good, considering I wasn't going for that. The reason for its speed is that red and blue's jobs are interleaved: both paths are 12 cycles long, because of the distribution of labour, the work done with blue is essentially free. This is an example of a relay pattern, where the work is divided into smaller subtasks and both waldos work independently (and simultanously!) and the results of one waldo is passed onto the next. It's similar to an assembly line or water-carrying relay.
On the face of it, 13 symbols is pretty good as well. Unfortunately, we already had a 11 symbol solution, so this one isn't as good as I had hoped. Having said that, the bouncer pattern is a good one, and in many cases it will actually be the least-symbol solution.
So, what have we learned here?
First and foremost: know the rules of the game!
- All symbols and plates can be moved.
- All symbols have a context menu.
- Red executes before blue.
- To match the target, you only need to match atom-pairs and their bond number, not the position or rotation.
Path length is the biggest factor for the cycle count. When optimizing for speed, make the
tracks as short as possible. That said, on occasion it's also useful to use longer paths
for syncing, in order to remove
Combo execution. Since red's instruction always preceded blue's on the same cycle,
you can let the instructions work together to form, for example,
in/bondcombos. Using these at the right time can win you a few cycles overall.
Bouncer arrows will create single-line paths instead of loops, and can be used to
minimize arrows and path-length. Combined with
flip-flops, you can create some truly devious paths.
A parked waldo can be used to execute an instruction on every cycle, and can help
reduce the amount of symbols. Primary targets for these are
bondor output commands.
- A parked waldo solution means that the other waldo does all the heavy lifting. In some cases, you can duplicate that algorithm to achieve a twin loop, taking full advantage of parallel execution. You can work at twice the speed, but it also costs twice as much in symbols.
Another way to to achieve parallel execution is to have relay waldos. Part of
a waldo's task is carrying molecules from the left input zones to the right output zones,
and this can be a significant part of the time. In the relay-waldo pattern, each
waldo carries the molecule halfway, and the first passes it on to the next. Because both
waldos now work independently, they can do their work simultaneously.
For comparison, consider a case where a single loop solution takes 20 cycles to complete.
- With a parked waldo, you use the single loop and have 20c/output.
- With a twin-loop, you have two 20-cycle loops, and get 20/2 = 10c/output.
- With a relay, each waldo takes takes 20/2 cycles, and because the work's done simultaneously, the final time is also 10c / output.
And here are some links that you should probably check out:
- SolutionNet. For saving and comparing solutions.
- reddit: Tips and tricks for new players. For tips and tricks.
- reddit: How I feel playing SpaceChem. For the lulz and shared experience.
- Steam forum: Revolutionary revelations, Solutions you're proud of and Terrible Solutions.
- Please don't copy solutions wholesale, though, that would be cheating – not just cheating others, but you're also cheating yourself: if there's one thing everybody agrees on it's the intense pride one feels when you finally solve a mission, and you'd completely miss that. Seriously, looking up solutions to a puzzle game. What the hell?!?
- onto the plates, AHAHAHA *cough*, ahem, sorry about that.
- start-symbols do not count to the final score, but arrows do.