BG1, PRELOAD BG2, PRELOAD

Page 1 of 3 1 2 3 LastLast
Results 1 to 20 of 44
  1. #1

    Default How to buffer events (and use it with a counter)



    Hi there again! Remember that previous tutorial, How to make a simple counter? Today we are turning that into a reliable dead body counter.

    N.B.: this tutorial covers the logic that I am using for my new level's custom score counter, but I think a death counter is a much less abstract example. For reader's convenience.




    Here we have a dirty commie sackbot. The pests come in droves and it is best to heat up the cold war a bit and turn them into dust! As you can see, we are using a simple bullet hit detection that triggers a 0.1s timer which in turn kills the bot through a destroyer. Nothing fancy. At the same time it gets hit, it triggers a 1-shot counter connected to a tag. The counter is to make sure that the signal we are creating by activating the tag lasts as short as possible.




    DIE COMMIES!!!




    Here we have our counter logic again and this time not a button but a tag sensor - registering the death of a dirty commie sackbot - triggers the counting mechanism to add up. (N.B.: in the screenie, the sensor is supposed to go into the positive input of the signal combiner, not the negative)

    But these commies won't stop coming and we might just shoot two at once occasionally... Now our tag sensor will fail, because it does not distinguish between one tag active and multiple tags active. What we need to do, is pick up such an exceptional event and fire off multiple pulses into our counter caused by this event.




    Here we are setting up one way to do it. Replace the tag sensor by a new microchip and put two tag sensors on it; one registering (at least) ONE sackbot death tag and one registering (at least) TWO sackbot death tags. In case two die, the first sensor is also triggered and we want to make sure it is either the one or the other. You see that setup demonstrated above.




    Here we've added some more logic. When only one red dog dies, that signal goes out the other side of the chip as one pulse into the counting system. When two traitors of freedom die simultaneously, it triggers the reset of an inverted 2-shot counter. When this counter is reset it activates a small microchip that contains a pulser (a NOT gate feeding itself, creating a very rapid pulse). During a brief moment this pulser increases the counter with two pulses until it is full again and shuts the pulser down. During that time the pulser will have given off two quick pulses into the counting mechanism.

    So, when two stinking commies die simultaneously, it creates two rapid pulses inside the system.

    Perfect, right? NJET!!

    I used to think this would work, but it is an unreliable setup; when after a simultaneous death, during the short moment that the system is giving off two pulses, if another bot dies, this pulse will coincide with the double-pulse going in at the same moment, causing one to get lost.

    Awful commies! Freedom must prevail!!




    Yikes!! What's this thing? It's freedom, baby.

    Again, this is a bit complex, but stay with me, okay? This is multi-channel buffer that stores a single and double death event separately and unloads these events into the counting system whenever there is something to unload; on its own pace, even moments after the dirty commie rightly so bit the dust.

    Two tag sensors, one for one, one for two death tags. They each up a counter of their own through a signal combiner. The counter goes into a positional sequencer that has a battery across its entire canvas. When the counter is empty, the cursor on the sequencer will be on the 0 position and the battery will not give off a signal; however, when the counter is of value 1 or higher, the battery gets activated. Thus the sequencer detects whether a counter's value is not 0. These batteries lead to a 3-gate AND gate.

    On the other side of the chip we have a pulser (the purple NOT gate), leading into each AND gate. This pulser also passes through a red AND gate into the cycle input of a 2-gate selector. Each output of the selector goes to another AND gate. What will happen now is that the pulser causes the selector to rapidly switch between buffer channels; if a channel has a counter set to 1 or greater, it will activate the channel's AND gate.

    An active AND gate goes to the negative input of the signal combiner, causing to count down the channel's counter. When the counter reaches 0 again, the channel stops passing on pulses. But as long as the AND gate is active, pulses will go to an OR gate where all channels send their pulses to; the output of that OR gate goes into the counting system. Also, separated by another OR gate and a NOT gate, these pulses go into the red AND gate, causing the cycling between channels to halt and unload that channels counter. When unloaded, the cycling continues until another filled channel is detected.

    Freedom prevails!!




    Oh no!! Invasion!! Blow up the truck.

    In this last example we'll be blowing up a truck and kill ten commies at once. Our system cannot really deal with ten simultaneous death events. We can extend the buffer logic to include ten channels, but there is another way. We know that a truck carries 10 kremlin dwellers and they will all die at once. So, why not increase our counting system with 10 instantly?




    Here we have such a setup. A dedicated tag sensor registers the destruction of a truck (same logic as with a bot), goes to an OR gate and into the signal combiner that goes into the second selector on our counting logic, upping the count with 10 instantly.

    But what if a truck dies at the same moment that a single bot dies who is causing the count to go up from 9 to 10? Then the truck event and the pulse from the red chip arrive at the OR gate at the same time and one of them is lost.




    Same buffer, but instead of two tag sensors, the two pulses go into their own channel. Enjoy your rock-solid commie corpse counter!




  2. #2
    Sack shane_danger's Avatar
    Points: 9,665, Level: 29
    Level completed: 53%, Points required for next Level: 285
    Overall activity: 1.0%
    100 Experience Points 7 days registered 250 Experience Points Created Blog entry 500 Experience Points
    PSN
    shane_danger
    Join Date
    Apr 2011
    Location
    Remote Moon 2/4
    Posts
    284
    Blog Entries
    2

    Default

    I love the analogies. Great tutorial!


  3. #3

    Default

    Nice tutorial, tho your "commie" hatred baffles me!

    Relying on one shot signaling bit me several times, though. I can't document it ever being missed (I think it happened once or twice), but I definitely know for sure that the signal may sometimes not be caught "in time". Actually, I was planning to make a video about those "asynchronous" tags and tag sensors. That's why, instead of one shot signaling, you may want to use verified signaling to make sure of the time that your receiver end received the signal, then go "boom" on the commie-bot. This "circular" signaling as I'd like to call it has been outlined in my own counter tutorial (the technique should work with any counters, not to compete with yours, your counter does something else, but the stress is on signaling), tho it may need heavy modification for parallel signaling, which you have already solved here. I may get onto that sometime myself. Just a warning for one shot signaling.


  4. #4
    Sackperson Private Antikris's Avatar
    Points: 20,047, Level: 43
    Level completed: 22%, Points required for next Level: 703
    Overall activity: 4.0%
    100 Experience Points 7 days registered 250 Experience Points 30 days registered 500 Experience Points
    PSN
    Stellakris
    Join Date
    Nov 2010
    Location
    Amsterdam, Holland
    Posts
    1,376

    Default

    Quote Originally Posted by hesido View Post
    Nice tutorial, tho your "commie" hatred baffles me!
    Hey, it's Rambo.

    Quote Originally Posted by hesido View Post
    Relying on one shot signaling bit me several times, though. I can't document it ever being missed (I think it happened once or twice), but I definitely know for sure that the signal may sometimes not be caught "in time". Actually, I was planning to make a video about those "asynchronous" tags and tag sensors. That's why, instead of one shot signaling, you may want to use verified signaling to make sure of the time that your receiver end received the signal, then go "boom" on the commie-bot. This "circular" signaling as I'd like to call it has been outlined in my own counter tutorial..
    I'll take a look at that. At the moment, my one-way signaling appears to work, but I have been telling that myself several times over the course of months only to find out later that the score didn't add up with the targets killed. It'd be a severe test of your circular system however; this tutorial only shows 4 buffer channels, while I use 18 in my score counter. I kill a pile of enemies and I see the buffers unload themselves for the next 2 seconds after. If the feedback to the signal's source has to be behind that buffer, then it'd take ages before an enemy blows itself up.

    Your circular system has the same goal as my buffers: to try and make event registration reliable. It is too soon to say, I have to dive into your tutorial first, but we might have built two completely different ways to tackle the same problem.


  5. #5
    Doodler extraordianaire Skalio-'s Avatar
    Points: 16,452, Level: 39
    Level completed: 1%, Points required for next Level: 798
    Overall activity: 3.0%
    7 days registered 30 days registered 100 Experience Points 250 Experience Points 500 Experience Points
    PSN
    skalio-
    Join Date
    May 2010
    Location
    Rainy City
    Posts
    948

    Default

    great tutorial Kris! as ever it was as informative and clear as it was funny

    keep em coming !

  6. Thanks!


  7. #6

    Default

    In your setting, the one shot signalling may *not* cause problems indeed. In the setting that I had problems with position was also important, basically what happened was, the one-shot signal was being given at a specific location, and then the signaler moved on right afterwards. The signal receiver looked for the signal in that specific spot, and normally, it could catch it. But some objects *always* missed it, although the signal was given in that location, it received no signals.

    Took quite a while to figure out, but it turned out that these objects (exact emitted copy of other objects that worked normally) received the signals 1 frame later than others. The one-shot signal was not actually being missed, it was received 1 frame later, but at the new position! The signal was missed because the receiver did not look for it in the new location. So I had to change the system so that the signaler didn't move on until it makes sure the signal is received by the signal receiver.

    I'm assuming, these objects that "live one frame later", are objects that are emitted at times of high complexity to reduce cpu load (probably assigned to a different thread?), but they keep on living one frame later even when you reduce that complexity. If you highlight them and clone them, the cloned objects still live 1 frame later. If you capture them objects, and place them from your goodies bag, they re-sync back to the world!

    I should stress that your system may not have any problems. But I wanted to share my experience with one shot signaling Sorry for diluting your nice tutorial.

  8. Thanks!


  9. #7
    BabyFace
    Guest

    Default

    great tutorial...what happens if you kill said commies faster than said buffer can unload?

  10. Thanks!


  11. #8
    Sackperson Private Antikris's Avatar
    Points: 20,047, Level: 43
    Level completed: 22%, Points required for next Level: 703
    Overall activity: 4.0%
    100 Experience Points 7 days registered 250 Experience Points 30 days registered 500 Experience Points
    PSN
    Stellakris
    Join Date
    Nov 2010
    Location
    Amsterdam, Holland
    Posts
    1,376

    Default

    Quote Originally Posted by BabyFace View Post
    great tutorial...what happens if you kill said commies faster than said buffer can unload?
    Then the buffer will keep unloading the events for a while. The only limit is the size of the channel's counters. The buffer will unload stuff as fast as a pulser frequency can unload it, with the only significant latency being the switching between channels; it is not noticeable with two channels, but try 10 and worst case scenario it takes up to 1 second until the buffer starts to unload the stored events.

    So, it can lag behind sometimes, but the upside of all of this is that it is extremely reliable: you kill it, you get rewarded for it. For one-way systems like score or body counters the lag doesn't matter much, but if you are feeding the results of these systems back into other logic that is timing critical, you may want to reconsider.

  12. #9
    BabyFace
    Guest

    Default

    i guess what i meant to say was what will happen if you fill the counter before it gets to unload. will the nxt kill then be missed? i know its farfetched but it could be possible with heavy action

  13. #10
    Sackperson Private Antikris's Avatar
    Points: 20,047, Level: 43
    Level completed: 22%, Points required for next Level: 703
    Overall activity: 4.0%
    100 Experience Points 7 days registered 250 Experience Points 30 days registered 500 Experience Points
    PSN
    Stellakris
    Join Date
    Nov 2010
    Location
    Amsterdam, Holland
    Posts
    1,376

    Default

    Quote Originally Posted by BabyFace View Post
    i guess what i meant to say was what will happen if you fill the counter before it gets to unload. will the nxt kill then be missed? i know its farfetched but it could be possible with heavy action
    Yes. Set the counters to 100 max, drop 201 sackbots in your level and blow them all up at once. You will miss one kill.

    That is where the truck option comes in.

    EDIT: actually, it will fail to work anyway if you do this; the system is designed to take rapid pulses of single and double kills, not a single blast of more than 2 bots at once. That is indeed what the truck solution is to illustrate.

    Now I need to step off this kill counter example and explain the original purpose of all of this logic: a score counter that receives tag pulses. My system takes 10, 20, 40 and 80 points buffered and also double-10, 20, 40 and 80. It unloads these as pulses of 10 points into the counter (first selector). Then next we have the same setup for 100, 200, 400 and 800 in unloads of 100 (second selector). The truck tag sensor illustrates the 100's score count and how subsystem needs to be buffered with the 10's subsystem as well in order to not fall behind 100 points occasionally.

    The limits of this score system are clear: cannot buffer more of any unit than the size of its counter; cannot detect and buffer triple (or more consecutive) occurences of an event; does not support score event pulses that go beyond the sensors used (max. 100+200+400+800 = 1500 points in one go). Of course, an event can go on pulsing 1500 points 10 times to add 15000 points, but that is not what this system is for; I have separate sensors for high numbers (10k, 20k, 50k boss score bonuses), but they occur on tightly controlled moments (unlike blasting away hordes of enemies) so they don't require a rigid buffering system.

  14. Thanks!


  15. #11

    Default

    I must say, this is fantastic. I had to read through it a couple times before I understood, but it looks great.
    Playing LBP Vita. Making a 'FF Tactics - esque' game.

  16. #12


  17. #13
    BabyFace
    Guest

    Default

    thats the tv you use?

  18. #14

    Default

    Awesome. This tutorial came at just at the right time for my newest creation


    Click my signature to be taken to my art gallery!

  19. #15

    Default

    here is another way you could do the same thing, i'm not good at explaining how things work so i'll just post a pic and give a brief run through.

    basicly it adds the simultaneous points/deaths together then adds them to a feedback loop. it then checks to see if there is 10% or more in the loop, if there is it pulses the 10 output(if you still want to use selectors for final count), subtracts 10% then checks again. when there is less then 10% it checks for 1% or more, if there is it pulses the 1 output and subtracts 1%, then checks again till there is nothing left.
    this setup can handle up to 9 at once, but it's easy to extend the setup to handle as many as you want, if you want more than 100 at once you will need to use custom batteries so you can add/subtract values less than 1%
    in the pic blue batteries are 1%, green are 5%, and yellow are 10%.
    the green ONE chip is just a one-shot counter, and the green chip with the [=] outputs an on signal when both inputs are equal.
    Edit: you may need a one shot counter or a 2 port selector after each sensor to dump the analog signal
    Last edited by evret; 07-20-2011 at 01:17 AM.


  20. #16

    Default

    Quote Originally Posted by evret View Post

    Your one of the few people I know who label there logic. But that is a good way aswell

  21. #17

    Default

    if your referring to the PLUS, MINUS, EQUALS, and ONE chips, i made them and and hearted them coz i use them all the time, it gives me quick access and it saves re-making the same things everytime. i gave a few to robbit10 so you can get them in the creators toolkit if you want them. the other colour coding and stickers on the chip were to make things easier to understand for this thread

  22. #18

    Default

    Very detailed and understandable. Thanks and well done.

  23. #19
    Sackperson Private Antikris's Avatar
    Points: 20,047, Level: 43
    Level completed: 22%, Points required for next Level: 703
    Overall activity: 4.0%
    100 Experience Points 7 days registered 250 Experience Points 30 days registered 500 Experience Points
    PSN
    Stellakris
    Join Date
    Nov 2010
    Location
    Amsterdam, Holland
    Posts
    1,376

    Default

    Your FBL setup has me intrigued. Before I read your reply something like this was going through my head after I watched compher's FBL tutorials.

    I might give my level's buffer another iteration, using this, but other things take priority right now.

  24. #20

    Default

    i had to make a couple of changes since i posted the pic. turns out the XOR in the subtraction part wasn't quite doing the trick, i changed it so the one's part didn't even try to check untill the there was nothing left for the tens part to take (did that make any sense? :P)
    i sent you a friend request so i can show/send it to you if you wanna check it out with rebuilding it yourself

    also the setup in the pic was based on you still wanting to use the selector setup to store/display your total count, however you could use lower values for the FB loop to have it store your total count as well, or you could wrap past 100%, or use both.........
    for example if you use values of 00.1% you could have a count up to 1000, but if you were to wrap it into a second FB loop you could have a total of up to 1,000,000. or a third would be 1,000,000,000 etc etc.

    by wrapping past 100% i mean using logic to make it so when 2 numbers add to more than 100%, say 45 and 90, it can carry the 1 over to a second FB loop and leave the 35% in the 1st FB loop


Page 1 of 3 1 2 3 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •