Spin and Go 'variance' Simulation

    • nsavov
      nsavov
      Silver
      Joined: 24.09.2010 Posts: 702
      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 :f_drink:

      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 buyIn = 1; //buy-in /*|*/
      /*|*/ 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:

      for(int gameNumber=1; gameNumber<=numberOfGames; gameNumber++){


      currentBankroll-=buyIn; //buy-in
      rake +=buyinFee; //rake generated


      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){
      currentBankroll+=3000*buyIn;
      } else{
      currentBankroll+=300*buyIn;
      }
      }

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

      if (winOrLose<=winRate){
      currentBankroll+=200*buyIn;
      } else{
      currentBankroll+=20*buyIn;
      }
      }

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

      if (winOrLose<=winRate){
      currentBankroll+=100*buyIn;
      } else{
      currentBankroll+=10*buyIn;
      }
      }

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

      if (winOrLose<=winRate){
      currentBankroll+=25*buyIn;
      }
      }

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

      if (winOrLose<=winRate){
      currentBankroll+=10*buyIn;
      }
      }

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

      if (winOrLose<=winRate){
      currentBankroll+=6*buyIn;
      }
      }

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

      if (winOrLose<=winRate){
      currentBankroll+=4*buyIn;
      }
      }

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

      if (winOrLose<=winRate){
      currentBankroll+=2*buyIn;
      }
      }




      // --- 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

      if(gameNumber%resultsDivider==0){
      cout<<"Spins played: "<<gameNumber<<"t bankroll: "<<currentBankroll<<" rake: "<<rake<<endl;
      }



      //if you lose your bankroll

      if(currentBankroll<1){
      cout<<"YOU LOST YOUR BANKROLL ON "<<gameNumber<<"th spin"<<endl;
      break;
      }
      }
      //final stuff (BOTTOM OF THE SCREEN!)
      ROI=(100*((double)currentBankroll-(double)startingBankroll)/(double)numberOfGames)/buyIn;
      cout<<endl<<"YOUR ROI IS: "<<ROI<<"%"<<endl;
      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 :f_cool:

      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! :happy:
  • 4 replies
    • Lazza61
      Lazza61
      Headadmin
      Headadmin
      Joined: 23.03.2011 Posts: 9,209
      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 :f_drink:

      Laz
    • tonypmm
      tonypmm
      Silver
      Joined: 11.01.2009 Posts: 3,853
      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.
    • nsavov
      nsavov
      Silver
      Joined: 24.09.2010 Posts: 702
      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 :pcuser:
    • tonypmm
      tonypmm
      Silver
      Joined: 11.01.2009 Posts: 3,853
      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 :pcuser:
      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.