# Spin and Go 'variance' Simulation

• Bronze
Joined: 24.09.2010
Hey guys, I was bored today and decided to exercise some C++ programming, so I wrote a simulator for spins. I hope you find it interesting to play with! Check it out:

http://cpp.sh/5deq

Here is the code if the link doesnt work for some reason. Just copy it and paste it on that site or some other online c++ compilator:

#include <iostream>
#include <stdio.h> /* printf, scanf, puts, NULL */
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */

using namespace std;

int main()
{

/*|*/ //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------/*|*/
/*|*/ /*|*/
/*|*/ /*|*/
/*|*/ //ENTER YOUR RESULTS/STATS HERE: /*|*/
/*|*/ const int winRate = 39; // the % of tournaments you expect to win. winRate = (chipEV + 500)/1500 For example: If our chipEV winnings are 100 chips per game our winrate would be 40% because (100+500)/1500 = 40. /*|*/
/*|*/ const int startingBankroll = 200; // starting bankroll you begin with /*|*/
/*|*/ const int numberOfGames = 10000; // how many games to simulate /*|*/
/*|*/ const int resultsDivider = 10; // how often to show results. 1 will show every result, 10 will show every 10th spin /*|*/
/*|*/ const double buyinFee = 0.07; //rake /*|*/
/*|*/ /*|*/
/*|*/ //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------/*|*/

int game; // random number which determines what we play fore. if we hit 1 we play for 3000, if we hit 2-6 we play for 200 and so on...
int winOrLose; // random number 1-100. If the number is less than our "winRate", we win, if its bigger, we lose
int currentBankroll = startingBankroll; //your `current` bankroll which will show in the end
int lowestBankroll = currentBankroll;
double rake = 0; //rake...
double ROI;
srand (time(NULL)); //time seed for randomness

// The simulation loop:

game = rand()%100000 + 1; //what price are we playing for. The less the number is the better the price
winOrLose = rand()%100 + 1; //are we going to win this game

// Checking what price the spin is and is it won ---

// 1 in 100 000 for \$3 000
if(game==1){

if (winOrLose<=winRate){
} else{
}
}

// 5 in 100 000 for \$200
else if(game>1 && game<=6){

if (winOrLose<=winRate){
} else{
}
}

// 10 in 100 000 for \$100
else if(game>6 && game<=16){

if (winOrLose<=winRate){
} else{
}
}

// 100 in 100 000 for \$25
else if(game>16 && game<=116){

if (winOrLose<=winRate){
}
}

// 500 in 100 000 for \$10
else if(game>116 && game<= 516){

if (winOrLose<=winRate){
}
}

// 7 500 in 100 000 for \$6
else if(game>516 && game<=8016){

if (winOrLose<=winRate){
}
}

// 19 866 in 100 000 for \$4
else if(game>8016 && game<=26382){

if (winOrLose<=winRate){
}
}

// 72 018 in 100 000 for \$2
else if(game>26382 && game<=100000){

if (winOrLose<=winRate){
}
}

// --- End Checking

//get the lowest bankroll
if(lowestBankroll > currentBankroll){
lowestBankroll = currentBankroll;
}

//with this if-statement it shows results less often. You can change the number at the beginning

cout<<"Spins played: "<<gameNumber<<"t bankroll: "<<currentBankroll<<" rake: "<<rake<<endl;
}

if(currentBankroll<1){
break;
}
}
//final stuff (BOTTOM OF THE SCREEN!)
cout<<endl<<"THE LOWEST YOUR BANKROLL GOT IS: "<<lowestBankroll<<endl;
return 0;
}

You can change the win rate, starting bankroll, number of games and how often to show results. Just click Run when you are ready.
Its preferable not to touch other stuff if you dont know what you doing

Sorry, I couldnt make some stats like "biggest downswing/upswing" I tried but my head started to hurt, if someone has an idea, you are welcome to edit and share it! Also if someone is good at visual c++ to add graphs it would be really cool!
• 4 replies
Joined: 23.03.2011
Hey nsavov,

Awesome bit of work. Works like a treat from the link. Definitely think regular Spin 'N' Goers' have a fiddle inputting their own numbers.

Cheers

Laz
• Silver
Joined: 11.01.2009
At a glance, it seems that your program doesn't do anything that SwongSim wouldn't be able to do (except for telling the moment when the bankroll is lost); however, it's nice to have readable open-source code that we can modify if needed, e.g. if we want to run a simulation for a mix of stakes (e.g. if the higher stake is played only at softer offpeak hours) or even a mix with other poker formats.
• Bronze
Joined: 24.09.2010
Yeah... I didnt realize there is already a better program. Oh well, I had fun writing it, nevertheless.

that was a good idea to incorporate buy-ins, heres the new version:
http://cpp.sh/5deq

It seems when we lose our bankroll it shows incorrect ROI, cant seem to fix it
• Silver
Joined: 11.01.2009
I'm bumping this and subscribing in case anyone wishes to improve the program (I'm afraid I won't find enough energy this month because the grind will be taking it all). The option to mix different stakes (at low traffic times at the 30s+) or to add occasional MTTs (with a payout structure read from a file) to the daily Spin grind would be particularly interesting.

Originally posted by nsavov
It seems when we lose our bankroll it shows incorrect ROI, cant seem to fix it
At line 157, you should divide by gameNumber (the number of games that Hero has actually been able to play), not by numberOfGames (the initially set sample), and by (double)buyIn (typecast) instead of the integer variable buyIn itself.