Home    LittleBigPlanet 2 - 3 - Vita - Karting    LittleBigPlanet 2    [LBP2] Tutorials
#1

Binary Logic: You're Key for Awesome!

Archive: 7 posts


Ok so lot's of people are having problems with logic, and I can understand its a bit of a benign concept that can be hard to wrap your head around.

Ok so first off, whats a boolean, or binary? Simply put, it stands for dual values. Everything in boolean logic has one of two values, on, or off. Represented by 0 or 1.

Now when it comes to lbp sometimes your boolean values can be special, instead of on/off they get transformed into left/right, IE winches and etc.

Now logic gates are special switches that take in a bunch of inputs, and pump out an output based on the inputs. If you recall highschool math this is called a function, turning multiple inputs into one output. Think of it like a machine you feed a bunch of things into and it pumps out a single answer.

There are a few primary logic gates in LBP. OR, AND, and XOR. Also there is NOT but thats kind of not the same as it only ever has one input.

First off is the simplest gate, NOT. Not flops the input into it. If you input 1, it outputs 0, and vise versa. The best representation of a logic gate is via something called a Truth Table. This is a representation of all possible inputs and their outputs.

For example, here's the truth table for NOT

IN OUT
0 1
1 0

Often for logic functions/gates, the inputs are represented by variables, generally p, q, r, and s. Others are a, b, c, and d. etc etc it doesn't matter. The ones to avoid are v, o, l, x, and i. Simply put, these letters can be mistaken for variables/symbols used in logic.

Next up is the AND gate. This gate is pretty simple. Our LBP2 AND gates take in a lot of possible inputs, with a minimum of 2. The AND gate only ever outputs true when every single input is one. If even one is off it will output 0, off.

Lets make the simple truth table for AND with 2 inputs.

s q OUT
0 0 0
0 1 0
1 0 0
1 1 1

Next up is OR, this is basically a connector for lines. It lets you combine multiple inputs together to control one thing, but has other uses as well. Essentially if even just one input is one, or even all of them, it outputs true. The only time it outputs false is when every single output is off.

s q OUT
0 0 0
0 1 1
1 0 1
1 1 1

Finally we have the XOR gate. It's a special version of the OR gate in that it only outputs true when... ok wait hold on er...

Ok normally XOR gates are only ever 2 inputs so in all honesty, I have no clue if LBP2 only outputs 1 when only 1 input is one, or all but 1 input is one... so uh... let's stick with 2 outputs for now and you guys all have homework to go mess around with the XOR gate to find out what does what, ok? Besides experimenting is what LBP is all about, am I right?

Basically XOR is a one or the other gate, but not both. If one input is on it outputs true, but if none of them or both of them are on, it outputs false.

s q OUT
0 0 0
0 1 1
1 0 1
1 1 0

Now on the forums I personally suggest we all use the accepted mathematical symbols for logic gates

NOT : ~
AND : ^
OR : v
XOR : X
The actual symbol for XOR is a cross in a circle but thats hard to type, so Xx is easier.

Finally lets go back to the NOT symbol, as it has a neat little property. If you apply the not gate to any of the other logic gates it flips their values, making them the opposite of their use. Commonly this is represented by putting the letter N before their name, NAND, NOR, XNOR, etc.

Whats awesome in LBP2 is you don't even need to use the not gate, as each of the other 3 logic gates has the NOT gate built right into them as a toggleable value, just hit square over your gate and select the not toggle on them to stick an invisible NOT gate right after them. Yay for MMM being awesome!

Let's see the effects of not on the main gates.

NAND makes your gate output true when ever one or more inputs are off. It's like a reverse OR gate!

NOR outputs true when everything is off! Neat!

XNOR becomes a very special, highly valued logic gate, as a test let's look at it's truth table and you can guess what it's name is.

s q OUT
0 0 1
0 1 0
1 0 0
1 1 1


If you guessed its the EQUALS gate, you get a gold star!
:star:


This is an awesome way to verify that both inputs are the same, either off or on.

Next let's cover some basic practice for making your logic in LBP easy to use.

First off, name everything! First and foremost your microchips. Give them a good name that shows what they do. In 3 months if you come back to your level and look at your logic, if there's more than 4 logic gates in it you probably will have 0 clue how it works, or even what it does.

Second, you can name your inputs and outputs too! To add an input to your gate when you don't have something to connect yet, stick a battery outside the MC and grab its wire and attach it to the inputted gate in your MC, then break the connection. Now if you minimize your MC you'll see an input on its left side, neat! But it gets cooler!

Maximize it again and hover over the input, where the glowing triangle gets big and hit the edit button. Lo and behold, you can edit the name of said input, and if I recall correctly you can apply a not value to it too. Whoa!

Name it and then minimize your MC. Grab your battery and hover the wire over the input. Look at that, the name of that input now shows up. This is an extremely important thing to do to keep your MCs user friendly. A well made MC won't need the user to even maximize it up to figure out what connects to what, and they'll be able to hook it up with ease!

The same goes for outputs, once you establish an output connection the same way (hook a gate up to something outside and then break the outer connection to make a static output) you can then hover over it and edit it, and thus name the output so the user knows what value comes out.

MMM is pretty awesome, /golfclap

Now let's do one last tweak to make your MC even more user friendly. If you've noticed that hooking two different inputs or outputs to gates that are close to each other, the lines for the outputs are really close to each other. It's actually pretty easy to separate them farther apart and evenly space them!

Instead of directly hooking up the gate to the outer input of your MC, grab the wire and click just inside of your mc where you want your wire going out. This should stick down one of those little circles with an arrow that represent a continuation of the line. Then grab the output of THAT little circle and put THAT to the output. This allows you to force the outputs to be farther spaced apart, letting your MC become even more user friendly. Alright!

Next up will be complex logic gates, like Toggle and split/combine. To be honest I'm not very fluent with the splitter and combiner so I'm going to experiment a lot with it before I post a tutorial on it.

Hope you enjoy, post any questions you want and I'll try to answer!
2011-01-26 03:11:00

Author:
lionhart180
Posts: 200


In short:
AND = All inputs must be active for it to activate.
OR = One or all inputs Must be active for it to activate.
XOR = Only activates if one input is active and not if more than one or none are active.
NOT = Gates are backwards, for instance:
NAND = Activates when none or one input is active.
NOR = Activates when no inputs are active.
XNOR = Activates when no or at least more than one inputs are active.
(NOT has many many uses depending on the situation, fo instance, when you have a cable connected to various objects and want one to be reversed of how the other one is, instead of having to make a whole new system, you can just attatch one of the wires to a NOT gate and it'll all work. )

- Microchips can and should be named.
- Inputs and outputs can be named.
- Wires can be re-stablished and re-organised by setting them on nothing 1st then connecting the new input that was just made to the switch/ gate, these inputs can also be named as well.


Hope that helps those who couldn't read all, or simply didn't understand!
(or those who didn't felt like understanding. )
2011-01-26 03:58:00

Author:
Silverleon
Posts: 6707


Okay so just to add that if people are still confused about logic gates then try checking out the 'Logic Gate' page on wiki here :- http://en.wikipedia.org/wiki/Logic_gate it should clarify the function of the various logic gates for you (though I think that the original poster did a great job of explaining them), and enlighten you as to just how powerful they can be, especially when coupled with the new sequencers, timer & selector objects, so get reading and in no time you will be building your own virtual memory circuits!, well maybe?....anyone for a 'flip flop' ?2011-01-26 13:32:00

Author:
CloaknBlagger
Posts: 78


Awesome post..very helpful!



Second, you can name your inputs and outputs too! To add an input to your gate when you don't have something to connect yet, stick a battery outside the MC and grab its wire and attach it to the inputted gate in your MC, then break the connection. Now if you minimize your MC you'll see an input on its left side, neat! But it gets cooler!

Maximize it again and hover over the input, where the glowing triangle gets big and hit the edit button. Lo and behold, you can edit the name of said input, and if I recall correctly you can apply a not value to it too. Whoa!

I use this a lot and it's a really great way to manage a lot of wires on a chip. It seems that there's a bug that input/output names revert back to the default after switching to play mode ...is there a trick to making them stick?

Another cool organizational trick with microchips and some other gates is that you can use the sticker tweak to delete the icon on the gate and add your own
2011-01-26 15:13:00

Author:
Chazprime
Posts: 587


One quite nessecary but left out gate was the toggle. It in it self is a binary value. I can't imagine logic without it.2011-01-28 18:04:00

Author:
Unknown User


Wow, this is really detailed. Thanks a ton for taking the time to explain it all.

Unfortunately, I'm an idiot. I haven't played around with the logic yet, but I hope I'm
not alone when I say that I think it'd be easier for me to learn if you gave some kind of
an example for each gate. Something that applies to a gameplay mechanic or an ability
you're giving to something you've created.

I don't want to come across as demanding or anything. It's just that some of us are much
more creatively inclined, so when people start talking logic our brains start to hurt.

Thanks again for the thread!
2011-01-28 23:11:00

Author:
ccapel
Posts: 100


Wow, this is really detailed. Thanks a ton for taking the time to explain it all.

Unfortunately, I'm an idiot. I haven't played around with the logic yet, but I hope I'm
not alone when I say that I think it'd be easier for me to learn if you gave some kind of
an example for each gate. Something that applies to a gameplay mechanic or an ability
you're giving to something you've created.

I don't want to come across as demanding or anything. It's just that some of us are much
more creatively inclined, so when people start talking logic our brains start to hurt.

Thanks again for the thread!


I have a few examples to get you started, they are really helpful to apply these things to a real world problem.

For each Gate they present a real world example.

http://www.play-hookey.com/digital/basic_gates.html

For example. The NOT gate "The door is NOT locked = You may enter"
The AND gate "If I move the switch on the wall up and the light bulb is good and the power is on, the light will turn on" Assuming you have an AND gate with three inputs.
How about the OR gate.." If it Rains OR if I turn the Sprinkler on, the grass will be wet" Notice with the OR gate either statement will be true even if both inputs are true.
2011-01-28 23:59:00

Author:
Krondelo
Posts: 136


LBPCentral Archive Statistics
Posts: 1077139    Threads: 69970    Members: 9661    Archive-Date: 2019-01-19

Datenschutz
Aus dem Archiv wurden alle persönlichen Daten wie Name, Anschrift, Email etc. - aber auch sämtliche Inhalte wie z.B. persönliche Nachrichten - entfernt.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.