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

Randomization with No Repeats?

Archive: 5 posts


Hi All,

I am working on an auto-scrolling level. A randomizer is hooked up to six different emitters that emit six different foreground pieces (the player must traverse these). Currently, these are emitted at random, but if possible I would like to have them emit WITHOUT emitting the same piece twice in a row. Is anyone aware of a method to accomplish this?

At first I thought I could do this by setting the randomizer to "Add and reset when full," but on this setting when the randomizer resets, the next wire simply stays on (the other ones just turn off). This means that no new signal is sent to the emitter, so it doesn't emit (they are set to "Emit once").

If anyone has a solution, it would be much appreciated!
2011-03-19 20:05:00

Author:
hybrand
Posts: 3


Set the randomizer's pattern to "add", then, it won't repeat any signal that's already been triggered unless you reset it.2011-03-19 20:18:00

Author:
Joey9898
Posts: 131


Thanks for the reply.

Two issues I see with this method:

1. There is still a chance to get two identical signals in a row. For instance signal 4 could be the last of the six activated, then the first after the randomizer is reset.

2. Is it possible to reset a randomizer set to "add"? I tried sending a negative value with a direction combiner, but this just adds another signal...
2011-03-19 22:31:00

Author:
hybrand
Posts: 3


The add setting can be reset by turning the randomizer off and then back on again, but you're right: there's the possibility that the last output of one randomizer cycle will be the first of the next cycle.

I assume your object need to emit at specific times since you're talking about a scrolling level. I think that I would try building a queue system between the randomizer and the emitters. So have the randomizer toggle on and trigger one of six ports on a selector. Once a selector port is active, it will toggle the randomizer off until whatever you use to control the sync tells it to emit, at which point it will turn the randomizer back on. The beauty of using a selector is that even if the randomizer picks the same port twice in a row, it won't actually make anything happen 'cuz the selector port is already active--any signals to turn on the already on port will be ignored and the randomizer will keep going until it triggers another port, which will trigger the the toggle again to turn off the randomizer and will put that port's signal into the emitter queue.

If that doesn't make any sense, I'll go ahead and build one and take a pic for you.

[Edit] I built it. Here's the simplified chip:
http://if.lbp.me/img/ft/4bfe8430a5a0b4664b87dce8a1d016bf815b7e4a.jpg

I omitted the repeated components to make the wires easier to see. You'll need a one-shot self-resetting counter for each of the selector's ports (6 all together) and they all need to be tied into the the OR gate at the bottom. Also, you'll need to place a circuit node on the sub-chip (what I like to call a circuit breaker) for each of the selector's ports and hook each of them to one of your emitters. The timer at the top controls the sync: set it to however long you need between each emitter firing, and set each emitter to "emit once".

The way it works is the timer switches the two port selector to its second state, which turns on the randomizer. The randomizer triggers one of the 6 port selector's states, which subsequently triggers a one-shot counter. The one-shot feeds into the OR gate which resets the two-port back to port one, turning off the randomizer. When the timer fills again, it turns on the circuit breaker chip for a single clock cycle--just long enough to tell the emitter to fire--and then turns it off again and turns the randomizer back on. If the randomizer chooses the same selector port that's already active, nothing happens, 'cuz it can't turn on something that's already on, so the randomizer stays on until it chooses another port.
2011-03-19 22:34:00

Author:
Sehven
Posts: 2188


Sehven --

Thanks much for the detailed response! Just built a full version of the rig and it works perfectly. Screenshot helped simplify things too.
Sweet Sacktimus Prime btw,
2011-03-20 00:40:00

Author:
hybrand
Posts: 3


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.