GameSalad

Random number generation

xotty9999xotty9999 Posts: 15Member, PRO

I am sure there is an easy fix to this, but I can't seem to find it. I want a random number generated each time a player does touch release behavior on an actor. If the random number is above 10, a new cell value of [current cell value]-5 should result in a table.
Here is what I have:
When touch is pressed and,
Numeric expression, random (1,20) is >=10
then,
Change table value, table name, row 1, column 1 to function table cell value (table name, row 1, column 1) -5

This works when I touch the actor, but when I release touch and touch again, the randomly generated number part of this rule does not start over. So if I get a random number result over ten, the number decreases by 5 as it should, but then every time I touch, it keeps reducing by 5 as if a newly generated random number is never being generated.
So how do I get the random number to generate each and every time I do the touch behavior?

Comments

  • pHghostpHghost London, UKPosts: 1,929Member
    edited March 17

    Two rules:

    1. When touch is pressed, change attribute: self.number to random (1,20).
    2. When touch is pressed AND attribute: self.number is >=10, change table value, blablabla.

    P.S. Yes, they have to come in this sequence.

  • xotty9999xotty9999 Posts: 15Member, PRO

    Great. That worked. That's two I owe you!

  • smurftedsmurfted Posts: 396Member, PRO

    On this note, how random is the random number these days?

  • pHghostpHghost London, UKPosts: 1,929Member
    edited April 7

    @smurfted said:
    On this note, how random is the random number these days?

    Not this discussion again... :trollface:

    It's random enough for use in very accurate slot machine games. What exactly do you need it to do?

  • smurftedsmurfted Posts: 396Member, PRO

    No stress and obviously you can do work arounds.

    Though i did notice out of a choice of a 1000, an app of mine does seem to repeat numbers in the same area quite a lot before moving on...

  • pHghostpHghost London, UKPosts: 1,929Member
    edited April 7

    @smurfted said:
    an app of mine does seem to repeat numbers in the same area quite a lot before moving on...

    Yeah, I've noticed a similar thing myself. Of course, the issue is that that might happen even with a truly random system. It's only our perception that makes us think it isn't random enough, seeing patterns. If in doubt, link two randomisers together. Or make a randomiser that changes constantly, and when you click the button (or whatever you need to do in your game), just read the current number.

  • SocksSocks London, UK.Posts: 12,700Member, PRO

    @smurfted said:
    No stress and obviously you can do work arounds.

    Though i did notice out of a choice of a 1000, an app of mine does seem to repeat numbers in the same area quite a lot before moving on...

    The problem with real randomness is that anything can happen :)

    If you were to see a pattern of 5, 5, 5, 5, 5, 5, 5 (etc). . . . all the time, every time you ran your game, and no other number ever came up, then there would be nothing here to indicate that anything is wrong, a pattern of never ending 5s is as likely to appear as any other pattern.

    And by extension, there is no way to determine whether a random number generator is broken or not working correctly by simply looking at the output, there is no series of numbers that can tell you something is amiss, even if you were to see 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, (etc).

    Couple this with the fact that humans are very adept pattern seeking animals and most people find that they don't really want true randomness, but prefer a balanced distribution of values, so that there are no apparent patterns or gathering of values in one area or abscence of values in another.

    So, you might want to throw together your own 'random' number generator that distributes values more evenly, people tend to find that kind of thing bettter for games.

  • SocksSocks London, UK.Posts: 12,700Member, PRO

    @pHghost said:

    @smurfted said:
    an app of mine does seem to repeat numbers in the same area quite a lot before moving on...

    Yeah, I've noticed a similar thing myself. Of course, the issue is that that might happen even with a truly random system. It's only our perception that makes us think it isn't random enough, seeing patterns. If in doubt, link two randomisers together. Or make a randomiser that changes constantly, and when you click the button (or whatever you need to do in your game), just read the current number.

    While agreeing with everything you say here, I'd say he most probably needs a less random system, one that spreads values out more evenly, like you say most of the time it's us perceiving patterns and thinking things don't look random enough.

  • SocksSocks London, UK.Posts: 12,700Member, PRO

    @pHghost said:
    Not this discussion again... :trollface:

    It comes up on a regular basis, although it could be a random basis, hard to say.

  • smurftedsmurfted Posts: 396Member, PRO

    They say prunes keep you regular...

  • SocksSocks London, UK.Posts: 12,700Member, PRO
    edited April 7

    @smurfted said:
    They say prunes keep you regular...

    If you want more of a random 'distribution' then mix in a couple of heaped tablespoons of egg powder.

  • SocksSocks London, UK.Posts: 12,700Member, PRO

    @Hopscotch said:
    A random scatterplot is still a smooth distribution.

    That's what I told the man who came to repair the toilet.

  • ArmellineArmelline Posts: 4,414Member, PRO

    @smurfted said:
    On this note, how random is the random number these days?

    About 6 months ago I generated 10,000,000 random numbers from 1-5, and once it was finished the most common number had been generated something like 300 times more than the least common. So they're pretty random.

  • SocksSocks London, UK.Posts: 12,700Member, PRO
    edited April 9

    @Hopscotch said:
    A random scatterplot is still a smooth distribution.

    @Armelline said:
    About 6 months ago I generated 10,000,000 random numbers from 1-5, and once it was finished the most common number had been generated something like 300 times more than the least common. So they're pretty random.

    How can you tell ? :p Those 10m numbers might have been a one off, everything else after that could have been a never ending stream of 3s.

    Ok, sorry :trollface: :)

    Attached is a quick illustration of a 'I don't really want randomness, I want sorta' nearly random, but evenly random kinda thing' distribution.

    Drag the slider in the top lefthand corner to the right to increase RadomosityPower™ (click on the screen to ReRandomisulate© the values) - on the left we have a uniform distribution, on the far right we have Hitler and a distribution nearer the kind we might see in a 'true' random distribution.

    I suspect people want something in the middle somewhere, avoiding the voids and grouping you might see in a 'true' random distribution, and avoiding any recognisable uniformity or pattern you see in a 'not random enough' distribution. Values as low as 15 are probably what people are often after.

    . . . .

    Bonus optical illusion (FREE!)

    Drag the slider to the far right, decide on a direction (up, down, left, right, diagonal, 20° . . . etc), then repeatedly click the screen to randomise the values while looking to see the dots move (for example) down, and you will see the dots move down ! (or in your chosen direction).

  • smurftedsmurfted Posts: 396Member, PRO

    love it..

  • ArmellineArmelline Posts: 4,414Member, PRO

    @Socks said:
    I suspect people want something in the middle somewhere, avoiding the voids and grouping you might see in a 'true' random distribution, and avoiding any recognisable uniformity or pattern you see in a 'not random enough' distribution. Values as low as 15 are probably what people are often after.

    This is so true. The number of times clients have complained that something wasn't random enough, and what they really meant was that it was too random!

    It always reminds me of one of Steve Job's keynotes where he was talking about making iTunes/iPod shuffle LESS random in order to make it feel more random. I wish I could find the Keynote.

  • SocksSocks London, UK.Posts: 12,700Member, PRO

    @Armelline said:
    This is so true. The number of times clients have complained that something wasn't random enough, and what they really meant was that it was too random!

    It always reminds me of one of Steve Job's keynotes where he was talking about making iTunes/iPod shuffle LESS random in order to make it feel more random. I wish I could find the Keynote.

    I think there should be a new word for this thing people want, 'randish' ?

Sign In or Register to comment.