Picking random number without repeating (4 different attributes)

BonepileGamesBonepileGames Member Posts: 194
edited September 2014 in Working with GS (Mac)

Hello to GS Community,

I would like to ask you:

I have 4 global attributes called A B C D. A has value of 1(real), B 2, C 3, D 4. That is the default. On a specific occasion, they should change their value random(1,4) but I do not want them to repeat ( A 2, B 3, C 1, D 1 is repeating) or in other words to make 1,2,3,4 in a random way. How to do that?

Thank you

Comments

  • jeezzcakejeezzcake Member Posts: 144

    This could help:

  • jeezzcakejeezzcake Member Posts: 144
    edited September 2014

    Or you can use a Table with 4 rows ( values from 1 to 4 )
    row 1 = 1,
    row 2 = 2,
    row 3 = 3,
    row 4 = 4;

    pick a random number :
    random(1,tableRowCount(yourTable)) -> let's say the random number is : 2;
    remove the row number 2 (row 2) , using the Add/Remove Row behaviour:

    The new table:
    row 1 = 1,
    row 2 = 3,
    row 3 = 4,

    and so on.

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    I believe I also did a tutorial on how to achieve this (except using tables). I think you can find it in my community tutorial thread - since it uses tables, you can pick from the equation and use what you need to make it work for your game.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Okay here is the link to a template @tatiang made then just pick four rows to assign to your attributes. I used it to do what you are after that way.

    http://forums.gamesalad.com/discussion/53553/demo-randomize-table-rows#latest

  • BonepileGamesBonepileGames Member Posts: 194
    edited September 2014

    Thank you @jeezzcake‌ that indeed helped.

  • BonepileGamesBonepileGames Member Posts: 194

    I have made the same thing as @jeezzcake‌ suggested but I want to make it a twist:

    Every 10 successful moves (game.success) to change the numbers. I tried to add rows once game.success%10 but it doesnt seem to work.

    Any ideas, guys?

  • jeezzcakejeezzcake Member Posts: 144

    If you want to repeat the random process, you have to create a default table with 4 rows and the working table(same as the default table), from which you remove the randomly chosen rows.

    Then every 10 successful move copy the default table into your working table.
    Now you have the 4 rows table to work with again.

  • jorkosjorkos Member, PRO Posts: 353

    I do these with tables with the rows as randomized: ie. 1,3,4,2 etc. - then you just randomly pick the row value. I use this a lot for sets of 10 for example.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
Sign In or Register to comment.