Starbound

Starbound

Not enough ratings
Wiring Games With Starbound: Tic-Tac-Toe
By MongooseCalledFred
Want to do more with wiring? Think Tic-Tac-Toe is easy? If so, try this guide.

Note: Persistent Switches now have the functionality that Latch Switches are being used for. You can safely use a Persistent Switch in place of a Latch Switch if: instead of connecting to both nodes, you connect to the top node, and instead of connecting to the top node only, you connect to the bottom node.
   
Award
Favorite
Favorited
Unfavorite
What You Need
Before you begin, you will need your wiring tool and these 215 parts:
  • 81 Bulbs
  • 70 And Switches
  • 20 Latch Switches
  • 20 Buttons
  • 19 Not Switches
  • 2 Lights
  • 2 Displays (to identify a win)
  • 1 Or Switch

You may substitute as you see fit.

Key to the Images
Letters identify a node. Red lines indicate a wire should connect the two nodes at its ends.
Step One: the Cell Circuit
Place two Not Switches, four And Switches, and two Latch Switches as shown in the left of the image. Then wire them together as shown in the right of the image. Ignore the letters for now.

Make eight more of these. I recommend placing them in a row so that you can identify which goes to what cell later.
Step Two: the Main Interface
Place your Bulbs in 3x3 squares in three rows and three columns with each row and column seperated by one block. Place your buttons in two 3x3 squares, one on either side of your display. It should look something like this:
Ignore the torches, bananas, and other unmentioned elements.
Now, wire all those buttons to their appropriate X's or O's in the Cell Circuits. Next, wire the center and corner Bulbs of each cell to the SX nodes on the appropriate Cell Circuits and the outside Bulbs of each cell to the appropriate SO nodes on their appropriate Cell Circuits.
Step Three: Detecting Wins
This step may seem tedious, so you can skip it if you're willing to drop this feature.

Set up a 4x4 grid of And Switches for each player. Connect each output of the first and third columns to the lower input of the And Switch to its right. For each player, wire the SX or SO nodes to the remaining And Inputs so that every possible winning combination of three outputs is connected to one set of And Switches. The eight possible combinations for each player are: (1, 2, 3), (1, 4, 7), (1, 5, 9), (2, 5, 8), (3, 5, 7), (3, 6, 9), (4, 5, 6), and (7, 8, 9).

Now, place two And Switches next to each other with Latch Switches beneath them and wire them together like this:

Connect all the outputs from the second and fourth columns of Player X's And Grid to the left W and all the outputs from the second and fourth columns of Player O's And Grid to the right W. Next, either wire both LX and LO to all nodes in the Cell Circuits marked L, or wire LX and LO to the inputs of an Or Switch and connect that to all nodes marked L. (This is to stop the game when someone wins.) Finally, connect LX to whatever you want to indicate that Player X wins and LO to whatever you want to indicate that Player O wins.
Step Four: the Turn Selecter and the Reset Buttons
The Turn Selecter
This is just a Latch Switch, a Not Switch, and two lights. Wire the Latch Output to the Not Switch and all Nodes marked with a T. Wire the Not Switch to all Nodes marked with an N. Place the lights next to the input panels for each player. Wire the Latch Output to the light next to Player O and the Not Output to the light next to Player X. Whichever player can make a move will have a lit light.

Now connect all C and C' nodes from the Cell Circuits to the upper input of the Latch Switch. Connect all C' nodes to the lower input of the Latch Switch.

The Reset Buttons
Place a button near each of the two player input panels. Connect them to an Or Switch. Connect the output on that Or Switch to the upper inputs of all Latch Switches.
The Full Forms of the Letters and Conclusion
  • C - Change Turn Selecter to Off
  • C' - Change Turn Selecter to On
  • LO - Lock Cells and O's Win Display
  • LX - Lock Cells and X's Win Display
  • N - Not Turn Selector Output
  • O - O's Input
  • R - Reset Node
  • SO - Show an O
  • SX - Show an X
  • T - Turn Selecter Output
  • W - Win Initiated
  • X - X's Input

Thank you for reading this guide. You may be able to spot / have spotted a way to optimize the resource usage. If so, please tell me in the comments. (At least one option exists.) If you have suggestions for other games you think could be wired up with Starbound, please tell me.
The Design Process
To start, I tried to break Tic-Tac-Toe into smaller parts. The most logical intermediate parts were the nine individual Cells, the Turn Keeper, the Win Detection Logic, and the Reset Button. In order to plan what I would be building, I drew up some custom symbols to represent each switch. Then I started stringing them together in what turned out to be a very messy drawing that I doubt anyone could understand without the key. From that schematic, I built the wiring in my very own, requisitioned high-security Apex Lab. The buttons and display were in the entry way, so anyone could theoretically play the game if they found it. (The security was so good, you needed to be an Admin to get inside the building unless you were part of my party and I was inside.)
The Cells
I broke down each Cell into a sequence of activities that needed to happen (with a parallel chain for each player). The first thing in the line would be the button. In order to prevent players from cheating, the button had to go through a Regulator that would determine that "yes, it is your turn" (by asking the Turn Keeper) and "yes, this cell is empty" (by asking the Persistent Memory). If both of those were true, it would quckly tell the Turn Keeper to swap to the other player's turn. (If either or both were false, the Regulator would ignore the button, letting the player select a different Cell.) The Regulator would also tell the Persistent Memory to turn on (a Latch Switch at the time, a Persistent Switch now, more on that below). The Persistent Memory would now tell the Regulator that the space was occupied, so no one should be able to put anything here. The other job of the Persistent Memory was to turn on the appropriate Bulbs in the Cell, telling the players that the button push was successful.
The Turn Keeper
The Turn Keeper was very simple initially. Just one Latch Switch. Activating both nodes would turn it on; activating just the bottom one would turn it off. One player's Cell logic required that the Turn Keeper be on in order to claim the Cell. The other player's Cell logic used a Not Switch to invert the Turn Keeper's signal, requiring the Turn Keeper to be off in order to claim the Cell. With later projects, I realized that the Not Switches from each Cell could be replaced by a single Not Switch at the Turn Keeper, thus reducing construction cost.
The Win Detection Logic
I first calculated the possible winning combinations: three horizontal rows, three vertical columns, and two diagonals, summing to eight combinations for each player. Since there were three units of Persistent Memory (each from different cells) that had to be "On" for each combination, I needed two And Switches per combination. That meant that I needed 8 "combinations" times two "players" times two "And Switches per combination" = 32 total And Switches. My design sketch actualy shows less, because I forgot that each player needed their own set of logic.
The Reset Button
One of the main objectives of this project was that you wouldn't need to use the Matter Manipulator to start a new game. At the time, Persistent Switches had one input - when you activated it, the output turned on and stayed on until you took the Persistent Switch off of the wall. That wasn't going to work, so I had to use Latch Switches. Now that Persistent Switches have an "On" node and an "Off" node, the Latch Switches look clunky.

Now, where the Reset Button actually comes in. Because everything was tied to the Latch Switches, I could simply turn them all off to clear the board. That's what the Reset Button does - turn off the Latch Switches.
12 Comments
MongooseCalledFred  [author] 19 Nov, 2016 @ 8:02am 
Added a huge section, I'm not sure if it really covers the thought process.
bobthrollop 18 Nov, 2016 @ 8:24pm 
that would be a good idea
making a paragraph or two
on the thought process
behind this great guide
Andyspace 29 Dec, 2015 @ 8:39pm 
niec
RogueRIft 29 Dec, 2015 @ 11:26am 
idk
MongooseCalledFred  [author] 29 Dec, 2015 @ 10:33am 
I'm making another guide like this one soon. Do you confused people have any suggestions for how to make the next guide less confusing?
RogueRIft 21 Dec, 2015 @ 4:11pm 
i'm soo confuzed
the goldfish gobbler 20 Dec, 2015 @ 7:01pm 
you guys are crazy...
MongooseCalledFred  [author] 20 Dec, 2015 @ 9:52am 
@ISB MAJ. flaminghedgehogs Exactly. You're the kind of person I wrote this guide for: those who can overcome inadequacies of guide writers and see beyond the guide. Do you think this would be less confusing if I included a paragraph or two on the thought process behind the design?
miele dishwasher 18 Dec, 2015 @ 4:05pm 
This isn't actually that complicated, when you think about it.
Woa 5 Sep, 2015 @ 1:39am 
...I wish i didn't restart now.... :steamsalty: