kartik8800's blog

By kartik8800, history, 5 years ago, In English

Hello Codeforces!!

Recently I was fascinated about two of the most amazing things in the world : money and ofcourse algorihtms xD. I saw some interesting games played at casinos and I thought about one of them for quite a while : The Roulette.

The Roulette

Consider a spinning wheel with numbers from 1 to 12 marked on it. Each number has an equal probability of showing after the wheel has stopped spinning. The player(will avoid the word gambler) has the following power : he may bet some coins on either odd/even. Let's say the player bets x coins on even. If the roulette after spinning shows an even number than the player gets 2x coins otherwise he loses x coins. Similarly if the player bets x coins on odd then he will win 2x coins if roulette shows an odd number after spinning.

Possibility of an Algorithm for winning?

So is it possible for us to design a sure-shot algorithm that can guarantee the player to win some profit?

Spoiler

Then why are we even here?
So it might not be possible to guarantee a profit but maybe we can come up with strategies/algorithms that make a certain amount of profit with a certain confidence/probability.

Motivation : The Martingale Algorithm

So the martingale algorithm in my opinion is simple and brilliant with a great deal of drawbacks.
Suppose that we wish to make a profit of x coins.
Here is the algortihm:

 Let X be an integer.
1. Bet X coins on odd.
2. Let the roulette spin.
3. If outcome is odd, go to step 5.
4. X := 2 * X and go to step 1.
5. END.

Wonderful, isn't it? Sorry to say that it has a great deal of drawback because to be fair it has only 1 drawback.

Drawback

Also another drawback which for now we will overlook : usually casinos have an upper limit on the bet you can place. In the very unlikely event of lots of consecutive loses there will be a disaster.

"I have enough coins and the amount of profit I want to make is considerably smaller, nearly 1% of the coins I have. What is the chance I stand to win this profit using martingale algorithm?"

Probability

Cooool, so now probably I should give some modified or new strategy for higher winning chances? No, instead I am here with a challenge.

The Challenge

You are given 10K coins, you need to come up with an algorithm/strategy which stands a good chance of winning/making profits.

There will be exactly 5K roulette spins, giving you the opportunity to make bets.

I am super interested in people coming up with some algorithms that maximize the chance of winning.

So here is the challenge, design a strategy and implement it to check what profit do you make. Here I am providing a template code in which the user simply needs to implement the make_bet() function. Basically you will be building a betting bot to play roulette for you and earn as much as possible.

What about the bot getting lucky? How will scoring be done?

Scoring

A few rules :
Try to keep your bot deterministic/don't use rand() in your make_bet function.
Do not try to utilize the pseudo-randomness of rand(), if that is a possibility.

I know we all would love to maximize the score of the bot.
Here is the template code : Betting Bot challenge
Hope people find this fun and interesting.

P.S. Do not gamble :)

  • Vote: I like it
  • +26
  • Vote: I do not like it

»
5 years ago, # |
Rev. 2   Vote: I like it +5 Vote: I do not like it

Hmmm, a nice initiative, Maybe I could steal some of the solutions of others to the challenge to trade the E-mini futures. Lambo here I come.

»
5 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Doubling your bet whenever you lose is pretty standard. I have another fun challenge for you to think about.

Consider a game of blackjack. Given what the other people are being dealt at the table, what you've been dealt, and how big the deck is, use an algorithm to determine your bet size.

This is called counting cards. It really is fascinating and used by professional gamblers all the time. There isn't one answer to this, so have fun with it.

Hint: Maintain integer that represents the amount of low cards that have been dealt (2-5) and the amount of high cards (faces).

I don't condone gambling btw LOL

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    Yes I was aware that certain strategies and algorithms exist for card games, however they require more knowledge of the game being played.(I have never played blackjack and I don't know the rules)

    The concept of Roulette is comparatively much easier to understand.

    Btw good to know your viewpoint on gambling xD

»
5 years ago, # |
  Vote: I like it +6 Vote: I do not like it

If you start with X coins, any finite strategy will get X coins at the end on average. You can read more about the expected value or gambler's ruin.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +2 Vote: I do not like it

    Thanks for sharing this, I wasn't aware. Still from my understanding of the concept, setting smaller profit goals when you have large initial wealth to start with has a high chance of achieving. But again it's not that great for someone to earn a dollar when they had 10 million to start with.

    Also for other's who are interested in knowing the concept mentioned : https://youtu.be/Ne2lmAZI4-I