On January 1, the shopping gallery in the "Capital" will not work. The food court will open at 16:00 and will be open until 22:00. Sportmaster will be open from 12:00 to 20:00, food court — from 12:00 to 22:00, Kinomax — from 12:00 to 02:00, Family — from 11:00 to 22:00 .

Here comes the new year 2021

For the holiday Lions decorated with garlands

The MFC is now accepting by appointment

Post offices will be closed for three public holidays

Do you look at the decorated shop windows?Kak_ya_uchil_neyronnie_seeti_igrat_v_kazino_xabr

How I taught neural networks to play casino / Habr

HELLO, world! Hello, Habr! My name is Mikhail, I am in my second year of South Ural State University and one of the most beloved things in my life is programming and gambling …

How I taught neural networks to play in a casino

Hello Habr! My name is Mikhail, I am in my second year of South Ural State University and one of my favorite things in my life is programming and gambling.

For about a year now I have been engaged in machine learning, which means it's time to fix the acquired skills in practice. The topic of study of the casino has long been interested in me, and my acquaintance with Sklearn and the company gave me an extensive arsenal for this.

Green - I guessed the color, red - I made a mistake, gray - the correct answer for my mistakes. It is worth noting that the precision and recall of green are two zeros :) In other words, not once, having predicted zero, I was not right and did not guess a single really dropped zero

Today we will consider other people's money, write a parser, explore data, create machine learning models and watch memes.

The idea to beat roulette is not new, unlike the idea to do this with neural networks. A little google, I stumbled mainly on the model for playing Blackjek (21).

P.S. This article is not an advertisement for gambling or a specific site. The author has repeatedly lost large sums and does not recommend that he contact anyone with a casino or bets.

We present to you the villain

The enemy will be a popular Counter Strike: Global Offensive – CSGOFAST. There are more than ten types of gambling on this site, and skins on weapons from the game CS: GO are used as a currency.

We will try to beat the euro roulette, or rather its analogue with an abbreviated number of numbers. The choice of this particular site is due to several reasons, one of them is personal scores 🙂 The rest will be discussed later.

Knives are one of the rarest and expensive objects in the game.

Rules of the game

The roll is a gambling game, which is a rotating wheel with 36 sectors of red and black colors and the 37th green sector “Zero” with a zero designation. Players playing roulette can bet on the fall of the ball on the color (red or black), even or odd number, the range (1-18 or 19-36) or a specific number.The croupier starts the ball over the roulette wheel, which moves towards the rotation of the roulette wheel, and eventually falls into one of the sectors. The winnings receive everything whose bets played (bet on color, range, one-nesting or numbers).

This is the definition of Wikipedia offers us. We will deal with a simplified version in which bets are accepted only for color loss, and the number of numbers is reduced. Yes, and there is no croupier here, the usual numbers generated by the computer 🙂

How it works with a random

At the beginning of the round (that is, before betting), a random number from 0 to 1. at the end of the round is selected on the side of the site, it is dated to 15 and rounded to the smaller direction. The resulting number is the winner number. So that the site does not twist the roulette as it likes it, from the very beginning of the round we have access to the Sha-256 hash of a random number that the site chose, and after the round and the number itself, respectively, the user can independently skip it through the Sha-256 algorithm and make sure of honesty.

The site cannot twist, since the victorious color is known before betting.

P.S. For those who are not familiar with encryption, the Sha-256 is such a thing that converts one sequence of characters to another, while in the opposite direction it is quite difficult (almost impossible). This is the joke.

Let's get down to business

First you need to decide on the data on the basis of which our model will predict the color of the next dropped number. The maximum available on the site in real time is the results of the last 50 games, as well as cash rates for the current game. So that our model does not need an additional collection of observations and it can be used from the box without waiting, we will make a prediction of the next color at 50 games. Accordingly, our first step is to write a parser for data collection.

We will use Python and the Requests-HTML library, the usual Requests will not work, since to access the results of the games you need to pre-execute the entire JavaScript page. We will record the results in .csv files.Also, I did not bother with combining data during the collection, because it is much easier to do this a couple of teams from Pandas.

We announce the class of Parser. He will have two functions, one of them will load the history of games, the other to collect information about the currently passing (these are two different pages, respectively and two functions). That is, we can get information about cash rates only from the current game, and the dropped numbers for all 50 past.

Function for loading and selecting data from the history of games

The Parser will load the HTML page, renders the entire JavaScript, select the text from the container '.history -wrap' (it contains the results of the last 50 games – what we need) and then return the convenient list from the results of the games.

The second function works similarly. Sometimes there is a moment when there is no '.Game-Bets-cheader' on the page, so the check is added.

Collection of information about cash rates

Place the whole thing in the cycle that will download data with specified intervals and write the results to the file. He will download information about cash rates much more often than one game lasts, so the recording will be created when the timer is less than a unit, or equal to 25 (the moment at which the roulette is spinning and the information about the rates can no longer change)

Parser is ready to work

Well, now we leave our whole thing for a couple of weeks so that it retains the results of the games in the background

Let's play

A couple of days have passed, the data is collected, but there are still too few of them for analysis, which means. So far, you can do others. Let's go to this roulette and see what accuracy of predictions we will get without the use of mathematics (I repeat, exclusively for research purposes!).

I identified 3 conservative methods of game:

1) game without strategy

I just relied on luck and intuition, guessing numbers. There are 7 black, 7 red and 1 green sector on the field. This means that at the rate on red/black, we have the probability of victory 7/15 or 0.466. In fact, the majority plays

Having played 100 games (without bets), I guessed the correctly 45/100 loss, which is already quite close to an analytically calculated value.Looking ahead, we will build plots using matplotlib and Pandas.

Let's combine these 2 graphs.