Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <functional>
- #include <iostream>
- #include <iterator>
- #include <random>
- #include <vector>
- uint32_t constexpr NUM_BALLS = 80; // total balls in the game
- uint32_t constexpr NUM_DRAWN = 20; // how many balls drawn for each game
- uint32_t constexpr NUM_CHOSEN = 8; // how many balls player picks
- uint32_t constexpr MILLION = 1e6;
- uint32_t constexpr ROUNDS = 40 * MILLION;
- uint32_t constexpr bet = 4;
- int64_t player_bankroll = 0;
- int main(int argc, char *argv[])
- {
- // create the RNG
- std::random_device rd;
- std::mt19937 rng(rd());
- // create and initialize the balls
- std::vector<int> balls(NUM_BALLS, 0);
- std::generate(balls.begin(), balls.end(), [n=1] () mutable { return n++; });
- // change the last number to 10000*bet for standard paytable, 60000 was to test
- // whether a progressive was positive-EV
- std::vector<int> awards{{ 0, 0, 0, 0, 2*bet, 13* bet, 100*bet, 1652*bet, 60000 }};
- for(uint32_t i=0; i < ROUNDS; ++ i)
- {
- std::shuffle(balls.begin(), balls.end(), rng);
- // out of the first 20 balls of the randomly shuffled set,
- // count how many are below "NUM_CHOSEN + 1", i.e. assuming the
- // player always picks numbers 1-n, since all combinations are equally likely,
- // it's easier to always choose 1-n for an n-spot game. +1 is so we include n
- player_bankroll += awards[ count_if(balls.begin(), balls.begin() + NUM_DRAWN,
- std::bind(std::less<int>(), std::placeholders::_1, NUM_CHOSEN + 1)) ];
- //std::copy(balls.begin(), balls.begin() + NUM_DRAWN, std::ostream_iterator<int>(std::cout, " "));
- }
- std::cout << "EV = " << static_cast<float>(ROUNDS * bet - player_bankroll)/static_cast<float>(player_bankroll);
- //player_bankroll -= ROUNDS * bet;
- //std::cout << "Bankroll = " << player_bankroll << std::endl;
- std::cout << "RTP = " << static_cast<float>(player_bankroll)/static_cast<float>(ROUNDS * bet);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement