# How do I modify odds in a gambling game?

Get help using Construct 2

### » Thu Mar 23, 2017 8:23 am

This might not be specific to C2 but I still want to ask about it. If a moderator feels this topic fits better elsewhere, please move it.

So, I'm about to get a deal with a client (if it's a deal) about making a gambling game.

In this game, the client wants to be able to modify the odds of winning every once in a while (maybe every session, or something else). Imagine a keno where players can pick numbers between 1 and 50, and let's say that I want to make the odds of winning to be 1 in 100. How do I make a random number generator to pick numbers in a mathematical way to ensure that every player playing has a 1% chance of winning.

thanks.
B
45
S
13
G
2
Posts: 173
Reputation: 5,331

### » Thu Mar 23, 2017 8:43 am

Simply set a number random(0,1000) when selecting the odds of the next card/chip/number/whatever
and use the condition If Number <= 10 'winning' card/chip/number/whatever appears.
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
40
S
17
G
32
Posts: 818
Reputation: 20,629

### » Thu Mar 23, 2017 8:52 am

Exactly as MpplantOfficial says above:

IF you want a chance of something, you'd have a variable and then modify it using "random(FIRST,SECOND)"

So, say you want a 50% chance of an event happening,
Code: Select all
`Global Variable XXXXEvent -- SomeTrigger -> Set Variable XXXX to Random(0,100)Event -- if XXXX <= 50  -> Do Action and reset XXXX to 0Event -- if XXXX > 50  -> Do Action different action and reset XXXX to 0`

So what's happening above is that the variable XXXX is set to a random value between 0 and 100
the other 2 events then check if it is greater than, equal to or less than 50 (giving you a 50% chance since it's between 0 and 100).

Always best to reset the Variable to 0 after you've triggered the event just to be sure it doesn't get triggered twice.

Be aware that when using "random" the number it generates is a float, so can have decimal points.
To counter that you can either round the number up or floor it down using the following.
Code: Select all
`set XXXX to Round(random(0,100))ORset XXXX to floor(random(0,100))`
B
9
S
2
Posts: 69
Reputation: 833

### » Thu Mar 23, 2017 2:38 pm

Wow!

I just have to say if that is a gambling game that actually accepts money what you are describing is highly illegal and any Casino caught changing odds would be under some serious legal action. That is called fixing the game.

I would suggest you check the laws in your country before getting involved in any such activity!
Banned User
B
29
S
7
G
58
Posts: 1,229
Reputation: 34,910

### » Fri Mar 24, 2017 1:28 pm

Thanks a lot for your answers! I'll try to use them in the game when it's time to implement it.

@lamar: honestly, I'm not sure if it's illegal or not since I don't know laws about gambling specifically. I'll keep what you said in mind and ask the client. I hope it's just a case of misunderstanding.
B
45
S
13
G
2
Posts: 173
Reputation: 5,331