PDA

View Full Version : Video Tutorial - Make the Randomizer Truly Random



blastroid
12-15-2014, 06:38 AM
The problem with the randomizer in both Little Big Planet 2 and 3 is the pattern the randomizer creates is not truly random each time the level is loaded. This is important for example if you want to shuffle a deck of cards, have a slot machine, or roll dice. This tutorial will help explain why this happens and demonstrates a method to help resolve the problem.


https://www.youtube.com/watch?v=amVYHdObGuM

Video URL = https://www.youtube.com/watch?v=amVYHdObGuM (https://www.youtube.com/watch?v=amVYHdObGuM)

Devious_Oatmeal
12-15-2014, 10:12 AM
This is something I've actually known for a while and I'd like to add some notes.

The system, with the emitter, is somewhat redundant. Although he is right about the player's actions being the only random indicator. (Until they patch up the 'random every time'; which I could have sworn was fixed in 3 and mentioned as a find in the Beta)

You can just do this in one microchip:

http://i7.lbp.me/img/ft/ba75bb88332c42e0df7bc4950b11fe743805e13e.jpg

The holograms are the choices for the randomizer, which can be as many as you want. (Like the numbers in the video)

The distance from the holograms and the switch (Switch of your choice, ie: player sensor, button, etc.) will need to be filled with those obstacles that will determine the player's randomness.


When the player activates the switch, it will allow the randomizer's output to go through, which they have been unable to this whole time, thanks to the perma-switch (The counter on the bottom) being off.


And! It also looks nice, if you are a neat-junkie.



As a side note:

This system also works in LBP2, except that the nodes (The small circles with the play symbol) would need to be replaced with AND gates. The nodes just make it look nicer.

blastroid
12-15-2014, 01:20 PM
The reason your method seems to work above is because the randomizer is already on. The pattern is still the same it just has been running the entire time when you entered the level. You are just at a random spot in the already determined sequence. Do this load your level wait 5 seconds, stand on the button, and write down the pattern (write down allot of steps so you can see the large pattern). Now replay the level but this time wait 6 seconds before standing on the button. You will find the pattern has not changed but where you started in the pattern has. That is why emitting the randomizer randomly is the only way to draw a new pattern, If the randomizer is in the level already the pattern will be the same on a replay even though you may enter the pattern at different times making it feel more random. I wired as your screenshot showed to confirm this.

Example:
5 seconds
1342314342331423
____^started using randomizer here

6 seconds
1342314342331423
_________^started using randomizer here

master3243
12-15-2014, 03:13 PM
Simply putting 2 blocks of any material with space in between would force the player to jump so that the time that the player sensor turns on would differ by milliseconds each time which would create a completely new pattern.

blastroid
12-15-2014, 03:22 PM
Simply putting 2 blocks of any material with space in between would force the player to jump so that the time that the player sensor turns on would differ by milliseconds each time which would create a completely new pattern.

If the randomizer is already in the level it is never creating a new pattern you are just jumping into different places of the already set pattern. Using the player to create the random time to emit the randomizer is what is causing a new pattern not just turning the randomizer on or off. It is confusing as it looks like a new pattern but it is just a continuation of the pattern that has already been set when the level loaded. If you were to write down the pattern you would see that it is the same pattern just you are entering it at different times.

RANDOMIZER ALREADY IN THE LEVEL:
1.) Level loaded with randomizer already in the level
2.) Randomizer pattern set Example: 321423224112322242314113341234
3.) Player uses the randomizer at random time (player actions) the randomizer gives result depending where it is in the already set pattern:
321423224112322242314113341234
________^ Player happened to start here in the random pattern
4.) Player restarts level
5.) Randomizer pattern set Example: 321423224112322242314113341234
6.) Player uses the randomizer at random time (player actions) the randomizer gives result depending where it is in the already set pattern:
321423224112322242314113341234
________________^ Player happened to start here in the random pattern
7.) Player restarts level
8.) Randomizer pattern set Example: 321423224112322242314113341234
9.) Player uses the randomizer at random time (player actions) the randomizer gives result depending where it is in the already set pattern:
321423224112322242314113341234
_^ Player happened to start here in the random pattern
Note: Notice it is the same pattern each time


RANDOMIZER EMITTED IN THE LEVEL AT A RANDOM TIME:
1.) Level loaded without randomizer already in the level
2.) At a random time (player actions) the randomizer is emitted to the level.
3.) Randomizer pattern set Example: 243223114423142314233221413241
4.) Now when the player uses the ranomizer because it is a unique pattern it does not matter where in the pattern they start.
5.) Player restarts level
6.) At a random time (player actions) the randomizer is emitted to the level.
7.) Randomizer pattern set Example: 442314232331142324113242324414
8.) Now when the player uses the ranomizer because it is a unique pattern it does not matter where in the pattern they start.
Note: Notice the pattern changes each time

GribbleGrunger
12-15-2014, 05:07 PM
Hasn't the randomizer now got a new setting? I thought you could set it to select a different sequence each time?

edit: Well that's stupid. What's the point of the pick different pattern option if it doesn't do that?

blastroid
12-15-2014, 05:23 PM
Hasn't the randomizer now got a new setting? I thought you could set it to select a different sequence each time?

edit: Well that's stupid. What's the point of the pick different pattern option if it doesn't do that?

Hehe yeah I mention that setting in my video. It got my hopes up until I tested it. Maybe it will work one day and this work around will not be needed.

GribbleGrunger
12-15-2014, 05:26 PM
Hehe yeah I mention that setting in my video. It got my hopes up until I tested it. Maybe it will work one day and this work around will not be needed.

What if you used the physics to start the randomiser? I'd considered this with LBP2 but never really needed it. A ball (full bounce) with a tag. Several pins between it and the bottom. Ball drops on entering level. Hits pins until reaches tag sensor at bottom. Randomizer begins.

Oh, and I still can't see what you're doing in the menu! Get those contrasts.

blastroid
12-15-2014, 06:37 PM
What if you used the physics to start the randomiser? I'd considered this with LBP2 but never really needed it. A ball (full bounce) with a tag. Several pins between it and the bottom. Ball drops on entering level. Hits pins until reaches tag sensor at bottom. Randomizer begins.

Oh, and I still can't see what you're doing in the menu! Get those contrasts.

Remember it is not about when the randomizer starts but when the pattern get created. If the randomizer is already in the level the same pattern is already set every time the level loads. When you access the randomizer you may be in different spots of the pattern but it is the same pattern. That is why you must use an emitter to randomly at a time bring the randomizer into the level. Using physics would also not work since physics are just cause and effect. Since nothing random has been presented to the physical world the ball would drop in the same fashion colliding with the same objects in the same manner each day. Since LBP does not have wind, real sun, planet rotation, the butterfly effect the physics in the game are like the movie Groundhog Day.

Also I thought of your comments on the last tutorial. I changed the background color to black and did choose a different popit color. Just got to find the right one. Any recommendations on the popit color to choose? Thanks

LittleBigDave
12-15-2014, 06:44 PM
Seems like just using an Object Saver to keep the pattern going would avoid all this complication in LBP3.

https://lbp.me/v/qt4hfbg

GribbleGrunger
12-15-2014, 06:45 PM
Remember it is not about when the randomizer starts but when the pattern get created. If the randomizer is already in the level the same pattern is already set every time the level loads. When you access the randomizer you may be in different spots of the pattern but it is the same pattern. That is why you must use an emitter to randomly at a time bring the randomizer into the level. Using physics would also not work since physics are just cause and effect. Since nothing random has been presented to the physical world the ball would drop in the same fashion colliding with the same objects in the same manner each day. Since LBP does not have wind, real sun, planet rotation, the butterfly effect the physics in the game are like the movie Groundhog Day.

Also I thought of your comments on the last tutorial. I changed the background color to black and did choose a different popit color. Just got to find the right one. Any recommendations on the popit color to choose? Thanks

Are you sure an object with bounce, dropped through several pins, would result in it landing at exactly the same time, every time?

On popit colour (just for tutorials) Black with red writing. I use that as my default anyway because it's very easy to see everything. That floor still takes the eye though! I think a white platform with the back completely black is the perfect set up for tutorials. There is absolutely nothing to distract you from what's going on and what you are saying.

edit: Yep, you're right. Physics aren't random either.

Entity
12-15-2014, 07:09 PM
It seems what the 'new pick every time' setting does is make it so a number isn't repeated e.g. off: 1333244443122 on: 1431432412431

Something that should work better is to use a self-resetting timer wired up to the randomiser emitter, with an object saver placed on the same circuit board. This should give you 30 different random patterns for each second. you set the timer to. You could also use this in combination with Sackboy movement to increase randomisation further.

blastroid
12-15-2014, 07:23 PM
It seems what the 'new pick every time' setting does is make it so a number isn't repeated e.g. off: 1333244443122 on: 1431432412431

You can see in the video I talk about that settings and even turn it on and it made no difference.

Also On / Off means nothing than continuing the pattern. When the level is re-loaded the same pattern is chosen.

To make sure a number is not repeated during the sequence you can change the pattern to Add. This is also talked about in the video. Even when not repeating it still is a repeating pattern per sequence chunk 1431432412431, replay 1431432412431, replay 1431432412431...

Sehven
12-15-2014, 08:06 PM
It seems everybody is making you defend your need for a randomizer to actually be, you know, random. I appreciate the tutorial and, while making it so that the player's interaction causes the randomizer to pop up in a random spot in its pre-determined sequence, there are scenarios where that simply isn't a good enough option. For example, if you need something to randomly happen at the start of a level before Sackboy has had time to seed it. Also, since the sequence is pre-determined, a player might notice that something like a random sequence of lights is the same every time they play even though it doesn't necessarily start at the same point in the sequence. In other word:

Random sequence = 1,2,6,3,4,1,1,5,3,6,1,3,3...
Player observes: 6,3,4,1,1,5,3,6,1,3,3... on one play and
2,6,3,4,1,1,5,3,6,1,3,3... on the next.

blastroid
12-15-2014, 08:27 PM
It seems everybody is making you defend your need for a randomizer to actually be, you know, random. I appreciate the tutorial and, while making it so that the player's interaction causes the randomizer to pop up in a random spot in its pre-determined sequence, there are scenarios where that simply isn't a good enough option. For example, if you need something to randomly happen at the start of a level before Sackboy has had time to seed it. Also, since the sequence is pre-determined, a player might notice that something like a random sequence of lights is the same every time they play even though it doesn't necessarily start at the same point in the sequence. In other word:

Random sequence = 1,2,6,3,4,1,1,5,3,6,1,3,3...
Player observes: 6,3,4,1,1,5,3,6,1,3,3... on one play and
2,6,3,4,1,1,5,3,6,1,3,3... on the next.

Yes I agree this is not needed for example light sequence but a shuffling a deck of cards or roll of dice it is. Also if you need something to be random at the level load this would not work either. The answer I have not seen yet is how to you create a fresh random pattern every time you load the level.

In my level Blastroid's Resort (LBP2)
I have a slot machine where I use the technique to make it random just not picking a point it the same pattern that gets chosen when the level loads. Now if I did not use this technique to create a new pattern each time the player gets to the slot machine it may or may not matter. If the player cannot remember well they may not even notice that part of the slots is acting exactly as it did on their last play. Some players never play the level more than once. Also it depends on when the player activated the slot machine if the randomizer is already doing it's thing in the background their first pull of the slot machine might appear random enough.If they keep pulling though and write down the results they will find that they catch up to the same pattern on each play of the level. Is this a big deal, not at all. Does it need to be fixed, probably not. Does my OCD agree with it, NO! :)


Currently I have listed to everyone's suggestions but when putting them to practice I get the same pattern each time. The only way I have come to a solution is the method I demonstrate in my video that emits the randomizer using the player to help choose a random time to do this. I would absolutely love an easier solution or to have this patched. Many creators will never need this in their level and others do not care it may be the same pattern over and over or for their scenario it is hard to even tell it is the same pattern. This tutorial is mainly for those technical times where you would truly need a new pattern when the level loads.

I thought it would be fun to kind of show when the randomizer patterns get set to show it is not really random on replay. To 0.01% of creators this may matter. :) I do like though I finally got someone to comment on my tutorials. Lets keep the conversation going. :)

GribbleGrunger
12-15-2014, 09:36 PM
Of course, if we had logic that could take the time/date of the PS4 and apply it in game, true randomization would be easy.

LittleBigDave
12-16-2014, 03:26 AM
Currently I have listed to everyone's suggestions but when putting them to practice I get the same pattern each time. The only way I have come to a solution is the method I demonstrate in my video that emits the randomizer using the player to help choose a random time to do this. I would absolutely love an easier solution or to have this patched.


OK, I made a simple sample level demo'ing the Object Saver technique I had posted above:
Randomizer Example (http://lbp.me/v/qt4hfbg)

This seems like it's working great to me, but I'd be interested in other's feedback. I agree this stuff matters. :)

If you play that little sample, I would be interested to hear what you get for an initial pattern on their first play through. I figure we'd all get the same as this isn't player-data-based. So a possible drawback will be if you get the same pattern every time you first play, that might allow players to reset their data so they can anticipate the pattern to get a higher score. That might matter a lot in card games, but probably less so in most levels.

EDIT: OK, actually this Object Saver example isn't working consistently now for me. I'm not sure why it works sometimes and not others. It seemed to work well on my Moon, and hitting replay or finishing the level and playing again would give me a fresh sequence. This continued the first couple times after publishing to my Earth too. But then the published version started giving me the same pattern every single time. (Well, except one time in the middle I believe it gave me a different pattern, which is stranger still.)

GribbleGrunger
12-16-2014, 03:28 AM
testt

Well, that was random.

LittleBigDave
12-16-2014, 03:32 AM
Well, that was random.

I was having a heck of a time getting my reply to post. Kept getting server error messages. Not sure why...

GribbleGrunger
12-16-2014, 03:36 AM
I was having a heck of a time getting my reply to post. Kept getting server error messages. Not sure why...

It happens from time to time for me too. It drove me nuts when I was trying to update the LBP2 tutorial directory.

blastroid
12-16-2014, 04:30 AM
@LittleBigDave

Tried your level and I too am getting a repeating pattern. My pattern was 2F2F3F311 (F = Face).

When I exit your level via menu or scoreboard I get the following error "Recent changes to your profile could not be saved due to an unknown error." So I don;t think the saver is working. Let me know if you get it fixed and I will try again.

LittleBigDave
12-16-2014, 05:43 AM
@LittleBigDave

Tried your level and I too am getting a repeating pattern. My pattern was 2F2F3F311 (F = Face).

When I exit your level via menu or scoreboard I get the following error "Recent changes to your profile could not be saved due to an unknown error." So I don;t think the saver is working. Let me know if you get it fixed and I will try again.

Thanks for trying it. I'm pretty sure that's a different pattern than I was getting, so that's interesting. The level is copyable if you want to mess around any further there. That error message I've gotten other times in LBP3 but I'm not getting that when I try that level. Clearly there's a game bug still out there, so I may hold off on pondering Object Savers much more until patch 1.04.

Side Note: One thing I learned while doing this though is that if you use an Object Saver and then republish your level, your players get a message forcing them to choose between the losing their saved data or not getting the version update. Worth knowing ahead of time.

Devious_Oatmeal
12-16-2014, 09:26 AM
The reason your method seems to work above is because the randomizer is already on. The pattern is still the same it just has been running the entire time when you entered the level. You are just at a random spot in the already determined sequence. Do this load your level wait 5 seconds, stand on the button, and write down the pattern (write down allot of steps so you can see the large pattern). Now replay the level but this time wait 6 seconds before standing on the button. You will find the pattern has not changed but where you started in the pattern has. That is why emitting the randomizer randomly is the only way to draw a new pattern, If the randomizer is in the level already the pattern will be the same on a replay even though you may enter the pattern at different times making it feel more random. I wired as your screenshot showed to confirm this.

Example:
5 seconds
1342314342331423
____^started using randomizer here

6 seconds
1342314342331423
_________^started using randomizer here


HHmmmmmm.....

I knew it repeated, although the reason why I decided on this was because your system repeated if the distance traveled was the same in both play-throughs. So that means that there is a pattern in the selection of which pattern is chosen; the pattern chosen is then the pattern that now appears in your emitted pattern. It is as if a more advanced randomizer is choosing your randomizer (I'll call it the ΩRandomizer because Sn'Gs). I do not think that was something you were taking advantage of voluntarily, but if it is how the randomizer's work, then that is very useful info for randomizers!

Basically, I would hypothesize that the game itself has an in-game randomizer (ΩRandomizer), but it randomizes the patterns that are to be chosen for randomizers in levels. The reason why your system works is due to that in-game randomizer (ΩRandomizer), but even that randomizer(ΩRandomizer) does not reset for levels on each play-through. The choice of randomization is just quicker, or a more advanced system for randomization.

So, in order for my system to replicate that, the microchip I posted would need to go through random sequences, or the same sequence, very rapidly; like setting it to go through each choice at the speed of (.1). But that would be unnecessary though, since the game's randomizer is far stronger and quicker.


OK, I made a simple sample level demo'ing the Object Saver technique I had posted above:
Randomizer Example (http://lbp.me/v/qt4hfbg)

This seems like it's working great to me, but I'd be interested in other's feedback. I agree this stuff matters. :)

If you play that little sample, I would be interested to hear what you get for an initial pattern on their first play through. I figure we'd all get the same as this isn't player-data-based. So a possible drawback will be if you get the same pattern every time you first play, that might allow players to reset their data so they can anticipate the pattern to get a higher score. That might matter a lot in card games, but probably less so in most levels.

EDIT: OK, actually this Object Saver example isn't working consistently now for me. I'm not sure why it works sometimes and not others. It seemed to work well on my Moon, and hitting replay or finishing the level and playing again would give me a fresh sequence. This continued the first couple times after publishing to my Earth too. But then the published version started giving me the same pattern every single time. (Well, except one time in the middle I believe it gave me a different pattern, which is stranger still.)

And in order for the object saver to work, they would have to of already played the level once, or there is the backfire you are referring to with the players just deleting the information. So far, it seems that each way we try and implement a randomizer, there is no way to make it actually a sophisticated random sequence. We can only rely on the game's randomizing since it is the most complicated randomizer(ΩRandomizer) we have access to. (At least, that is just a hypotheses)

Sehven
12-16-2014, 06:49 PM
Does it need to be fixed, probably not. Does my OCD agree with it, NO! :)

I 100% agree with you. https://www.youtube.com/watch?v=tnzz-eFmKaw

LittleBigDave
12-16-2014, 09:32 PM
OK, I tweaked the sample level I did using the Object Saver technique and it seems to be working properly now, while still keeping things pretty simple:
Randomizer Example (http://lbp.me/v/qt4hfbg)

I put the Object Saver on a block with an emitter and a timer chip. The emitter emits the randomizer chip. The timer's value gets saved between plays, making the exact timing of the randomizer creation variable. In practice this seemed to mean I was getting different sequences every time.

This might not be better than any other technique at this point, but there's probably time when it's advantageous not to have to rely on player data (especially if your game doesn't involve players freely gadding about). The concerns of players resetting their data to restart the same sequence should be lessened if you're also saving other progress for them. They'd have to wipe everything to start over.

- - - - - - - - - -

I think the issue before with the Object Saver might be that randomizers get a seed code set when the level is published, and that that is all that is saved by the Object Saver. Not the position in the sequence (which you can't even directly inspect anyway). I think possibly whenever you run the level on your moon it is "recompiled" in some sense and a new seed gets created each time. (All I really know there is the fixed sequence problem wasn't happening for me in this example until I published the level.)

I have read that the core behavior issue with the randomizers came from online multiplayer concerns. They wanted the only simulation data needing to be shared between players to be the player position/state data. Everything else was predictable by design, so two remote players could be running the same level together with a slow net connection and still stay in sync. But things may have changed now since LBP2, with so much more state-saving tech in the game.


It seems what the 'new pick every time' setting does is make it so a number isn't repeated e.g. off: 1333244443122 on: 1431432412431



You can see in the video I talk about that settings and even turn it on and it made no difference.

To make sure a number is not repeated during the sequence you can change the pattern to Add. This is also talked about in the video. Even when not repeating it still is a repeating pattern per sequence chunk 1431432412431, replay 1431432412431, replay 1431432412431...

Just to be clear, entity is correct about what "New Pick Each time" does. It just prevents the same output from being triggered twice in a row. As we all know now, it has nothing to do with repeated play throughs. (I suspect somebody in the beta days was confused about that too, leading to our initial misunderstanding that "true" random was a new feature in LBP3.)

The "Add" mode turns on an output, leaves it on, and then turns on another, until all outputs are on. The Selector in the logic in the video obscures this because a Selector can only ever have one output on. You don't normally need the selector if all you care about is generating random values. But indeed a selector combined with the Add setting is a nice way to simulate a random permutation. (You might have also said this in the video...I had been distracted during part of it.:( )

blastroid
12-16-2014, 09:41 PM
The "Add" mode turns on an output, leaves it on, and then turns on another, until all outputs are on. The Selector in the logic in the video obscures this because a Selector can only ever have one output on. You don't normally need the selector if all you care about is generating random values. But indeed a selector combined with the Add setting is a nice way to simulate a random permutation. (You might have also said this in the video...I had been distracted during part of it.:( )

The only reason for the selector was I needed to wire something to the tag sensors and it made it easier to view what wire was going to what for the video. You could wire directly without the selector. Also the selector is nice as it has some nice features but for most scenarios would not be needed.

psn_zerocub
12-16-2014, 11:06 PM
At first I thought you could use the memorizer but that would only help in making it different per replay and not per new player.. hmm.