Home    LBP Showcase / Reviews / Recommendations    Object Showcase
#1

Analog Memory Cell

Archive: 36 posts


I've seen a lot of half-baked attempts at creating systems for enemy hitpoints or other variables using convoluted systems of timers or counters that ultimately wind up just being unreliable. So, I decided to sit down and engineer a solution to this problem once and for all. I created a memory cell that allows you to store, retrieve, and perform relative addition or subtraction on analog signals. It's a little complicated to put into plaintext, so I went ahead and made this nice HD video for you guys to see how it works:

http://www.youtube.com/watch?v=MoodoUy12Lw
Basically, the device has 2-4 inputs depending which version you're using. The basic version can store values between -100% and 100% and output that value to whatever you'd like. You can any use any sort of trigger you'd like, such as a button press or an impact sensor, to trigger the "store" function and lock in a value.
The advanced version can only store positive values (for the time being), but allows you to perform relative mathematics. Once stored, you can add or subtract another (customizable) value from the value in memory, allowing for instantaneous calculation, unlike previous counter or timer-based systems that can only count 1 unit at a time. Furthermore, it allows for both addition and subtraction and can have any number of inputs, making it an incredibly versatile tool for a wide variety of applications.
In short, you can:

Store, retrieve, and modify variables.
Create reliable health/ammunition systems.
Have an added degree of control over almost any analog device.
And a limitless amount of other possibilites. Use your imagination!


I haven't published a level to show off or give away the memory cell just yet, but I'm working on it and will have it published sometime this week. In the meantime I wanted to get the word out, since I know a lot of people have been waiting for something like this.
2011-03-09 02:17:00

Author:
Unknown User


A few things:-


Which component are you using to store the analog value, and what method are you using to update it?
What do you mean by "...the only way to input and output an analog value from the same item is through a control stick..."?
With regards to "...you can't use negative values with math...", check out section 2.3 of this blog post (http://www.lbpcentral.com/forums/entry.php?2107-Analogue-Logic-2-Sorting-amp-Addition).
2011-03-09 20:15:00

Author:
Aya042
Posts: 2870


What do you mean by "...the only way to input and output an analog value from the same item is through a control stick..."?

That one really confused me, as well. Once the level's shared I guess it'll be a lot easier to see what he's doing with that sackbot controllinator... It's not particularly easy to follow what's going on in the video, especially with all the logic vacuum-packed.
2011-03-09 20:23:00

Author:
tetsujin
Posts: 187


A few things:-


Which component are you using to store the analog value, and what method are you using to update it?
What do you mean by "...the only way to input and output an analog value from the same item is through a control stick..."?
With regards to "...you can't use negative values with math...", check out section 2.3 of this blog post (http://www.lbpcentral.com/forums/entry.php?2107-Analogue-Logic-2-Sorting-amp-Addition).


To answer the first two, the right control stick on the Sackbot's controlinator is what's actively storing the value. In order to make the memory cell work, I needed an item that I could input an analog value to and get the same value output from it, and it also needed to be able to connect to its own input without changing the value being output. The Control Sticks and the Sixaxis are the only object that allows for this, so I went with the right stick. You could technically have 6 memory cells on a single Controlinator. Anyway, what's happening is that you pulse a signal into the right stick, then the right stick outputs that signal and sends it right back into itself, but it passes through a node first. The node is on a microchip that gets turned off for the duration of the pulse, which then allows whatever the new value is to be set to the stick. When you trigger one of the switches, let's say the "Store" function, a pulse is sent into the cell through an AND gate. The first input is the value that you want to set the cell to, and the second input is just a counter that resets immediately, making the AND gate output a signal at the minimum of its two values (and since the counter gives a 100% signal, this will be whatever the value you want to set is).

Anyhow, I began formulating an idea for working negative values but I'll look over that blog post and see if I don't learn something. I originally designed the resistors and the sum chip for my This is Science level, and having negative values there destroys the puzzle so I didn't really bother figuring a way to get them to work properly. As it is now, the math on the chip delibaretly only outputs positive values, meaning it has a minimum threshold of 0, in the event a negative number is reached. The issue is that if I were to put a negative number into my Sum Chip, the sign would be ignored and it wouldn't give you the right answer (for instance, (-50% + 50%) should give you 0%, but you'd get 100% instead), so I just threw a few Direction Splitters in the circuit and wired the positive leads to the function, treating negatives like zero. Since, as I said, it was designed for a puzzle that emulates electricity, it makes sense that you can't have less than zero power flowing through a wire. In any case, I'll be making a separate version of the cell to incorporate negatives. As it is, the advanced cell is perfect for making health/ammo bars, which also wouldn't make sense if they could go below zero.
2011-03-09 21:50:00

Author:
Unknown User


To answer the first two, the right control stick on the Sackbot's controlinator is what's actively storing the value. In order to make the memory cell work, I needed an item that I could input an analog value to and get the same value output from it, and it also needed to be able to connect to its own input without changing the value being output.

You mean like an OR gate, or a non-inverting NOT gate?

I'm still not clear on what you get out of the controlinator... I thought it was strictly one input per output, and (apart from the threshold logic) pretty much just output whatever comes in... But I haven't played around too much with sackbot controlinator inputs...
2011-03-09 22:37:00

Author:
tetsujin
Posts: 187


You mean like an OR gate, or a non-inverting NOT gate?

I'm still not clear on what you get out of the controlinator... I thought it was strictly one input per output, and (apart from the threshold logic) pretty much just output whatever comes in... But I haven't played around too much with sackbot controlinator inputs...


I tried replacing the control stick with a gate like you suggested, and it doesn't work. I have no idea why it doesn't work, it really does make perfect sense and it would let me create an ordinary microchip. I tried an OR gate, I tried inverting a NOT gate, and I tried using one of those small circuit nodes, but they won't hold their value for some reason. I press the Store function and it lasts a fraction of a second before reverting to 0. I literally moved the two wires from the control stick right to the gate, and when it didn't work I moved them back to the control stick and it worked perfectly, so I know I didn't forget a connection or something like that. I tried it on a brand new microchip, and if you connect a battery to a node and then replace the battery with the node's output it actually will hold its value, but on my chip specifically it's not working. I'm going to attempt to rebuild it from scratch and see if it'll work then, but my working theory is that it won't agree with something in the pulse. I'm speculating that there's something about the control stick that makes it hold its value for one frame longer than the gates, and that frame is really important. I may be wrong, but whatever happens I'll report back and see if I can't imrpove this about a thousandfold if it works.

EDIT:
I experimented with it a bit, and the problem was with the pulse like I suspected. When you send the pulse to the circuit, it would turn off the return node momentarily, resetting its value to zero. At the same time, it would pass the new signal into memory, by which time, when using the control stick, the return node would have been turned back on. When using an ordinary gate, the pulse had already turned itself off before the return node had been turned back on, meaning the new signal would enter the gate and then hit a brick wall. I added a check to the circuit that ensures the return node is on before disabling the pulse, and now it works just fine. I really should have experimented with the regular gates more before tragically overthinking the problem. I'll have a level with the chip published in a few hours.
2011-03-09 23:51:00

Author:
Unknown User


unlike previous counter or timer-based systems that can only count 1 unit at a time.

Not sure where this is coming from... Counters have that limitation, but timers don't. I can't honestly see how this would give any benefit in accuracy over a timer-based system. You're dealing with analogue values in the normal 1% range for each value, so you have 100 hit points. The reason you might be able to claim greater accuracy is because you are using floating point addition / subtraction only and not relying on the inherent division operations used by timers... However, as a timer can happily work extremely accurately in the range of 100 hit points, with an arbitrary number of simultaneous hits of both positive and negative values detected on every single frame, I'm not sure how much more accuracy you might wish to gain from a system such as this? The only I can see is being able to increase or decrease by >33% of maximum at any one time, which is a moderate benefit I'll admit.

To obtain a higher granularity than the 100 pts, you'd have to produce reference signals at <1% granularity, and I may be wrong but I'm pretty sure the only way to achieve that is through the use of floating point division, in one way or another... In addition, you'd have to store each of those values in another memory store (which if you aren't using timers and rather using one of your custom stores is going to be overly complex anyway)...

IDK, I could be wrong, I didn't exactly follow this video at all, bar the bits like basic addition etc. but being a strong advocate of the timer-based health bar, which is basically as lightweight as a timer and the accompanying signal generation parts, I just wanted to see if there really is a claim that this is superior

I would certainly be interested in properly understanding how it works, though.
2011-03-10 00:26:00

Author:
rtm223
Posts: 6497


Not sure where this is coming from... Counters have that limitation, but timers don't. I can't honestly see how this would give any benefit in accuracy over a timer-based system.

Namely, timers don't have a positional input. Correct me if I'm wrong, but as far as I can tell there's no way to instantly add 5s to a timer's count, unless you actually spend 5s letting it count, nor is there a way to set a timer to an exact value barring a reset and then waiting for it count. I have no doubt you could create a system with a whole lot of parts that could match this circuit in accuracy, but I don't think you can match the speed and efficiency with timers. I'm going to suggest disregarding the video at this point since I've drastically improved it and it now fits on a standard microchip, which you'll be able to get your hands on fairly soon. I'll make a new video at some point that goes in-depth on how to build it yourself so you can actually do a lot of the things I described in the video, like adding multiple set, add, or subtract options, since that's really where I think it gets a lot of its strength.
2011-03-10 00:55:00

Author:
Unknown User


Yeah, you can do that stuff timers, speed input is win. As I said, you are limited to plus or minus 33% change in any onesimulation frame but there are ways around that too. Also the timer offers equal accuracy with significantly less parts. Sum your positive change, sum your negative change, get the difference to give total change for this frame and then feed that directly into the timer, which will add this result, scaled, onto it's current value.2011-03-10 01:06:00

Author:
rtm223
Posts: 6497


Yeah, you can do that stuff timers, speed input is win. As I said, you are limited to plus or minus 33% change in any onesimulation frame but there are ways around that too. Also the timer offers equal accuracy with significantly less parts. Sum your positive change, sum your negative change, get the difference to give total change for this frame and then feed that directly into the timer, which will add this result, scaled, onto it's current value.

I have no idea what you're talking about. If I set a 10s timer to Speed Scale and wire a 100% battery into it, it takes 10s to count, and if I set the battery to 50%, it takes 20s. I don't understand what you're doing to make it go faster, but nothing I set it to makes it count any faster than real-time. You're gonna have to be a little more specific, 'cause I've got the parts right in front of me and it's just not happening no matter how I wire 'em together.
2011-03-10 01:32:00

Author:
Unknown User


Why do you need to set the timer to 10s? When you're using it just to store a value, there is never any reason to set it to anything besides 0.1s. Then if you scale the output up 3x, you can treat 1/3rd as full and get the timer to any value in one frame.2011-03-10 01:40:00

Author:
Tygers
Posts: 114


Set it to 0.1 seconds and you'll get 33% change per frame.

the significantly less parts claim from the previous post might not be accurate tho... Still, it's gonna be less components, but if all you want is something to add and subtract values then the store should be nothing more complex than the an signed adder tree looped back into itself. For explicit value setting you could add in a sampler using an or gate and a couple of basic components to block the adder for 1 frame and feed the sampled value back into the output and the feedback loop. Tbh, I think this is what you may be doing, just overcomplicating the issue

the thing to watch with this is exactly where you add the old value into the adder tree. You could screw your results unless you do it at the very end, assuming that we're handling simultaneous addition and subtraction

sorry if this is a bit vague, it's really late and im posting from my phone
2011-03-10 01:40:00

Author:
rtm223
Posts: 6497


Okay, I tried the timer thing, and it's something I might use for a simple system, but that 33% change limitation was glaringly apparent and really ruins it for more in-depth applications (in my opinion).

As far as the number of parts goes, here's the basic cell:
http://i8.lbp.me/img/fl/f38701b15d40e09b4d897850045e0ee8cfef93ff.jpg
This is the one that just stores the value when you tell it to.

And here's the advanced cell:
http://i9.lbp.me/img/fl/349dee6971120f0bbdd03b7f55f8129e4685173a.jpg
The Danger icon is a settings chip where you can set how much to add/subtract when the respective functions are called, and the ones with the monkey on them are just the basic cell.
2011-03-10 02:41:00

Author:
Unknown User


Your explanations are a bit hard to follow and having the circuits jammed together doesn't help...

Consider this:
http://i8.lbp.me/img/ft/ae8968fd6ad6fdfe648081136f7999ca18b4ebb7.jpg

It's a simple implementation of a D-latch. The top input is the signal, the bottom input control whether the output follows the input signal, or the last value that was stored. Note that the latch basically handles the digital and analog portions of the signal separately:if you gave it a latch-trigger signal of +1/0.0 it would update its digital state but not its analog state... So to use the latch for analog data you must provide it with a 1.0 analog value for the trigger.

It works pretty well, though it loses the sign of the analog signal. (The AND gate takes the sign from the digital signal and applies it to the analog signal) You can solve that by using direction splitters and combiners:

http://i3.lbp.me/img/ft/853ca71c468dd060caddede6ddc5218369ce7c6b.jpg

It looks a bit more complicated, but the logic's the same: "Follow the input if latch is high, preserve the last value if latch is low".

Of course, if the output is feeding back into the input (for instance, a subtraction involving the output is being used as input) you don't want the output of the D-latch to continuously follow the input, you want the output to update once, in response to its input, and before that input has a chance to change.

In a real circuit you could do this by hooking two D-latches together, and inverting the "latch" signal to one of them, this creates an edge-triggered "D-flip-flop"...

http://i3.lbp.me/img/ft/af337103913755a571fb798b957ba8521b168a8f.jpg

The result here is that when the trigger signal goes low, the first D-latch starts following its input while the second one preserves its last input... And when the trigger signal goes high again, the first D-latch preserves its last input, and the second follows its input (the output of the first D-latch)

Of course, it can be a little simpler in LBP since time is broken up into discrete chunks: you can simply filter the "latch" signal through a one-shot...

http://i4.lbp.me/img/ft/ef485249ba2138649178996a48f35f03323a62f4.jpg

(The one-shot here is a 1-step counter, self-resetting)

You can then use the edge-triggered D-flip-flop as the basis of a triggered decrementer circuit:
http://i4.lbp.me/img/ft/a548231a191415c52597b3623b83d963b8b6bd57.jpg

In this case, the output of the D-flip-flop decreases by 5% (the battery value) each time the trigger input goes high. (Note the subtraction here doesn't guard against underflow - add a direction splitter after the combiner to change the output to 0.0 on an underflow condition)

One thing to note about this method of storing a value (as compared to timer storage) is that the circuit relies on feedback, and therefore loses its value if the circuit board it's on is deactivated. (Timers retain their value while their host circuit board is deactivated) This may also have an impact on thermo if you use a lot of them (I'm not sure).
2011-03-10 07:15:00

Author:
tetsujin
Posts: 187


Looks liek your going roughly in the direction I was thinking tetsujin. Also, for a generic system I'd probably create the cell with a "modify" input, taking a signed value to do a += style operation (this works for atomic addition and subtraction). Then a simple edge triggered "set" signal (where you would you break the circuit from the main feedback loop and force the cell to match an explicit value from a 3rd input). No other components should go into the actual "cell" as anything beyond that is application-specific.

As for the limitations on the timer device. Yes, in my first post I mentioned that the limitation was a +/- 30% change. It depends on applications and I don't think either lends itself better to more "advanced" or "in-depth" applications. In many cases you can go more "in depth" because it lends itself to working with higher levels of granularity as it implicitly scales values for you.


@fatal gear, I'm sure those circuit layouts feel compact and neat to you stylistically, but no one is ever going to be able to follow stuff like that, the following is just a block of squares to me, as I'm sure it is anyone else. The only way I'm going to understand that is if I rebuild it myself from first principles:

http://i8.lbp.me/img/fl/f38701b15d40e09b4d897850045e0ee8cfef93ff.jpg
2011-03-10 08:13:00

Author:
rtm223
Posts: 6497


The thing I can see timers failing with is the "you're dead already and just don't know it" effect you get from big damage. That was a minor issue in the Tank damage system, where it was just a counter on, telling a timer to pulse, until a counter fills (10x damage I think), and then reset the first counter so the main health timer would stop subtracting... but I haven't really built one since that first week or anything that can be one chip changing it's timer states for multiple damage types.

There's probably a million ways to streamline or improve this stuff, but the seemingly instant jumps here might be actually be really practical as a way to have the matching sequencer keep AI and actions at the ready for an NPC or sentry etc then you could tag your environment with battery variable tags, have your addition and subtraction operate off a signal strength tag sensor, and he should theoretically be able to understand his own environment (like, notice the calender girl poster on the wall as a distraction), even if your player is pursued from room to room, and would let you place one sentry in any area, create objects that affect behavior, and assign locations a tag. With no cycle time through the sequencer, he's going from happy to mad when he sees you, instead of happy, to all the AI you have inbetween for a half-a-sec, before getting mad.
2011-03-10 13:47:00

Author:
Unknown User


A few things:-


Which component are you using to store the analog value, and what method are you using to update it?
What do you mean by "...the only way to input and output an analog value from the same item is through a control stick..."?


Never mind. I worked it out last night.

The answer to #1 is that the value is stored in a feedback loop, and the answer to #2 is probably that it's just a workaround for some sort of latency issue - the Controlinator probably breaks the feedback loop from the game's POV, and forces the components to update in the correct order.

It's actually kinda neat, as it means you don't need to update a Timer, which is limited to deltas of 33% of max value per frame. The only difference, as far as I can tell, is that it's volatile (you'll lose the value if you deactivate the chip), which may or may not be desirable.

Most of the designs for arbitrary-offset HP counters I've seen so far are based on a register and an adder, where the adder feeds into the register, and the register feeds back into one input of the adder. For analog the register is a Timer, and the adder is a Direction Combiner, and for digital, it's mostly using traditional designs (flip-flops, etc.).

But, it occurred to me, why even bother having a register? As long as the other input of the adder is set to zero, then, for the analog case, feeding the output of the Direction Combiner directly back into its positive input, then pulsing the negative input with a small analog value for a single frame, pretty much gives you a one-component HP system.

Okay, so you'd still have to initialize it, and ensure that the subtracted values are only active for a single frame, but the former need only be done once (the value in the feedback loop is retained even if you capture/replace it), and the latter could be done by your projectiles.

To be able to set it to a fixed value at 'runtime' would require something more like this...


http://i8.lbp.me/img/ft/ae8968fd6ad6fdfe648081136f7999ca18b4ebb7.jpg

...which is the exact same circuit I thought of last night, and by the looks of the rest of tetsujin's post, I went through pretty much the exact same thought process, i.e. start with the 'D-latch', and feed back either the current value, a constant value, or a value relative to the current value.

The only difference I might make for an HP bar would be to remove the edge-triggered nature, and leave the responsibility of pulsing the input to the projectiles, which would allow for a 30Hz update instead of 15Hz. Okay, you'll still need some extra bits n' pieces if you want to detect multiple hits per frame, but that's true of any design.

Comparing to a digital design, the only disadvantage would be accuracy, but it occurred to me, if you limit your input values to fractions expressible in IEEE754, even that may not be a problem, as you end up effectively using the 23 bits of the significand as a digital system, hopefully with no accuracy loss.

If that works, the only real argument to using digital would be if you require more than 23 bits, but I really can't see many cases where you'd need more than 8 million discrete values. As for getting the right values, it can be a pain given the problems with Timer inaccuracies, but...


...if you connect a battery to a node and then replace the battery with the node's output it actually will hold its value...

...this is something I also noticed during the beta. Once you have a fixed value you want, you can store it in a node like this, and you can capture it and retain the value too.

Perhaps I can finally throw all my digital stuff in the bin, although I'll miss all the arguments with rtm.
2011-03-10 15:06:00

Author:
Aya042
Posts: 2870


oh Gawd!!!!!!!! if i ever want to feel inferior, i know where to come!!! look, i'm basically Fick... so with that in mind, could someone (anybody) please explain in real terms how this stuff can benefit LBP2 game creation? imagine you are talking to a chimp. thanks

so in Sesame street terms: GO!
2011-03-10 20:23:00

Author:
GribbleGrunger
Posts: 3910


could someone (anybody) please explain in real terms how this stuff can benefit LBP2 game creation?


In his initial post Fatal Gear described using this stuff as the basis of a hit-point system. Unlike the regular projectile sensors, etc. this kind of system would allow you to assign different damage levels to different attacks and also do things like restore a certain amount of hit-points (when collecting a healing item, etc.)
2011-03-10 21:01:00

Author:
tetsujin
Posts: 187


Thanks for this.

It took me a while to figure out what you guys were going on about, but once I got that, it's very cool. I didn't watch the whole video as it was impossible to tell what you were doing with your logic, but Aya helped me figure out how to use a combiner with a feedback loop to create some really interesting stuff.

The first thing I did was create a system that could increment instantly up or down at any desired increment size you'd want. No longer am I limited by the 33% per frame method using timers. The only problem that I foresee with such a system is how to make it apparent to the player. The nice thing about timers is that they can be used as a visual indicator. Also, for obvious reasons, this system has a maximum of 100 increments/steps.

Thanks again for everyone's input here.
2011-03-12 00:34:00

Author:
comphermc
Posts: 5338


The only problem that I foresee with such a system is how to make it apparent to the player. The nice thing about timers is that they can be used as a visual indicator.

Attach the wire containing the analog value you want to display to the positive input of a Direction Combiner, the output of the Direction Combiner to a Timer (Target Time = 0.1s, Input Action = "Speed Scale"), and the output of the Timer to the negative input of the Direction Combiner, and the Timer will act like a Sequencer's "Positional" mode. It still has the limitation of taking up to 3 frames to switch to the right value, but that's inherent to the Timer.



Also, for obvious reasons, this system has a maximum of 100 increments/steps.

Sure, if you're using batteries to provide the signals for the deltas, but you can create much smaller values using Timers, e.g. the video in the OP uses a Timer (Target Time = 5000.0s, Current Value = 0.1s) to produce 50,000 increments.

Based on my (not particularly great) knowledge of the implementation, I'd say you can get about 224 discrete values with perfect accuracy, or if accuracy is less of an issue, you can represent signals as small as 2-128 of the value of a battery set to 100%.
2011-03-12 16:59:00

Author:
Aya042
Posts: 2870


It still has the limitation of taking up to 3 frames to switch to the right value, but that's inherent to the Timer.

Actually, it takes a lot longer than that as you are only moving 1/3 of the difference between current value and target value (the one you are feeding into the positive input) per step... so if are moving from, for example, an actual value of 100 to a target value of 50 (assume 50 is unchanging) your values will be:



100.00, 83.33, 72.22, 64.81, 59.88, 56.58, 54.39, 52.93, 51.95, 51.30, 50.87

(so a good 6-7 frames before your display is close to the target value).

This can actually be a quite nice effect aesthetically - you can account for damage immediately and then display transitions over a very short period of time (even going to the extent of putting a smaller maximum limit than 33% if you want). If you don't want that visual effect, I'd suggest triplifying the signal. You'll need overflow handling if 33% max change is too small and you'll also need signed value maths if you need to accommodate for both positive and negative changes in value - i.e. damage and healing. Once you've done all that, you will move immediately to the target point, or 33% closer, whichever is the smaller step, so you will always get there within 3 frames.

It's quite useful to know this and I've specifically used it to force a decreasing timer to trail off and never quite reach 0 (and thus keep it's digital value outputting a 1) under certain user input conditions. There were other ways to achieve this, but this one actually worked out rather neatly for me.


I'm currently seeing the issue with this as a health bar being that I'm currently working with a number of damage sources that are a combination of factors that have to be communicated to the recipient of the damage (namely weapon strength and distance from epicenter). I want those two values to determine the damage, based upon some mathmatical function I forget the details of. I can get a value for this easily, but with the timer I can easily have that same value transferred to each unit, regardless of their total damage, assuming that the units with higher levels of damage are using longer time timers...

In this case, you basically have to modify the damage value at the target, to account for different amounts of health that each unit has... It means that for more "in depth" ( ) applications you have to hard code the damage into several targets and thus treat every case as a special case, which is pretty poor design. You won't inherently be able to communicate any damage values to the target dynamically (if you have the +5 hit damage for weilding the Mace of Pwnage), so I'd question anyone claiming that the larger deltas fundamentally make this a better method, or a more sophisticated method for everything - application specifics are always the key.

Of course there is an alternative to this hardcoding, which is to actually subtract values from your units' health, or bias in some other way... i.e. lower toughness units have only 20% health to begin with (for example), or you allow higher toughness units to drop into the negatives before they are considered dead... Either way will add complexity if you wish to display heath at all.


In fairness I've been toying with the idea of forcing units to start at 20% or so for the reason that it improves your ability to tune gameplay, so that whole thing about it adding complexity is kinda moot in my case, it's as much of a pain with either system, though the method proposed here will force you to use smaller numbers for your damage (which again are harder to generate dynamically) if you want larger amounts of health.... ATM I'm almost certainly gonna be working with something modular enough that I can swap between the two if need be...



Perhaps I can finally throw all my digital stuff in the bin, although I'll miss all the arguments with rtm.

You think I wouldn't find ways to argue with you anyway?
2011-03-12 17:54:00

Author:
rtm223
Posts: 6497


Actually, it takes a lot longer than that as you are only moving 1/3 of the difference between current value and target value...

Sure. My point was more that given the maximum possible change in one frame (0->100 or 100->0), you're never gonna get the Timer to update in less than 3 frames, regardless of any delta amplification circuit you care to use, but, as you say, for a Timer-based display, aesthetics are more important than accuracy - which is not true of the internal math representation.

Of course, you don't have to use a Timer to actually display the HP bar. A Positional Sequencer could be employed to light a small number of hologram pieces, which could also be of different colors to give an additional visual cue.



(lots of stuff about a specific application)

If I'm understanding correctly, you effectively have a number of different units with different max HP values, but want to deal the same damage to each unit.

If I were using a Timer for display, I'd probably use the same deltas in the internal math, but scale the HP output value by 100/(max HP) before applying it to the Timer display, assuming that's possible.

But, TBH, I'd probably cop out and use a custom holographic display as I mentioned above, so I could use identical logic for each unit, such that units with fewer max HP have fewer pieces of hologram lit to begin with.



You think I wouldn't find ways to argue with you anyway?

Of course, but at least it'll be something other than the old analog vs. digital argument.
2011-03-12 19:31:00

Author:
Aya042
Posts: 2870


Going away from all this discussion about health bars and the like. I actually created exactly what you described to get my upgrade logic to work properly.

I'll post a pic of it as soon as I find where I put it.

EDIT: Well, it's very similar.

EDIT 2: I seem to have lost it. Either that, or I trashed it for a less thermo intensive method, which I am failing to find as well.
2011-03-18 17:48:00

Author:
SSTAGG1
Posts: 1136


Your explanations are a bit hard to follow and having the circuits jammed together doesn't help...

Consider this:
http://i8.lbp.me/img/ft/ae8968fd6ad6fdfe648081136f7999ca18b4ebb7.jpg

It's a simple implementation of a D-latch. The top input is the signal, the bottom input control whether the output follows the input signal, or the last value that was stored. Note that the latch basically handles the digital and analog portions of the signal separately:if you gave it a latch-trigger signal of +1/0.0 it would update its digital state but not its analog state... So to use the latch for analog data you must provide it with a 1.0 analog value for the trigger.

It works pretty well, though it loses the sign of the analog signal. (The AND gate takes the sign from the digital signal and applies it to the analog signal) You can solve that by using direction splitters and combiners:

http://i3.lbp.me/img/ft/853ca71c468dd060caddede6ddc5218369ce7c6b.jpg

It looks a bit more complicated, but the logic's the same: "Follow the input if latch is high, preserve the last value if latch is low".

Of course, if the output is feeding back into the input (for instance, a subtraction involving the output is being used as input) you don't want the output of the D-latch to continuously follow the input, you want the output to update once, in response to its input, and before that input has a chance to change.

In a real circuit you could do this by hooking two D-latches together, and inverting the "latch" signal to one of them, this creates an edge-triggered "D-flip-flop"...

http://i3.lbp.me/img/ft/af337103913755a571fb798b957ba8521b168a8f.jpg

The result here is that when the trigger signal goes low, the first D-latch starts following its input while the second one preserves its last input... And when the trigger signal goes high again, the first D-latch preserves its last input, and the second follows its input (the output of the first D-latch)

Of course, it can be a little simpler in LBP since time is broken up into discrete chunks: you can simply filter the "latch" signal through a one-shot...

http://i4.lbp.me/img/ft/ef485249ba2138649178996a48f35f03323a62f4.jpg

(The one-shot here is a 1-step counter, self-resetting)

You can then use the edge-triggered D-flip-flop as the basis of a triggered decrementer circuit:
http://i4.lbp.me/img/ft/a548231a191415c52597b3623b83d963b8b6bd57.jpg

In this case, the output of the D-flip-flop decreases by 5% (the battery value) each time the trigger input goes high. (Note the subtraction here doesn't guard against underflow - add a direction splitter after the combiner to change the output to 0.0 on an underflow condition)

One thing to note about this method of storing a value (as compared to timer storage) is that the circuit relies on feedback, and therefore loses its value if the circuit board it's on is deactivated. (Timers retain their value while their host circuit board is deactivated) This may also have an impact on thermo if you use a lot of them (I'm not sure).

Hmm when I implemented this for my level, it did in fact retain the sign of the analogue signal... or thinking about it, it may have just retained the sign of the digital signal, but still, I refrain from duplicating a circuit and using direction splitters/combiners because there is usually a simpler solution.
2011-03-21 14:21:00

Author:
thor
Posts: 388


Good work. I hope we'll have a decent toolbox of custom made logic available for all creators eventually. A lot of time goes into making these systems, and it would be a lot nicer to just pull health logic or similar from a bank of community items.

I do however kind of wonder how useful these ultra accurate health systems really are. I find it hard to imagine a situation where I need to subtract / heal more than 33% of max health in a time period of 0.033s. Especially since you can always kill an enemy in one hit by overriding the health bar and do a full heal by resetting the health timer. I mean, isn't it a bit too much to be able to accurately deal 54 234 / 100 000 points of damage? I don't see the practical application.
2011-03-22 00:15:00

Author:
Linque
Posts: 607


Great i was trying to figure and i figured the same circuit lol XD But i go far as that first one that loses sign. Also interesting to note:

-Feedbacked XOR Gate can also faction as sampler, so it not always capture the signal due ticking, feeding with 0,1ms but it makes lentency.
-Feedbacked OR Gate also stores maximum record of analog signal and can be reset with AND gate on feedback, but thats the basis why tetsujin's circuit work so you guys should know that already
2011-03-24 00:05:00

Author:
Shadowriver
Posts: 3991


Not sure how far you all got in recreating this, but I just created something with the exact same functionality. It's a logic system with a timer that can adjust to 864000 values instantaneously (although it seems to carry momentum slightly past the value, then return to it)

It's pretty much a perfect damage system (...yes, I made another, but I'm pretty sure that this is absolutely the best, since it has a display, which my last did not).

How it works is by using a slightly modified version of my health system, with only 6 parts added on to make the display.

Epic? I think so. I'll have a vid/pic tut up eventually so that everyone can learn to use it.
2011-06-01 01:23:00

Author:
SSTAGG1
Posts: 1136


I guess I'm waking up a subject a bit, but I've always wondered why did signal keepers have two inputs ? I made my own signal keeper with only one input. You just have to hook an analog pulse signal to it and it works. The only problem : to set it to 0, you need to disable the chip with it's override. This is the chip's logic :
http://i5.lbp.me/img/ft/8956c40d423945326f6f01885263a67206029842.jpg
the selector part is just a analog-to-digital converter. When the input is on, the output is the input. When the input is off, the output is the stored number. To reset it to zero, you must override the chip because it will set the loop between the or and the and off

I had this idea while building my health meter logic with feedback loops. This is cool because you just have to place your logic between the OR and the AND to lower and higher the signal and voil?: health meter system. I find this way more useful than any other signal keeper or d-latch I've seen. I can now override the current health during the game. Yay!
2011-08-06 03:24:00

Author:
Unknown User


You have idea that to sent the pulse you need a 2nd input somewhere else trigger it, don't you? That input replace function of a set you removed, memeory cell without set input it's useles,s since how it will know when to read and remeber analog signal?

Thru idea of useing digital signal as a set is cool too, still older curcit gives full control
2011-08-06 04:33:00

Author:
Shadowriver
Posts: 3991


not sure to understand what you mean. My logic always take the signal if there is one, but it doesnt if it is zero. So you cant store a signal from a joystick, because it would progressively come back to zero so it would store 0.0001 or something around. I find this useful as I just hook a OR gate to the input, make my health logic inside and make the logic pulse to make the health go to a certain point. With the other one, I would have to make the % signal on, then pulse the other input, then set the signal off.

I understand you might prefer to have a pulse if you want to be able to set it to zero and to keep a constant signal to it. But I prefer mine. Each has its own use I guess.
2011-08-06 04:58:00

Author:
Unknown User


It's not about ability to store 0, you saying that you send "analog signal pulse", you need to trigger that pulse with something and that trigger becomes your set input that you removed from original circuit, you could place that AND gate or microchip on and off trigger (what else you could use?) inside microchip and your circuit would look exacly the same from outside. Note that in original circuit you got AND gate connected to set and value input to feed the feedback loop, it work the same as trigger pulse that feeds you your version memeory cell. Your circuit is not much diffrent from original, you just store set input part outside the memory cell and thinking that you removed it from whole idea, you just feed feedback loop from multiple sources by Or gateing them and have lock on 0 value, which seems to be more optimazed for your use.

In other words, you said you don;t understand why 2nd input is needed, im telling you not removed it just displaced it somewhere where else. Again, memeory cell is useless without set input, without it your curcuit would just be 0 signal filter.
2011-08-06 12:14:00

Author:
Shadowriver
Posts: 3991


@pivott: When the input does not have a "digital on" signal, the input will not be stored, in your chip. It may indeed work in specific settings, tho. I think for general purpose use, the d-latches I use in the "detect changes over analogue signals" is currently the most ideal.2011-08-06 12:48:00

Author:
hesido
Posts: 166


My chip works perfectly, with both positive and negative. I've worked a bit with the d-latches and all, and now that I understand more how Aya's version works, I do understand what you mean. Yes, it is better with yours, cause all you have to do is make the same analog signal pulse to both of your inputs and ta-da you got mine. I just thought "why are peoples using so complex logic" and I now understand it. XOR gates scared me a bit I guess.
From Wikipedia :

In fact, any logic gate can be made from combinations of only NAND gates or only NOR gates.
Okay... Read this ! (http://en.wikipedia.org/wiki/NOR_logic)
Wow, I didn't know that...
Now the XNOR... Ok, the XNOR is ON unless there is only one on. Logic... Aherm, yes, I'm still here. So I just thought mine was simpler, but I guess yours is better. Yup...

I also didn't know you could pulse both signals at the same frame and it would work. I thought you had to start the analogue signal before pulsing. But then that would be dumb cause it means it would capture the previous frame's signal, so I were stupid... Never mind, I got it. I learned something new today (or in fact that was yesterday but... oh no, it was 1:20 AM, so it was today...)
2011-08-06 19:35:00

Author:
Unknown User


...I've always wondered why did signal keepers have two inputs ?

Well, it's just the convention for a D-type latch (http://en.wikipedia.org/wiki/Flip-flop_(electronics)#Gated_D_latch). Real-world electronics won't let you send a separate analog and digital signal through the same wire.



I made my own signal keeper with only one input.
http://i5.lbp.me/img/ft/8956c40d423945326f6f01885263a67206029842.jpg

Which works fine for your application, but it does have a number of weaknesses. You may as well just use this design...

http://i5.lbp.me/img/ft/e0527fe888eab8ff9010121c9855a6ae2ad4eb18.png

...feed the same signal into both inputs, and save yourself a component.
2011-08-07 02:57:00

Author:
Aya042
Posts: 2870


Awesome, I believe this is a great break through on lbp tech2011-08-19 14:49:00

Author:
comeroiroc
Posts: 157


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.