Showing a specific number of actors based on total actors

games4fungames4fun Member Posts: 185
edited January 2012 in Working with GS (Mac)
I want to show a specific number of certain actors based on total actors. For example i want to have 5 different actors lets say red,green,blue,black, and yellow. I want it to show a total of 10 of those actors but only lets say 3 of the red actor and the other 7 can be the other color actors but no more than 2 of each of the other colors. Thanks its a math problem that im stumped on.

Comments

  • CloudsClouds Member Posts: 1,599
    Place the following in your scene:

    3 red actors.
    2 green actors.
    2 blue actors.
    2 black actors.
    1 yellow actor.

    Job done !

    : )

    Is there a prize ?
  • games4fungames4fun Member Posts: 185
    Needs to be random because i will be changing the color that will need 3 of it each time. Also i need it to also be random on how many of the others show just no more than 2 of each though.
  • CloudsClouds Member Posts: 1,599
    Generate the first 10: (W=’white')

    RRRGGBBWWYY

    Then add additional actors in this order.

    RGBWYRRGBW
    RGBWYRRGBW
    RGBWYRRGBW
    RGBWYRRGBW

    Check after the generation of each actor whether you have reached the required number if total actors, if you have then stop generating actors.

  • CloudsClouds Member Posts: 1,599
    edited January 2012
    "Needs to be random because i will be changing the color that will need 3 of it each time."

    The colour is a red herring (no pun intended) - the numbers in any system can be ascribed any colour you like.

    With the pattern RGBWYRRGBW make R G B W & Y attributes to which you can assign a random colour (randomized at the start if the process so R is always = to pink, G is always = to blue and so on).

    Or more clearly C1 C2 C3 C4 C5.

    "Also i need it to also be random on how many of the others show just no more than 2 of each though"

    30% must alway be C1.
    20% must always be C2.
    20% must always be C3.
    20% must always be C4.
    20% must always be C5.

    (with 10% being the lowest useable value)

    So not random then ? : )
  • games4fungames4fun Member Posts: 185
    Yes it would need to be random all of it basically. The number of actors will change for example i might have a total of 5 colors and i want a specific one of those colors to show a certain amount of times lets say 3. The others i want to take the remaining total of 7 actors left since i started with 10 actors and have the remaining 4 colors total the other 7 remaining but no more of 2 of each one of those colors. For example RRWRYYGBGB those other 7 can change all the time. Also there will be times i will have more than 5 colors and also more than 10 total actors as well as times to where i might only have a max of only 2 of each color. Kinda hard to explain.
  • CloudsClouds Member Posts: 1,599
    edited January 2012
    "For example RRWRYYGBGB those other 7 can change all the time"

    . . . . but only within that group of ten.



    1) Randomly select a colour.

    2) Do the following checks (these five checks produce just a single number)
    . . . . . . . .
    Is it C1 - if you already have 3 C1s then add (+1)%5 to this random number (otherwise go on to rule 3).
    Is it C2 - if you already have 2 C2s then add (+1)%5 to this random number (otherwise go on to rule 3).
    Is it C3 - if you already have 2 C3s then add (+1)%5 to this random number (otherwise go on to rule 3).
    Is it C4 - if you already have 2 C4s then add (+1)%5 to this random number (otherwise go on to rule 3).
    Is it C5 - if you already have 1 C5 then add (+1)%5 to this random number (otherwise go on to rule 3).
    . . . . . . . .

    3) Have there been 10 colours made so far, if there has been then reset all the check values for all C numbers to 0.

    4) Generate next random number.

  • games4fungames4fun Member Posts: 185
    Trying to understand what the "if you already have 3 C1s then add (+1)%5 to this random number" not sure what you mean by add 1 and %5 to the random number?

    Lets say i have 5 of the same actor and i only want 3 random actors of those 5 to display a certain display message how would i do that.
  • CloudsClouds Member Posts: 1,599
    edited January 2012
    "Trying to understand what the "if you already have 3 C1s then add (+1)%5 to this random number"

    Sorry, I didn't make that particularly clear.
    Of the 5 colours - we are dealing with the one that you require 30% of - which here I have (arbitaraly) called C1.
    So the "if you already have 3 C1s . . . . " simply checks whether you have enough of these already in this batch of 10 numbers.
    If you do have enough C1s we need to select another number, adding +1 does what it says adds 1 to the random number (so 3 becomes 4 and 1 becomes 2)
    But we don't want 5 to become 6 because we have no '6'.
    So the addition of %5 tells Gamesalad that the world (of numbers) ends at 5 and after 5 simply loop around to 1.

    Example:
    Take a number (3) and keep adding (+1) = 4 5 6 7 8 9 10 11 12 13 14 15 16 17 . . . . . .

    Take a number (3) and keep adding (+1)%5 = 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 . . . . . . .

    Think of it as meaning 'loop after 5'. You can of course use any number you like, but in our example we want 5.
  • CloudsClouds Member Posts: 1,599
    "Lets say i have 5 of the same actor and i only want 3 random actors of those 5 to display a certain display message how would i do that."

    1) Randomly select an actor.
    2) Check whether it is the right kind of actor.
    4) Assign it a 'message'.
    5) Stop after 3.

    Did I really need to type that out !?!

    : P

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    I love it when people want complex stuff to be easy..lol
  • games4fungames4fun Member Posts: 185
    "Lets say i have 5 of the same actor and i only want 3 random actors of those 5 to display a certain display message how would i do that."

    1) Randomly select an actor.
    2) Check whether it is the right kind of actor.
    4) Assign it a 'message'.
    5) Stop after 3.

    How can i check if its the right kind of actor in order to stop at 3. For example i have 5 of the same red actor when touch is pressed change 3 of those 5 actors to display a message and those 3 must be randomly selected from the 5 in total. Would i need self attributes to do this. Im not sure how the rules should be set up. Sorry for all the questions and also thanks for taking the time to respond.
  • CloudsClouds Member Posts: 1,599
    edited January 2012
    @ games4fun

    "How can i check if its the right kind of actor in order to stop at 3"

    1) Randomly select an actor.
    2) Check whether it is the right kind of actor.
    4) Assign it a 'message'.
    5) what happened to step 3 ?
    3) Oh!, there you are, you cheeky little thing.
    99) Stop after you have assigned 3 'messages'.
Sign In or Register to comment.