c++ - how to add probabilities to the game? -


This program works well, but like a true casino owner, I want to minimize payouts as much as possible without adding more possibilities. The way I want to do this is to add possibilities to each number. There are 8 possibilities (2,3,4,5,6,7,8,9) I want 7 to be the least Therefore, I want to set the probes as 2 to 75% (which is 15% each), 8% to 20% (10% each) and 7% 5%. Can someone help me?

  #include & lt; Cstdlib & gt; # Include & lt; Iostream & gt; # Include & lt; Semith & gt; # Include & lt; Ctime & gt; using namespace std; Int random (int less, int hi); Int results (int a, int b, int c, int chips, int beat); Int main () {srand (time (0)); Int, less 1 (2), less 2 (2), less 3 (2); Int High 1 (9), High 2 (9), High 3 (9); Int menu = 0; Int beat = 0; Bool quit = 0; Cout & lt; & Lt; "Player Chips: $ 1000" & lt; & Lt; Endl; Int chips = 1000; While (Skip) {cout & lt; & Lt; "1) Play Slot 2) Exit."; Cin & gt; & Gt; Menu; Switch (menu) {Case 1: {cout & lt; & Lt; "Enter your condition:"; Cin & gt; & Gt; Bet; If (condition & lt; = 0; condition & gt; chips) {cout & lt; & Lt; "You did not enter a valid condition." & Lt; & Lt; Endl; Menu = 1; } And {int a = random (less 1, high 1); Int b = Random (Less 2, High 2); Int c = Random (less 3, high 3); Cout & lt; & Lt; A & lt; & Lt; "" & Lt; & Lt; B & L; & Lt; "" & Lt; & Lt; C & lt; & Lt; Endl; Chips = results (A, B, C, chips, condition); Cout & lt; & Lt; "Player Chips: $" & lt; & Lt; Results (A, B, C, Chips, Condition) & lt; & Lt; Endl; }            break; } Case 2: {cout & lt; & Lt; "Exiting ..." & lt; & Lt; Endl; Leaving = 1; break; } Default: {cout & lt; & Lt; "Not a valid menu!" & Lt; & Lt; Endl; }}} If (chips and lt; = 0) {cout & lt; & Lt; "You have $ 0! Game over!" & Lt; & Lt; Endl; Leaving = 1; }} Int Random (int lower, int high) {int random; Random = low + rand ()% ((high + 1) -lo); Random return; } Intimate result (int a, int b, int c, int chips, int bt) {if ((a = 7 7, and b = 7 7, and c == 7)) {cout & lt; & Lt; "You won your bet 10 times! ($" & Lt; <(condition * 10) <") & lt; & lt; & lt; & Lt; Endl; Chips = chips + (condition * 10); } If ((a == b == c) & amp;! (A == 7 & amp; amp; amp;; b == 7 & amp; amp; amp; c; = 7)) {cout & lt; & Lt; "You have won your bet 5 times ($" & lt; <(condition * 5) <"<") "& lt; & Lt; Endl; Chips = chips + (condition * 5); } If ((a == b || a == c || b == c) & amp; amp; (A == b == c) & amp; (A == 7 & amp; amp; B == 7 and amp; c == 7) {chips = chips + (condition * 3); Cout & lt; & Lt; "You won your bet 3 times! ($" & Lt; <(condition * 3) <") & lt; & Lt; Endl; } And {cout & lt; & Lt; "You've lost your bet ($ -" & lt; <-bt; <-lt; & lt; ")" & lt; & Lt; Endl; Chips = chips-condition; } Return chips; Introduction to an array of values ​​[0.05, 0.15, 0.25, 0.4, 0.55,},  

0.85

Then get a random number from 0 to 1. / P>

  if r < = 0.05, so this 7 and if R & lt; = 0.15, so this is 8 else if r < = 0.1 so it is 9 ... and if r < = 0.85 So this is 5 and this is 6.  

If you want, how can you write it down as a loop?


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -