小编Hap*_*ppo的帖子

兰德函数,产生3个值的概率(对于简单的老虎机)?

我正在制作一个简单的(终端)老虎机项目,其中3个水果名称将在终端输出,如果它们都相同则玩家获胜.

我无法弄清楚如何设定玩家将赢得该轮次的概率(例如大约40%的机会).截至目前,我有:

     this->slotOne = rand() % 6 + 1;              // chooses rand number for designated slot
     this->oneFruit = spinTOfruit(this->slotOne); //converts rand number to fruit name

     this->slotTwo = rand() % 6 + 1;
     this->twoFruit = spinTOfruit(this->slotTwo);

     this->slotThree = rand() % 6 + 1;
     this->threeFruit = spinTOfruit(this->slotThree);
Run Code Online (Sandbox Code Playgroud)

根据数字选择"水果",但三个位置中的每一个都有1/6的机会(看到有6个水果).由于每个单独的插槽有1/6的机会,总体而言,获胜的可能性非常低.

我如何解决这个问题以创造更好的赔率(甚至更好,选择赔率,在需要时改变赔率)?

我想把第二个两个旋转更改为更少的选项(例如rand()%2),但这会使最后两个插槽每次选择相同的几个水果.

我项目的链接:https://github.com/tristanzickovich/slotmachine

c++ random probability

1
推荐指数
1
解决办法
632
查看次数

标签 统计

c++ ×1

probability ×1

random ×1