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

Adding with counters?

Archive: 16 posts


I know how to make a variable damage health bar using timers, but how would you do this with counters?

I have 2 projectiles, lets say bullets and missiles. Now let's say it takes 33 bullets to destroy an object, but only 2 missiles. I could wire my two impact sensors into two counters, one set to a 33 count and the other with a 2 count, then wire these into an Or gate, but then it would count the projectiles separately. Meaning I could hit the object with 79 bullets but if I then started firing missiles it would still take two to finish the job, rather than adding the missile damage to the bullet damage. It seems I would need some way of adding digital signals rather than analogue signals to ensure that a specific unit of damage rather than a percentage of damage is delivered.

Having trouble working this out, so any ideas?
2012-03-01 22:03:00

Author:
Ungreth
Posts: 2130


Perhaps you could use a sequencer set to position on the bullet-hit counter and a battery, so that when you reach half of it it adds one to the missile counter?
I've been doing my health with feedback loop, and it's just great! (link in signature if you want it). I am obsessive-compulsive, so timers and imprecision scared me, which is why I started using counters, but now I'm addicted to looping signals. And you can still display the health on a timer, using a timer-override, thanks to comphermc. But I guess I don't make you learn much here, I usually learn from you ^^

I guess using multiple counters is better than using a multiple-times pulser, but it might take time if you want to use 10 types of projectiles.
2012-03-01 23:11:00

Author:
Unknown User


Perhaps you could use a sequencer set to position on the bullet-hit counter and a battery, so that when you reach half of it it adds one to the missile counter?
I've been doing my health with feedback loop, and it's just great! (link in signature if you want it). I am obsessive-compulsive, so timers and imprecision scared me, which is why I started using counters, but now I'm addicted to looping signals. And you can still display the health on a timer, using a timer-override, thanks to comphermc. But I guess I don't make you learn much here, I usually learn from you ^^

I guess using multiple counters is better than using a multiple-times pulser, but it might take time if you want to use 10 types of projectiles.

Lol, I never stop learning in LBP. Logic will always hold it's mysteries to me.

I've tried using a sequencer on positional, but not quite how you described, so I'll give your idea a go and see what happens.
2012-03-02 00:03:00

Author:
Ungreth
Posts: 2130


What is the problem with setting the object to 33/100 health, subtracting 1/100 for each bullet impact and 17/100 for each missile impact, all using analog signals through a feedback loop?2012-03-02 00:17:00

Author:
Antikris
Posts: 1340


What is the problem with setting the object to 33/100 health, subtracting 1/100 for each bullet impact and 17/100 for each missile impact, all using analog signals through a feedback loop?

Unfortunately, you can't just subtract or add 17 on a counter as it can only count one at a time, there would need to be a delay of at least 17 frames, and the logic for the delay could get ugly especially if other projectiles are mixing in simultaneously. Also, I'm not sure what you would need a feedback loop for, do you mind explaining? Counters already hold memory.

I haven't tested this, but I think you can just replace your OR gate with a simple adder from rtm's blog. That way, each bullet will be turned into 3% analog signal and missiles would be 50% and it wouldn't matter what order they are added or if both projectiles hit at the same time. When the signal reaches 100%, you can trigger a destroyer. You'll still need a positional sequencer, I think, with a battery at the end to convert it back to digital to trigger the destroyer or else you could end up with 100% analog but 0 digital.

EDIT: in case you can't find it:
http://i600.photobucket.com/albums/tt82/rtm223/adder%20sorter/APhoto_56.jpg
www.lbpcentral.com/forums/entry.php?2107-Analogue-Logic-2-Sorting-amp-Addition
2012-03-02 01:02:00

Author:
Unknown User


Unfortunately, you can't just subtract or add 17 on a counter

I get that. Why would you use a counter? A counter that is partially filled represents just as much of a variable analog signal as a signal that goes around a feedback loop.

The point of the loop is that you can instantly add or subtract fractions with it and it is memorized. Counters just don't cut it when you want to add or subtract more than 1 at once.
2012-03-02 07:33:00

Author:
Antikris
Posts: 1340


The problem with the analog damage counter is that the % output does not equate of the number of inputs you would expect. (I'm working with Comphs design as per tutorial). You would think that a 100% battery would deliver a signal that would fill the damage counter, but it doesn't. It's more like 3/4 full...and a 50% signal around 2/3....while a 10% signal requires 15 hits to fill the damage counter.

I'm primarily an aesthetics guy, not a logic boffin, and this is the first time I've really worked in-depth with analog signals but my friend Cloak n Blagger tells me it's a latency/ frames per second issue. Whatever the case though, I suck at math and I'm looking for a system where the input to output ratio can be measured more accurately, so I don't need to perform mental calculations to work out what % value = X number of hits with a bullet or missile, since 100% isn't equal to 100 incremental input signals.

I'm working with a lot of different objects, each of which will require a slight variation in the damage required to destroy them, so I want to be able to say,ok..this object need 30 bullets or 1 missile, this one needs 50 bullets or 2 missiles, this one needs 60 bullets or 2 missiles, etc. However, if an object needs 60 bullets or 2 missiles, then any number of bullets above 30 should only require one missile to finish the job since half the damage is already done.
2012-03-02 09:53:00

Author:
Ungreth
Posts: 2130


I'm primarily an aesthetics guy, not a logic boffin

I'll see what I can come up with tonight in the game. My brain says it should work, but reality can be a PITA. I'll take your description of your goals in mind and if you're not online I'll send it over (if I am victorious).

Can we agree that bullet damage is a fraction of that of missiles? Say, we make the rule that 1 missile always represents 15 bullets - and not an arbitrary number depending on the object (though that is certainly possible, it just isn't very practical unless you want to dive into 'armor types' ** ).


** Plenty of RTS games have this concept: units are divided into classes like 'small', 'medium' and 'large'; weaponry has a different result against its target, depending on a target's class; small arms fire is effective against small units, while only heavy missiles really penetrate 'heavy armor' - meanwhile, these missiles have little to no effect on small units.
2012-03-02 15:53:00

Author:
Antikris
Posts: 1340


I'll see what I can come up with tonight in the game. My brain says it should work, but reality can be a PITA. I'll take your description of your goals in mind and if you're not online I'll send it over (if I am victorious).

Can we agree that bullet damage is a fraction of that of missiles? Say, we make the rule that 1 missile always represents 15 bullets - and not an arbitrary number depending on the object (though that is certainly possible, it just isn't very practical unless you want to dive into 'armor types' ** ).

Ideally I would like 1 missile to equal 40 bullets, and no I won't be going for different armour types with different ratios.

Using Phorts signal display to help determine the exact strength of my signals, today I worked out that I can fill a timer with precisely 100 bullet hits with the timer set at 0.2 secs, and the analog input (a battery on a microchip that is activated by a pulse signal) set at 3%.

An awkward ratio, and doesn't help much if want only 80 bullet hits to fill a timer. Although taking 100 hits per timer as a basis, I can add a positional sequencer and have the destruction triggered by a battery when it reaches the 8th bar of 10, which is equal to 80 hits. That's the bullets sorted. Trouble is with the 0.2 secs/3% signal strength ratio set for the bullets, that means the least number of missile hits that will fill the timer is 3, with the missile's battery strength set to the max of 100%.

Because there's no such setting as 1.5% on analog signals, 0.2/3% is the lowest ratio I can achieve without losing those decimal units of signal strength that make things so much easier to work with.

Things would be so much easier if counters came with the option to tweak how many increments a single signal would increase them by. Wishful thinking I guess.
2012-03-02 17:24:00

Author:
Ungreth
Posts: 2130


I wouldn't know how to do it with counters, but a 7-bit full adder will allow you to add up to 127 including 0. Using purely combinational logic the result would be instantaneous.2012-03-02 17:51:00

Author:
Ayneh
Posts: 2454


I wouldn't know how to do it with counters, but a 7-bit full adder will allow you to add up to 127 including 0. Using purely combinational logic the result would be instantaneous.

What's a 7-bit full adder?
2012-03-02 18:41:00

Author:
Ungreth
Posts: 2130


What's a 7-bit full adder?

Circuit that adds binary numbers
2012-03-02 18:58:00

Author:
Shadowriver
Posts: 3991


What's a 7-bit full adder?
Like Shadowriver wrote, it's a circuit that adds together two sets of digital signals.

It might make more sense to start from the ground up.

http://i92.photobucket.com/albums/l37/Corporeal/7744c86b.png

An OR gate adds together two 1-bit numbers, labelled A0 and B0. The sum of these two numbers is labelled S0.

0+0=0
0+1=1
1+0=1
1+1=1

The problem is you can't distinguish between 0+1 and 1+1, since both are equal to 1. In reality 1+1 should carry into the next higher order bit or place, like in decimal addition.

http://i92.photobucket.com/albums/l37/Corporeal/a1b610ac.png

By replacing the OR gate with an XOR gate 1+1 no longer means S0 equals 1, but 0. The AND gate acts as a carry out, since it only goes high when you add 1 and 1. Note how the functionality of the OR gate has been split between an XOR and AND gate. This is called a half adder.

http://i92.photobucket.com/albums/l37/Corporeal/4f102d62.png

Now this circuit can carry in as well as out. This full adder is essentially two half adders with an extra XOR gate before the carry out.

If A0 and B0 were high before then Cout would be equal to 1 and S0 would be equal to 0, but now if A0 and B0 are high along with Cin both S0 and Cout will be equal to 1 since a bit has been carried in from a lower order place.

You can chain these together by wiring the carry out to the subsequent carry in of each full adder. If you were to copy/paste 7 of these S0 through S6 will be the sum of the two binary operands A0-A6 and B0-B6.

Here's a 4-bit full adder in LBP to give you an idea of how it'd look in-game:

http://id.lbp.me/img/ft/76dda3778c93c5994078973cd17dec658d2523db.jpg
2012-03-02 21:02:00

Author:
Ayneh
Posts: 2454


What's a 7-bit full adder?

I am not sure what Ayneh is talking about but here is a graphical representation of a 7-bit full adder to just give you an idea....
http://www.lbpcentral.com/forums/attachment.php?attachmentid=39062&d=1330723777

...ummm... not really but its very easy to understand at least.
2012-03-02 21:33:00

Author:
zupaton
Posts: 167


I've finally got it. I ditched the idea of the counter based system once I figured out the optimum ratios for strength/secs, which was 3%/2 secs for the bullet's battery (100 hits per timer), and 75%/2 secs for the missile's battery (4 hits per timer), then added a fast sequenced double pulse to the missile's battery so that 2 increments registered almost simultaneously, allowing precisely 2 missiles to fill the timer. Thus 1 missile = the strength of 50 bullets. Then I outputed the added total of each signal to a sequencer of a 25 strip length, which meant that each sequential battery position would be equal to a single unit within a total range of 100. Now to variate the damage required to destroy each object either by bullet or by missile, all I need to do is adjust the position of any batteries placed on the sequencer.2012-03-02 22:02:00

Author:
Ungreth
Posts: 2130


I thought I replied back to this! Oh yeah, the site lagged... I'll rewrite.

The problem with the analog damage counter is that the % output does not equate of the number of inputs you would expect. (I'm working with Comphs design as per tutorial). You would think that a 100% battery would deliver a signal that would fill the damage counter, but it doesn't. It's more like 3/4 full...and a 50% signal around 2/3....while a 10% signal requires 15 hits to fill the damage counter.
That's with a timer, not with a feedback loop. Feedback loops are as accurate as batteries can be. A 1% battery isn't perfectly 0.01000000000000000000000000. So adding one ten times isn't exactly 10. It might cause some trouble when testing comparison with sequencers, but someone made a round-up tool (actually, it rounds down) for me, which is in my health meter toolkit. I've asked evret to help me, since he made a signal probe which has no delay, to build a round-up tool which would be placed inside the health system itself. For now it's only to use with the picture display tools. Just watch comphermc's feedback loops tutorial, not his health meter tutorial. My toolkit is based on it a bit.
2012-03-04 18:35:00

Author:
Unknown User


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.