How SpaceChem helps enlighten Object-Oriented Programming

The flashy and complicated chemistry-based puzzle game, SpaceChem, does more than just challenge the player to simply bond chemicals.
As someone that truly finds a large interest in the Computer Science field, everything has some strange relation to programming. However, in a video game like SpaceChem, the relation seems to be extremely visible, specifically object oriented programming. If you’ve never played SpaceChem, here’s a brief overview of what the player must do:
As a “scientist,” the player must create chemical compounds as required by the stated objective. In the beginning stages, the player must create bonds that are distributed straight from the factory. However, as progress is made, the straightforward distribution receives a twist. In the later levels, the player is now required to distribute the chemicals from factories and assemble the bonds in reactors, some of which have specific use. Often times, it will look like this:

What is displayed is a basic (and poorly constructed) work-in-progress. However, the “solution” does not work. In fact, the null use is part of the purpose that is to be portrayed. The objectives stated are relatively difficult, considering the conditions.
This level requires that the player distributes the chemicals and turn them into two separate combinations.
This is where our programming mindset becomes our useful tool. If you’ve written any slightly thorough project, you’d know it’s best to not keep all your code in a single class. To avoid this, we create multiple classes, often carrying helper methods to achieve our objectives cleanly and efficiently.
The same instance is seen throughout a large portion of SpaceChem, as seen in this level. The main factory that distributes the chemical compounds is what we can consider our MainActivity/MainThread. In programming, as the compiler reads each line of code in our Main class, methods and initializes are called to help us achieve our objectives. In SpaceChem, the equivalent would be our assemblers and dis-assemblers. Our other classes are the assemblers and dis-assemblers, and their methods/functions are the changes being made within them. In many cases, it is necessary that we utilize multiple classes because of multiple objectives, like the one displayed above:
I chose this level because of how I was stumped previously. Prior to making this connection, my solution looked like this:

My final solution (Figure 1) came to be with the realization that what I learned in programming could also be applied here. The main factory distributes the chemical compounds to be disassembled, The following chemicals go separate ways into two different assemblers. From those assemblers, simple bonding is performed, achieving the objective.
If a parallel were made in pure machine language, the factory distributing the chemicals would be our Main class and the assemblers and dis-assemblers would be our other classes. Here is our object oriented mindset in action, creating a solution with slight ease.
The game is fun, yet complicated, and the learning curve is well worth the hair-pulling difficulty. SpaceChem challenges the player to think creatively, the way any form of programming would, involving a visually appealing twist.
Optimization? Well that’s for another article, and maybe even another game.
If you liked my post, feel free to leave a 💚! I also run a blog where I post about my projects and interesting tidbits I find through learning in the Computer Science Field :] Check it out! http://lacanlale.weebly.com/
