# SpaceChem tutorial : Fun With Water

## 1 Introduction

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 :).

Original introduction video with H2O example, by zachatronicsindustries. WATCH THIS FIRST!
Audience : beginner-intermediate

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.

Also, don't forget to visit SolutionNet where you can upload your own solution and view those of others to get some ideas on where to start if you're stuck.(1).

#### ResearchNet code

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:

H4sIACYioU8A/3WPMWvDMBCF/0q42QbJdAjSXrxlzBA6KPY5FiiSkU5Q17i/vSenlLily8F9vP
fu3QLWT5nqj+AxgVpAlLExXi8L3IPDLjsEBe3cx3BDr1stpRQCKuhC9gRKNuvbWoH833t6n4vz
xM7jHydbQ6ZdjS3qyX82hFG3n6IpEXxdNxwkddPsi4gSNppUOxNvWD9iQQ3GJazgGnyPsf4Wvz
yUCX0K8UdT0JAT7kmanCX6BQkdTiE+Y5qnUjdiQhO7kZt5cy/kNfvD2dJ42D5hbjKN5Sx0rPQM
ejsMlt+lGZRYvwBa3V5umQEAAA==

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’.

### 2.2 Overview

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.

#### Video

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.

Accompanying video showing all the solutions discussed below.

### 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.

Fig 1. Base solution from the introduction video.

#### Process

The whole process is as follows.

1. Red α-ins (c2) and grab H (b2). Blue β-ins and wait (b7).
2. Red drops at (e4).
3. Red α-ins (c1) grabs H (b2).
4. Red syncs (d5), which releases blue. Blue grabs O (b6).
5. Red drops (f5).
6. Blue binds to O (e5) to two H's (e4,f5).
7. Blue drops H2O at (ω:b2) and then ω-outs at (ω:a3). Loop complete.

#### Results

 cycles 323 1 24

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.

Fig 2. Tightly wound version of the base solution. Note that I've changed the grab-drops into pure grabs and drops for clarity.

#### Process

The algorithm is actually exactly the same as before; only the positions have moved.

1. Red α-ins (c2) and grab H (b2). Blue β-ins (c6), grabs O (b6) and waits (b5).
2. Red drops at (c3).
3. Red α-ins at (c2) again, then loops around and grabs H (b2).
4. Red syncs (c4), which releases blue.
5. Red drops (d4).
6. Blue binds to O (c4) to two H's (c3,d4).
7. Blue drops H2O at (g6) and then ω-outs at (f6). Loop complete.

#### Results

 cycles 166 1 23

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.

##### Syncless

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.

 Fig 3a: Giving the two paths equal lengths removes the need for syncs. Fig 3b: blue's start is placed such that the waldos won't collide at the crossing (b4).
##### Failed variations

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.

##### 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 bond+.

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.

Fig 4. Single waldo. Well, almost. The blue waldo is 'parked' at the left-wall, making it execute the bond+ continuously.

#### Results

 cycles 197 1 11

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.

##### Failed variations

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. Twin loop. Two single-waldo solutions running the same path in parallel for double speed.

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 bond+.

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 in/bond pair 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 a β-in/grab combo at the start, and a drop/ω-out at the end. This saves two cycles in the overall results.

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.

 Fig 6. red/blue on the same cycle: an α-in/bond combo. Fig 7. an extra rotate can allow for a shorter path, saving 1 cycle/loop.

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.

#### Process

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.

1. Cycle 2 : red β-ins O (g6) and blue grabs it immediately (b6).
2. Cycle 5 : red α-ins the first H (e6) and blue bond+s (b3).
3. Cycle 6 : red β-ins its own O (d6).
4. 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.
5. Cycles 11 & 13 : red α-ins its hydrogens (b3,c2), which blue bond+s at (g2,g4).
6. Blue rotates, drops and ω-outs its cargo (g5,g6,f6).
7. 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 with a β-in/grab combo.

#### Results

 cycles 97 1 26

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 α-ins right 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 branch.

 Fig 8a: The separate starting branch for red allows it to follow blue more closely, leading to a quicker time. Fig 8b: Watch out for collisions at intersections.

#### Results

 cycles 95 1 28

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 βin could also be put on the main line at (f6), removing the need for the blue β-in.

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 α-in/grab clash. 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 for an α-in/grab clash, that particular α-in actually 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 the superfluous β-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 :).

 Fig 9a: blue's does its own α-in, but red the second to avoid collisions at (b2). Fig 9b: Just enough space to rotate safely. Rotating earlier creates collisions (try it!) Fig 9c: blue's H2O lingers for a cycle, but this fits with red's rotation stalling.

#### Results

Nothing too exciting anymore, just the one extra cycle and symbol gain.

 cycles 94 1 27

### 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).

Fig 10. A single line path via bouncer arrows for low symbol count.

#### Process

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.

1. Cycle 2,4: Red spawns an O and carries it upwards (b8,b6).
2. Cycle 6,7: Red spawns an H and bonds it itself (b4,b3).
3. Cycle 8: Red drops OH at (b2); blue is now at (c2).
4. Cycle 9: blue picks up the OH.
5. 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.
6. Cycle 16,17: blue drops and outputs the H2O.

#### Results

 cycles 124 1 13

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.

## 3 Summary

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.
There are more rules, but these are the most important ones.
• 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 sync symbols.
• 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/grab or in/bond combos. 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 bond or 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:

##### Notes:
1. 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?!?
2. onto the plates, AHAHAHA *cough*, ahem, sorry about that.
3. start-symbols do not count to the final score, but arrows do.

## 13 thoughts on “SpaceChem tutorial : Fun With Water”

1. Oh, you're THAT cearn! I recognize you now from the spacechem.net leaderboards; you're an unstoppable machine! I spent HOURS looking for three more cycles to shave in Ω-Pseudoethyne because of you (unsuccessfully, so far).

Interesting to see what the serious SpaceChem players do in Real Life(tm). Unsurprisingly, many of us are assembly programmers :)

Love this site, by the way; keep up the good work!

2. Oh, you're THAT cearn! I recognize you now from the spacechem.net leaderboards; you're an unstoppable machine! I spent HOURS looking for three more cycles to shave in Ω-Pseudoethyne because of you (unsuccessfully, so far).

Yeah, this is me. Although I'm not sure who else I should be >_>. Another GBA programmer I take it? Don't think many others find this place.

[br]

Oh, Ω-Pseudoethyne. Fond memories. I designed the CΩ sorter completely on paper first and was just so stoked that it actually worked exactly as planned. And I know exactly which three cycles you mean. I could tell you where they came from, but that would be spoiling it :P

You seem to have a few nice scores on spacechem.net too btw. Nice one on KOHCTPYKTOP. That's the last level I need to do before I'm done with all the regular missions.

Oh, and you can easily get 2435 on "No Introductions" as well. Remove two bits of pipe should suffice.

Interesting to see what the serious SpaceChem players do in Real Life(tm). Unsurprisingly, many of us are assembly programmers :)

I reckon all the best players have a technical background, and I'm no exception. I just dabble with assembly though; nothing professional. But how about you? Senior developer in the biz. Impressive!

3. Ookay, so the comment system does not like Unicode. That's good to know. Fortunately, html-entities work just fine.

4. I've never done anything serious/professional with Nintendo hardware. I messed around with GBA homebrew for a bit many years ago, and found tonc to be amazingly useful. After I gave up on GBA stuff, I stuck around for the assembly optimization articles. Most of my real ASM experience is on the PS3's SPUs; I was lucky enough to be among of the very first developers at Sony to work with them. It was actually a fellow SPU programmer who first turned me on to SpaceChem; SPUs and SpaceChem map terrifyingly well to each other (two waldos two execution pipes per SPU, multiple reactors multiple SPUs passing data to each other, pipes between reactors ring buffers between SPUs, etc.)

Thanks for the tip on No Introductions! That was the level that first pushed me to start paying attention to the global leaderboards; you'll notice my standings get markedly better beyond that point. I really should go back and tweak my earlier solutions, but I'm more focused on finishing the game first (I just unlocked End Of The Line last night, and I haven't the faintest idea what to do with it).

You don't happen to know who Andy is, do you? I'd really like to meet him, shake his hand, and try to recruit him onto my team at Sony. You too, for that matter; want to move to Los Angeles? :)

5. I'm looking at some of your numbers and getting the itch to improve some of my old stuff as well. I already found 40 cycles for "I Told You So" (where you make benzene) and think I might be able to get a 200-220 solution if I try a bit harder.

[br]

End of the Line is a total bitch. I spent weeks off and on trying to get my head around it, and my heart skipped a beat when during building I realized out that my first plan for Σ-pseudobenzene wasn't going to work. But I got there in the end. I still need to redo it because I started with the wrong formulas, but at least I made it. The point for a good time is to get as many missiles out as possible, but the getting a nice 15 H2 / Ω ratio is troublesome.

[br]

And no, I don't know Andy, unfortunately; or Sahishar. I reckon those two have about over 90% of the first places. It's insane what those guys can do and I'd like to share their hand and take a bow to them as well.

As for moving: hehehe. I'm not sure the climate would agree with me, but, damn, getting into the guts of SPUs and stuff does tickle me in the right way. I miss assembly, and which I had time for that vertex/pixel shader stuff as well. But alas.

[br]

Oh, and did you see? SpaceChem's on sale today! At least in Europe; not sure how it is in the States. But if it is and you want to spread the luv for the game, now would be a good time. Looks like I got this article out just in time :)

6. Hi,
Interesting article, thx.
When you say "(There is also a certain order in which the bonders are executed, but how it works exactly is currently unknown.) " that’s not exactly true, http://www.reddit.com/r/spacechem/comments/muidl/bonding_algorithm/ serbaldrig comment is pretty accurate.
I know now how I can shave cycles in my solutions, but I probably wont do it (maybe because I’m not an Assembly expert ;)) but still it is interesting to see where the cycles are gained.

7. Hi, hrbrt.

I know of serbaldig's post, but I've ran tried all permutations of a 4-bonder reactor, and it seems that it's not just a matter of bonder numbering. Consider these two cases:

 (A)                 (B)
1  2                2  1
3  4                4  3

Suppose that (A) gives a horizontal bonding. Because (B) is merely a mirror of (A), you'd expect that it'd also give a horizontal bonding, but that's not the case.

My test case for this Cyclo-Boron with 4 single-bonded Borons. Since Boron can only have 3 bonds, you can easily see what has priority. B3 might also be a good candidate.

 H4sIAAdUoU8A/22PPW7DMAxGr1JwtgFJqBdpywm6Fx1Uh44FKKJBUUNi+O6V6qLI30KAjx8eyR
VCWor0V0qYwa6gWvlltf1c4UwRxxIRLByIKbmD03rQ2hk9KO20GbRyxgxKQQcjlSRgtdm+tq0D
KvLsfi00N0LzLFRNN/vcR88n7Hcx2MnHjB18Uzoi93/h9z2ZMWXi/0xDU8l4T/ISg8gDFIy4EN
9iuSztYMaMnse5Xpb8eX+hrX774EAc5FIHvsjc9sJYo6mCY5imUD+uU6u2H4GOSi9xAQAA

8. You are right, It doesn’t work like serbaldig said. I was really convinced that it worked and I have done some levels with that in mind without trouble (none that I remember).
But I may have discovered the algorithm :
Bonders are given a priority from 1 to the total number of bonders, starting from left to right and top to bottom. 1 is the highest priority and 8 the lowest.
i.e.
1 2
3 4
5 6
7 8

then for each bonders in highest priority order (1 2 3 ...) check the cells to the right and bottom, if there is a bonder bond the two atoms if allowed, if both cells contain a bonder start with the one with highest bonder priority.
I did some testing and it seems coherent both in my results and in a programming point of view.

9. Loop through bonders and check right and down – yeah, that was my second thought as well. Now that you mention it, it does kinda make sense. Checking each bonder-pair would require a double loop giving an O(n2) algorithm, but if you have a look-up table that maps location to bonders, the bonder-adjacent algorithm would be O(n). Of course with n ≥ 8 it never really matters, but still.

I haven't tested this fully yet, but if I apply this to my old results, it does cover all bases for a 4-bonder reactor. However, only if the order goes:

   1  3
1  4

This is different from what you have, there may be a difference between research and production mission reactors. I know that's the case with 8-bonder reactors, so maybe for 4 as well.

Or maybe I took a wrong turn somewhere, I'll just have to double-check.

10. I think I’m correct, keep in mind its not just right an down but either right then down or down then right depending on the bonder priority in the right/down spot.
Also by doing some tests each reactor has its own priority list for bonders.
for custom research it is:
1 2
3 4
5 6
7 8
for custom production standard/sensor reactor
1 3
2 4
for custom production assembly/nuclear and fusion
1 2
3 4
for custom production superbonder reactor
5 1 3 7
6 2 4 8

It would be logical that the custom production reactors are the same as the game corresponding ones, and that the research reactors in game are the same as the corresponding ones in game production.

11. Nice work!

Odd to see that much variation in the orders though – I would have at least expected the 4-bonder reactors to work the same.

How did you test all of this? I might want to try to reproduce all of this in the future.

12. .. j'espÃƒÂ¨re que je ne suis pas trop tard pour souffler avec toi les tites bougies!!!!!!!.. je suis sincÃƒÂ¨rement heureuse de t'avoir rencontrer dans ce bo monde virtuelle de bonne bouffe;)et je pique au passage quelques macarons!!!!~nancy xx