Author Topic: Roulette Game in Preparation  (Read 3782 times)

0 Members and 1 Guest are viewing this topic.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Roulette Game in Preparation
« on: November 27, 2018, 08:54:03 am »
I thought that I might create a Roulette game.  Before I make any significant progress, I'd be grateful for any suggestions.  An obvious one is to make the ball apparently roll as opposed to just sliding around in a circle.  I will also have to work out the mathematics for when the ball drops into a slot.

As I fairly recently posted a fruit-machine game, you must think that I'm a gambling addict: but never been in a casino!  I will have to learn how to play the game, what the odds are and payout values.

You will need the two images.
Code: QB64: [Select]
  1. 'Roulette
  2. Wheel& = _LOADIMAGE("roulette wheel.png", 33)
  3. Ball& = _LOADIMAGE("billiardball1.png", 33)
  4.  
  5. SCREEN _NEWIMAGE(1200, 1000, 32)
  6.  
  7. Phi! = 0
  8. Theta! = 0
  9. X0% = -460: Y0% = -460
  10. X1% = 919 - 460: Y1% = -460
  11. X2% = -460: Y2% = 919 - 460
  12. X3% = 919 - 460: Y3% = 919 - 460
  13.  
  14.     _LIMIT 25
  15.     '_PUTIMAGE (100, 40), Wheel&
  16.     X0Dash! = X0% * COS(Theta!) - Y0% * SIN(Theta!)
  17.     Y0Dash! = X0% * SIN(Theta!) + Y0% * COS(Theta!)
  18.     X1Dash! = X1% * COS(Theta!) - Y1% * SIN(Theta!)
  19.     Y1Dash! = X1% * SIN(Theta!) + Y1% * COS(Theta!)
  20.     X2Dash! = X2% * COS(Theta!) - Y2% * SIN(Theta!)
  21.     Y2Dash! = X2% * SIN(Theta!) + Y2% * COS(Theta!)
  22.     X3Dash! = X3% * COS(Theta!) - Y3% * SIN(Theta!)
  23.     Y3Dash! = X3% * SIN(Theta!) + Y3% * COS(Theta!)
  24.     _MAPTRIANGLE (0, 0)-(919, 0)-(0, 919), Wheel& TO(X0Dash! + 100 + 460, Y0Dash! + 40 + 460)-(X1Dash! + 100 + 460, Y1Dash! + 40 + 460)-(X2Dash! + 100 + 460, Y2Dash! + 40 + 460)
  25.     _MAPTRIANGLE (919, 919)-(0, 919)-(919, 0), Wheel& TO(X3Dash! + 100 + 460, Y3Dash! + 40 + 460)-(X2Dash! + 100 + 460, Y2Dash! + 40 + 460)-(X1Dash! + 100 + 460, Y1Dash! + 40 + 460)
  26.     XBall! = 400 * COS(Phi!)
  27.     YBall! = 400 * SIN(Phi!)
  28.     _PUTIMAGE (XBall! + 560 - 20, YBall! + 500 - 20)-(XBall! + 560 + 20, YBall! + 500 + 20), Ball&
  29.  
  30.     _DISPLAY
  31.     Theta! = Theta! + 0.01
  32.     IF Theta! > _PI THEN Theta! = Theta! - 2 * _PI
  33.     Phi! = Phi! - 0.02
  34.     IF Phi! < -_PI THEN Phi! = Phi! + 2 * _PI
  35.  
  36.  

* billiardball1.png (Filesize: 20.05 KB, Dimensions: 134x134, Views: 339)
roulette wheel.png
* roulette wheel.png (Filesize: 1.04 MB, Dimensions: 920x920, Views: 328)
« Last Edit: November 27, 2018, 10:47:37 am by Qwerkey »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Roulette Game in Preparation
« Reply #1 on: November 27, 2018, 09:06:39 am »
From what I remember with roulette, there's 38 color slots.  18 red, 18 black, and 2 green.

When betting on Red or Black, your odds of winning are 18/19, and payout is double.
To bet on a specific number, the odds are 1/19, and the payout is 6x the bet.

Green are always house tiles and non-bettable.

The odds are stacked so in the long run, the house always ends up the winner...

But, this is all just based on my poor memory from doing some research for a novel once a few years in the past.  I've never actually played the game, nor even been in a casino, so it's entirely possible there are multiple variations on the game that I'm unaware of.  :)

Edit:  Apparently the modern betting system is a lot more complex than the simplistic one I remember, as the image here illustrates -- http://www.southafricanonlinecasinos.com/imagesNew/roulettebets.jpg
« Last Edit: November 27, 2018, 09:14:47 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Roulette Game in Preparation
« Reply #2 on: November 27, 2018, 12:21:28 pm »
If payout is only 6x bet, that is really unfair game when odds of hitting slot are 1 in 38.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Roulette Game in Preparation
« Reply #3 on: November 27, 2018, 12:56:48 pm »
If payout is only 6x bet, that is really unfair game when odds of hitting slot are 1 in 38.

Wiki actually has a good breakdown on the odds and rules: https://en.m.wikipedia.org/wiki/Roulette

Much better than my poor old memory.  ;D
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Roulette Game in Preparation
« Reply #4 on: November 27, 2018, 01:02:00 pm »
I'll be using the Wiki odds (probably amended slightly to make the user win on average).