Answer the question
In order to leave comments, you need to log in
What will the roulette algorithm look like?
I want to write a game - roulette, for the browser. Nothing serious - just for educational purposes.
The problem arises precisely in the algorithm, because in roulette there is, for example, a chance of winning red or black.
For example, there is this field:
1 2 3 4 5 6 7
8 9 10 11 12 13 14
Answer the question
In order to leave comments, you need to log in
Create an array: 0(green), 1(red), 2(black), 3(red), 4(black)...
You will end up with 15 elements.
The chance of each individual is 1/15, the chance of red is 7/15, the chance of black is 7/15.
Choose something like random(0...14).
Ячейка задаётся так:
cell = {number: 1, color: :red, parity: odd, size: small, dozen: 1, sixline: 1, corner: 1, street: 1, split: 1}
# соответственно для всех видов ставок
# ставим на пару с единицей (на границу 1 и 2) - шанс выигрыша = 17 к 1
bet = {number: nil, color: nil, parity: nil, size: nil, dozen: nil, sixline: nil, corner: nil, street: nil, split: 1}
def match?(cell, bet) do
!cell.keys.all?{|key| cell[key] != bet[key]}
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question