For example roulette. Program makes million of spins we know payouts. Program shows roulette edge.
Or Blackjack should we hit 15 vs 16 or not
Quote: maletaja81I would like to program some scripts where to start?
For example roulette. Program makes million of spins we know payouts. Program shows roulette edge.
Or Blackjack should we hit 15 vs 16 or not
Well what do you mean by where to start? Do you already know python and are asking how to design the program or are you asking how to learn the language to do what you want?
Quote: geoffWell what do you mean by where to start? Do you already know python and are asking how to design the program or are you asking how to learn the language to do what you want?
I have just started to learn python, possible for you to write python script to find the house edge of single zero roulette game and post it here ? What good RNG are you using ? Script for RNG( random number generator) ?
With your help I may modify it and use it to simulate other games......
Quote: ssho88I have just started to learn python, possible for you to write python script to find the house edge of single zero roulette game and post it here ? What good RNG are you using ? Script for RNG( random number generator) ?
To find a proper house edge, you don't use an RNG; you use "brute force" to go through every possible result, multiplied by the probability of that result.
Python has an RNG in integers called random.randrange; randrange(100), for example, will return a random integer from 0 to 99 inclusive. You initialize it using random.seed(); this sets the initial parameters based on the current date and time.
Keep in mind that, for complicated games like blackjack, it's not so much being able to write the code, as knowing what code to write.
Quote: ThatDonGuyTo find a proper house edge, you don't use an RNG; you use "brute force" to go through every possible result, multiplied by the probability of that result.
Python has an RNG in integers called random.randrange; randrange(100), for example, will return a random integer from 0 to 99 inclusive. You initialize it using random.seed(); this sets the initial parameters based on the current date and time.
Keep in mind that, for complicated games like blackjack, it's not so much being able to write the code, as knowing what code to write.
I know how to calculate the roulette house edge with simple hand calculations and I have learned VBA to write code for Blackjack, Three card poker, poker, 80++baccarat side bets and many other games . . . .
Unfortunately VBA is running quite slow compare to Python( I was told that !), I want something that can do combination analysis FAST(within seconds) based on exact remaining deck composition(especially for baccarat sidebets that involve suits !), my current VBA program take 20 minutes to complete CA for baccarat sidebets that involve suits( which is TOO SLOW !). So I have decided to learn new language python . . . .If you can show me the simple python codes to calculate roulette house edge . . .then from there I may learn fast and from there expand to other games . . . . .I know that RNG is for simulations( to find betting opportunities, ev/shoe . . .) and CA(to find house edge and does not required RNG).
Is python built-in RNG comparable to Mersenne Twister ?
p/s : House edge by billion rounds of simulation should match the house edge by CA, I normally use both method to verify the correct house edge.
Thanks
Python is easy to learn and use, and after you get down the basics, you can speed it up with external libraries such as numpy, scipy, and numba.
Python uses the Mersene Twister.
https://docs.python.org/3/library/random.html
Quote: Dalex64Python is not known for it's speed, especially when executing FOR loops. It should be faster than VBA, though.
Python is easy to learn and use, and after you get down the basics, you can speed it up with external libraries such as numpy, scipy, and numba.
Python uses the Mersene Twister.
https://docs.python.org/3/library/random.html
Thanks !
Quote: Dalex64Python is not known for it's speed, especially when executing FOR loops. It should be faster than VBA, though.
Python is easy to learn and use, and after you get down the basics, you can speed it up with external libraries such as numpy, scipy, and numba.
Python uses the Mersene Twister.
https://docs.python.org/3/library/random.html
Hi,
I need your/other comments on this python codes(cards shuffling), is it any way to shorten the code(especially line 7) so that it can run faster ? See link : https://imgur.com/a/0j18RSR
ssho88
I would do that quite a bit differently.
First off, though, I know a lot of the people who do this sort of thing for money use C for raw blazing speed, and lots of bitmask and integer operations.
Here is how you can do something similar in python.
First I would represent the deck as an ordered list of integers. 4 bits of the integers would hold the value of the card, 2 bits to hold the suit, then more bits to hold the deck number.
To avoid any lookup tables at all, you can use a bit for each value, a bit for each suit, and a bit for each deck.
That can list of numbers can be generated on the outside, and then created in your program as a literal numpy array. No need to make that up every time you run the program.
Then instead of shuffling the whole list, I would grab the cards I needed from it. This will work if you need enough to simulate a hand at a time out of a fresh deck, for instance
See numpy random choice without replacement.
https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.choice.html
You can also shuffle the whole array:
https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.shuffle.html
HERE IS THE SHORT VERSION:
do the work of generating the deck ahead of time.
If you want to keep using human readable strings, just spell out the whole two dimensional array as a literal array in a separate file and import it.
For example, file 8decks.py would be
deck = [[1,"spades"], [2,"spades],... Etc
Then import it
from 8decks import deck
That should be faster.
Quote: Dalex64I am assuming that code came from here: https://www.programiz.com/python-programming/examples/shuffle-card
I would do that quite a bit differently.
First off, though, I know a lot of the people who do this sort of thing for money use C for raw blazing speed, and lots of bitmask and integer operations.
Here is how you can do something similar in python.
First I would represent the deck as an ordered list of integers. 4 bits of the integers would hold the value of the card, 2 bits to hold the suit, then more bits to hold the deck number.
That can list of numbers can be generated on the outside, and then created in your program as a literal numpy array. No need to make that up every time you run the program.
Then instead of shuffling the whole list, I would grab the cards I needed from it. This will work if you need enough to simulate a hand at a time out of a fresh deck, for instance
See numpy random choice without replacement.
https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.choice.html
You can also shuffle the whole array:
(Saving progress, more to come)
Yes, the cards only need to be generated once and can be "re-use" in next shuffling . . . . and normally it is required to shuffle ALL cards as the game will be play until near the bottom of the deck( normally cards will be dealt 7/8 whole shoe)