GMS 2 Random color + with +/- chances

Good morning guys!

I'm trying to do a little game based on colors.
What i have right now is an object that will choose the color you will play with.
every turn you will deploy this color inside the field and then another color will be choosen.

what i want to do :
I want the code that choose the color to understand how much of that color there is in the game field, and then choose more easly a color different from the most common in the game field.
Example : i have 20 green, 10 blue, 4 red. i want green color to be very difficult to get, blue medium and red common as the next color instead to be totally random.

What's the best way to achieve this?
Hope i explained well.
Thanks in advance!
 
Sorry but i cant understand.
I know how to do a probabilities count, but i dont want a fixed %.
What i want to do is like:

At the start you have 33% of have red, green or blue pieces.
Then the more red pieces you have played (to be correct, the more red pieces you have active in the game field), the less the % of having one.
This is what i'm trying to do.

EDIT: Solved.
What i did
Code:
global.colors = 3 //number of colors

if global.colors = 3
{
global.red = 33
global.green = 66
global.blue = 100
}
I will declare the % at the start of the level based on how many colors i will have.
Then i will loop with a "for" cycle to find how many instances of red, blue and green items i have in the game field, and every 3 instance of the same color i will lower by 1 the % of having one of them as next color. (global.colortolower -= 1)

Then i will do
Code:
check = irandom_range(1,100)
if check < global.red + 1 then global.nextcolor = red
else if check < global.green + 1 then global.nextcolor = green
...
...
...
I will be able to use this with as much colors as i need, i only need to set the counter that lower by 1 the % of getting a specific color based on how many boxes will have the levels.
 
Last edited:
Top