Learning to code may not be for everyone, but as technology continues to reach deeper into our lives, an ability to understand and participate in it has become increasingly important.
But more than that, programmatic thinking offers tools for strategizing, problem-solving and creativity that can be useful in everyday life.
This is why DUAL was created.
Many computer programs are built with three common patterns: selection, sequence and loop. Playing DUAL introduces all of these concepts.
When you use conditions you're testing to see if shapes on the grid return TRUE or FALSE. If a shape matches the condition, it will return TRUE. If it doesn't match, it returns FALSE. In code these are called conditional statements.
You can see how these work in the game below.
During each step of the sequence, the program loops through the shapes on the grid and checks which return TRUE. Shapes that pass these 'tests' are grouped and targeted by whichever action the player chose. Shapes that return false are faded out. See below for more about sequences and loops.
When you use the AND / OR logic in the game, you're using logical operators.
With AND between two conditions, the program returns TRUE if both conditions are met. With OR the program returns TRUE if either condition is met. Consider what this would mean if you combined two of the above conditional statements.
A program reads code in sequential order, responding to changing states as it goes along. This is exactly how sequences work in the game!
The program reads the code from top to bottom. After the first condition is tested and the first action is taken, the program moves to the next step. At this point the next condition is tested, but the shapes on the grid have now changed. Being able to anticipate such changes and plan ahead is key to playing the game – and key to being good at programming.
When you hit play, the program loops through every shape on the grid: first to check if each shape meets your set of conditions and then to perform each action in your sequence.
Let's see what the loop returns for the conditions below.
Loops are used all the time in programming to go systematically through a set of items or objects. Sometimes this is to find things, or test conditions like above. Sometimes it's to collect or change things. Computers are great at repetitive tasks that people would find boring.
DUAL wasn't designed to teach players how to code, but to get them started thinking programmatically. Many programmers would agree that writing code isn't actually the hard part – figuring out the logic for a program is. If the concepts in DUAL make sense to you then you've already taken a huge leap!
Thinking programmatically is really about thinking in terms of systems. The world is full of systems – making programmatic thinking an invaluable skill.
The web is brimming with great resources for learning programming. Here are some next steps: