Home LittleBigPlanet 2 - 3 - Vita - Karting LittleBigPlanet 2 [LBP2] Everything Else LittleBigPlanet 2
#1
Logical Peculiarities
Archive: 14 posts
I've been doing extensive testing of logic gates for my LBP2 Logisim library (https://lbpcentral.lbp-hub.com/index.php?t=38620-Simulating-LBP2-s-Logic-on-a-Computer-using-Logisim), and thought I'd share some of the things I've found. Warning: heavy logic ahead. First of all, as noted by rtm223 (http://www.lbpcentral.com/forums/entry.php?2069-Analogue-Logic-1-Fundamental), each signal wire in LBP2 contains both an analog and digital signal. Which part gets used depends on what you connect it to and what its settings are (this is why you don't need to change the settings on the source of a signal like you did in LBP1). For example, something set to "on/off", "stat playing", "one time" or similar will use the digital part, and things like "speed scale" and "strength scale" will use the analog part. It's also important to note that depending on what the source of the signal is and what logic gates are used it's quite easy to not just have one part have a value and the other be off (for example, a slight tilt of the analog stick will register an analog value but stay at digital zero), but it's also possible for one part to be positive and the other negative (you can run into this if you use OR/XOR or certain combinations of the Splitter, Combiner or NOT). As rtm223 notes, it's generally best to plan a circuit to be either all-analog and ignore the digital signal or vice versa, however there are times when you need to know about both and what effects they have. Just a few bits of terminology I'm going to be using before I get into the meat of it: Magnitude: This refers to the strength of an analog signal without regard to what sign/direction it is. For example two batteries set at 50% and -50% both have a magnitude of 50. Can also be called absolute value. Sign: The direction of a signal (analog or digital). This can be positive (forward/up/right on the controller) or negative (backward/down/left on the controller). Many bits of logic will ignore the sign completely, but some depend on it. One thing worth noting is the Counter will indeed count backwards if given a negative digital input. Non-zero: Fairly obvious, but I'm going to be saying it a lot. It's exactly what it says - anything other than 0. Maximum and Minimum: When I use these, I'm referring to the maximum or minimum magnitude of the inputs. For example, the maximum of 10 and 20 is 20 and the minimum of 10 and 20 is 10, but the maximum of 20 and -30 is -30, and the minimum of 20 and -30 is 20. Also, I'm only going to be dealing with 2-input gates. Adding more inputs is a headache I don't feel like dealing with quite yet. AND gate Anomalies The AND gate is where I first realized that much more testing needed to be done to fully understand how the logic gates in LBP2 work. At first it seems straightforward, and indeed it is if both inputs are positive. The first two rules for AND gate behavior are easy to determine: The digital output of the AND gate will be non-zero only if all the digital inputs are non-zero The magnitude of the analog output of the AND gate is the minimum of its inputs However, I and some other people noticed some odd things happening when doing processing on small analog values from the Controllinator. After testing, I discovered that the sign of the analog output depends on the signs of the digital inputs, and the signs of the analog inputs are actually ignored. With further testing I determined the following rules: The signs for any non-zero parts of the output of an AND gate will be the same The sign of an AND gate's output will only be negative if there are an odd number of negative digital inputs One way to see this is to make a simple rotator. Connect the analog stick from the Controllinator to one input of an AND gate and a battery set to 100% to the other input, then connect the AND gate's output to the rotator. If you slowly pull the stick down (or left depending on which you used), you'll see the rotator move one way (positive) until you get to 75%, at which point the digital signal goes from 0 to -1, the AND gate sees an odd number of negative digital inputs, and the rotator will change direction, even though you didn't change which direction you were pointing the joystick. OR gate Oddities Fortunately, the OR gate doesn't mix analog and digital signals the way the AND gate does, however it does have its own unexpected behavior in a few cases, especially obvious when dealing with the signs of digital signals. As above, the basic behavior is straightforward: The digital output of the OR gate will be zero only if all digital inputs are zero The analog output of the OR gate will be the maximum of its analog inputs, including sign This means that unlike the AND gate, the OR gate will preserve the sign of an analog signal no matter what the digital signal is doing. However, what if the magnitudes are the same but the sign is different? Well, that leads in to where things get odd. It's much more likely to happen with digital signals than with analog (unless you're using batteries for all the inputs), but I've confirmed this behavior with both a logic probe and with counters and rotators. If both digital inputs of an OR gate are non-zero, the output will have the sign of the input on top If both analog inputs of an OR gate have the same magnitude, the output will have the sign of the input on top This means that the order of connections can matter for an OR gate. In other words, +1 OR -1 is +1, but -1 OR +1 is -1. XOR Eccentricity At first the XOR seemed to be the strangest, since as rtm223 noted it depends on both the analog and digital parts of the input. However, as we've seen with AND, it's not unique in that regard. XOR means eXclusive OR, and in normal binary logic it simply means "one or the other but not both". From what I already knew, and after doing the previous testing, I knew what to look for so it was actually easy to determine how it behaves: If zero or one digital inputs of a XOR gate are non-zero, it behaves exactly like OR in all regards (see above) If two digital inputs of a XOR gate are non-zero, it turns off - both the analog and digital outputs are 0 Well, it was long, but I hope some people find this useful. At the least, it may help explain why things sometimes behave unexpectedly (https://lbpcentral.lbp-hub.com/index.php?t=38821-Pressing-on-the-Control-Stick-softly-gives-inverted-controls.) with certain kinds of inputs. (Edit: clarified that XOR turns to zero on digital inputs being non-zero) | 2010-11-01 14:47:00 Author: Balorn Posts: 92 |
Yea with OR gate sends sign of maximum input, same should be with AND imo but with minimum. Surely sign of signal is not numeral sign, at least it's not working that way, it's more like directional information of the signal and has laws of there own. | 2010-11-01 15:14:00 Author: Shadowriver Posts: 3991 |
This makes it prohibitively complex to work with logic in my opinion. As is standard with logic gates, AND should simply be multiplication (of analogue parts and digital parts), and OR should be addition (rounded down or up to stay in range). The trouble is that it is not obvious what the behaviour should be, and the analogue/digital dual signal is not explained to the player at all. | 2010-11-01 18:40:00 Author: thor Posts: 388 |
Good stuff. I've been reading Rtm's blog and I've sort of been able to follow it, but I have to keep it open in my browser whenever I do complex analog logic. Nice to get another perspective. You've probably already figured it out, but the solution to the controller/AND gate issue is to split the signal, run the split signals through separate AND gates and then recombine it. Whether a signal is positive or negative, putting it through the negative input of a combiner makes it negative and putting it through the positive input makes it positive. | 2010-11-01 18:49:00 Author: Sehven Posts: 2188 |
Yeah, there are ways to work around all these to get things to behave how you want (now that their base behavior is known), but some of these are rather... counter-intuitive. | 2010-11-01 18:58:00 Author: Balorn Posts: 92 |
This makes it prohibitively complex to work with logic in my opinion. As is standard with logic gates, AND should simply be multiplication (of analogue parts and digital parts), and OR should be addition (rounded down or up to stay in range). Imo i think this maximum/minimum is more useful gameplay wise, but also i think we need controlled resistor component that will do multiplication operation treating analog signal as percentage (since it is percentage), it would be useful too The trouble is that it is not obvious what the behaviour should be, and the analogue/digital dual signal is not explained to the player at all. I think they don't want to smash people with wall of text documentation since simplicity is there way to go, i'm sure they know we will figure it out everything anyway | 2010-11-01 19:53:00 Author: Shadowriver Posts: 3991 |
I do agree that maybe multiplication and addition would have been more intuitive functions for AND and OR, but then shadowriver has a point - min and max are very useful from a gameplay perspective. I don't doubt that with the given tools we'll be able to reproduce just about any function we could conceivably want - so probably the min and max were chosen as functions that would have more common usage. But back on topic - this is odd. And almost certainly wrong. I probably wouldn't have come across this as I find the min/max behaviour with negatives to be strange regardless of what is right or wrong. I tend to do as sehven describes and split - it's much easier to deal with stuff that way | 2010-11-01 20:48:00 Author: rtm223 Posts: 6497 |
For most players there's nothing intuitive about ANDs or ORs, let alone AND as multiplication and OR as addition. That's just "intuitive" to computer programmers because that's how they know it already. But my guess is minimum and maximum are a lot easier to explain (and thus more "intuitive") to most players. In fact, when I found out the analogue functionality of the AND and OR gates, I wondered why they didn't just call them MIN and MAX gates instead. | 2010-11-01 21:26:00 Author: Rogar Posts: 2284 |
Because on/off signal is still the core of the game and it easier to explain for those who didn't even had a touch with logic circuity. But yea you right, in fact when i was starting thinking how to find a way to select specific value of analog signal first thing that came to head is use of AND gate. Also we need to keep in mind that real digital circuitry something like analog signal not exist and as i know there no theory about logic gate doing something with any kind of analog signal (not to mation electornical analog signal is something very complex and logic gates based on transistors will react to them differently depending what transistors is used) and sum or multiplication in those gates is something that apples only to bool algerbry, where we got only 0 or 1, false or true that whole logic/digital circutry is based on. LBP2 logic is already crazy and out of this world having something like -1 state | 2010-11-01 21:57:00 Author: Shadowriver Posts: 3991 |
Personally, I think the following two changes would make things more straightforward: Make AND gates keep the sign of the minimum input (like OR gates do) In cases of ambiguity, prefer positive signals instead of depending on the connection order like OR/XOR do now At the very least, something should probably be done about AND, since with the Controllinators having such a large initial dead zone for their digital signal it's easy for directions to seem to reverse. (I did submit a bug about that one.) | 2010-11-01 23:33:00 Author: Balorn Posts: 92 |
Okay, noob trying to keep up here. Couldn't the AND problem be solved by runing the inputs through an OR first and leaving the second input of the OR empty?= Source-->OR-->AND<--OR<--Source | 2010-11-02 01:17:00 Author: Biv Posts: 734 |
Okay, noob trying to keep up here. Couldn't the AND problem be solved by runing the inputs through an OR first and leaving the second input of the OR empty?= Source-->OR-->AND<--OR<--Source No, because running a signal through OR with the other port not connected doesn't do anything at all to it (except waste time and therm). The best workarounds are either splitting the signal and processing both, or adding special case circuitry, depending on what you're trying to do. | 2010-11-02 01:59:00 Author: Balorn Posts: 92 |
Hmmm, Just out of curiousity, are there any peculiarities with NOT gates? As far as I know, the NOT gate just does 100 - |input| and so never outputs a negative value, so I doubt it will be affected by this. Any chance you can do a couple of tests with your poking device balorn (I still haven't found the time to break that thing down and work out how it's working )? | 2010-11-02 11:05:00 Author: rtm223 Posts: 6497 |
Well, first of all the poking device I posted a schematic for doesn't work because of AND gate weirdness, but I made a working version and put it in a level (along with my logic probe) if you want to look at in in-game. As for the NOT gates, I haven't done any testing yet, but will once I get home in a couple hours. At least those only have one input. Edit: Confirmed, the NOT gate at least seems to behave exactly as we expected, and does appear to be 100-|a| for the analog part and |1-|d|| for the digital part (I confirmed NOT NOT -1 is 1), meaning it simply ignores sign/direction entirely for both the digital and analog parts if its input. | 2010-11-02 11:24:00 Author: Balorn Posts: 92 |
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.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.