Skip to main content

Search

Fire pulse every logic update? (E.g. continuously)

  • AndymationB

    I'm not sure I'm fully grasping your intent, but the signal manipulator gadget has a "Pulse on input" setting.

    I don't know what you mean but "every time the Dreams logic updates". It updates every frame. The most rapid pulse I know of is by wiring a not gate into itself, which will then output a pulse every other frame.

    What signal is going into your counter now?

  • TAPgiles

    Inputs that trigger something tend to look for an "on edge" (a signal that goes from 0 to positive), and then do something when that happens. If there's a positive signal being sent every frame, then it's always positive and will never have that "on edge" to trigger the behaviour.

    If you want to count +1 every logic frame, you can use a calculator. Set it to A + 1. Then wire the result back into A. This will add 1 every logic frame.

    If that doesn't work for your case, let me know a bit more about the situation and I'll see if there's some other solution.

  • Skn3--

    Andy:
    I guess I was thinking and speaking in how the Dreams logic might run at the code level. E.g. each game loop in Dreams the logic would update and we would expect that our logic circuit will run though once.

    So currently a pulse only triggers in certain gadgets when it has gone from off to on. Which makes sense because otherwise it’s not “pulsing” is it. But the issue is that effectively you can then only ever run your logic that requires a pulse, every other frame. Because it has to go off Pulse off Pulse off Pulse and so on. It’s sensible in that it “makes sense”.. but it limits the speed in which we can run calculations. Imagine you wanted to traverse a chess board. Your gonna have to pulse your scanner a ton of times to checkout each tile.

    So my question is wondering if there is some “magic” way we can trick Dreams to skipping that “off” phase but still pulse each update.

    Tapgiles:
    Yeah your right (see above). So the calculator idea sounds plausible, I was experimenting with that but it’s not quite right for my case.

    So basically I am trying to make a “better” state machine chip then the built in one. I want to have prev, next, and reset state inputs. So the calculator doesn’t quite work.

    I am trying to have the inputs trigger once per logic update. So effectively we could move the state on 1 (or back or set) each logic tick!

    Any ideas?

  • cgCody

    The solution then is to have two pulses that alternate (first pulse > not > second pulse). This is done in real electronics logic as well (when increasing the clock speed isn't an option.). :)

  • Skn3--

    Interesting! I will try this!

  • cgCody

    On second thought, maybe not. I fiddled around a bit, and the fastest pulse I could achieve was 15 pulses per second, which was done by wiring a NOT gate back into itself, and into the counter. Two of these NOT loops alternating just amounts to a solid signal. *shrugs* You could alternate incrementing two counters with this for a combined 30 pulses/second, but not the one.

  • AndymationB

    If it's a state machine you're after, Suppose/TAPgiles (same dude, two accounts) may have built what you're looking for in his "Wire Freezer". It uses a selector and two signal manipulators set to freeze output. Each one freezing every other logic frame. He has it freely available, if you want to check it out.

  • TAPgiles

    If you want to always go "next" every frame, you could use the calculator method and plug it into a selector's "active port" input. But I'm not sure that will help.

    I'm really not sure what you're trying to do, to be honest. If you could give me a concrete, simple example of some behaviour you're trying to create, perhaps I could figure out a way?

  • Skn3--

    The built in selector gadget is a little cumbersome though and seems a little limiting in its nature, which has lead me on this logic quest.

    So I have a chip nearly finished last night. It has 7 inputs:
    -next (on/off)
    -prev (on/off)
    -set (on/off)
    -set value
    -reset (on/off)
    -min
    -max

    And one output:
    -current

    So all of the (on/off) inputs work without a pulse, so any “true” value will cause them to activate. Certain things override each other. For example if you try and next/prev at the same time then it uses an XOR to cancel them out!

    Thanks for the tip TAPGiles about using the calculator as the value store. So I basically have the calculator feeding back into itself and then the second wire is a + operation. If I want to add I just pass a +1 into the second wire. Subtract I pass a -1.

    So every loop it might do value = value + -1. Or if nothing is currently “on” it will do value = value + 0.

    There are also conditions for checking the min/max range. And finally some logic for dealing with setting the value when the set is “on”.

    Just gotta iron out one big and then it’s done. So what is it for? Basically it’s a “pro” version of the counter. You don’t have to rely on pulses so can use it for continuous logic calculations.

    Perfect for a state machine! Imagine wiring each state output back into itself into the “next” input. So the state machine will loop through its state as quickly as Dreams allowed with its logic update ticks!

    Once it is complete, I can embed it inside another chip.... a state machine chip. This will have predefined logic to output a wire per state. Like we have with the selector.

  • Skn3--

    So finished the chip! Will publish it later/tomorrow. Ran out of time and I have to go out!

    Here is a video showing it in action.
    https://youtu.be/6HRauqc1aFo

    So it’s a pure Boolean / Expression based counter chip! Doesn’t use any signal manipulators, counters, sliders, etc etc! So it should be incredibly efficient!

    Doesn’t require any pulses to operate either!

    (Obviously I need to tidy up the wires)

  • AndymationB

    I'm not a trained computer science guy, so I'm not sure I get it. What is this chip used for? What kind of gameplay mechanics does it enable?

  • Skn3--

    Well it is just a better version of the Dreams counter kind of. But the benefits are that you can run your logic from it faster then you could a standard counter.

    So in terms of game logic. Imagine you had a game that plays on a 2D grid. What if you wanted to check all the tiles around you. To do that your gonna have to run lots of logic and repeat in a loop until it’s done. You would use some kind of detector block that has lasers or trigger zones. The faster you can run that logic, and move the dector block around the grid...the faster your game "thing" can happen.

    So a good example of that could be the game poyu poyu. In that the poyu beans squish’s into each other when they share the same color. If you have a group of nine then they turn into a big blob.

    To do that you would go over each tile in the grid and check the surrounding tiles. If any matches then you update what the current tile looks like. Is it a corner, edge, middle bit and so on. If this operation is slow, you will see weird artifacts in your game where the board hasnt updated quick enough.

    So with my counter you could easily use it to tick along those expensive logic checks at the fastest rate Dreams allow. If we were to use some of the built in widgets, they rely on pulses. Pulses only operate every other frame... so you can see already you have doubled the time it would take your logic to perform this "thing"! Simply because you are spending half of the time waiting for pulses to go from off to on!

    The chip isnt a magic wand or anything, I am making it sound super human! In reality its just a counter but its designed as a building block for doing counter-ie-stuff-better!

  • TAPgiles

    From seeing it in action, I think I understand it better now. Pretty cool ;P

    (But that hidden logic chip. My eyes are bleeding! XD ... I know, a lot of people's logic looks like that before it's released into the wild, don't worry ^^)

    @AndymationB: I think it's pretty much to loop through things (not "logic" in general). So I would probably just use a single self-adding calculator to go through 0 - 100 in 100 frames, maybe. But this solution is meant to allow anything a counter can do but the values change per frame, letting you run more complex loops.

  • Skn3--

    '@TapGiles
    Lol yes indeed!
    Probs tidy it up tonight and release if I get time! Wish Dreams let you "branch" a wire. That would be really useful for tidying things up. The wire grouping was a bit "sticky" last time I tried.

    Your explanation of the counter is spot on. Its basically as simple as a counter going up all the time and then you check what the counter currently is and then do stuff! But with this chip, its all neatly packaged up for you!

  • Skn3--

    Finished:

    https://indreams.me/element/oatjFuvxnLJ

    And here is a video demonstrating it.
    https://youtu.be/zC2l-9_wwSY

Please sign in to leave a comment.