兰德函数,生成 3 个值的概率(对于简单的老虎机)?
Rand function, generate probability across 3 values (for simple slot machine)?
我正在做一个简单的(终端)老虎机项目,其中终端会输出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);
根据数量选出一个"fruit",但是三个槽位各有6分之一的几率(看有6个水果)。由于每个单独的插槽有 1/6 的机会,因此整体获胜的概率非常低。
我将如何解决这个问题以创造更好的赔率(或者甚至更好,选择赔率,在需要时改变赔率)?
我想将后两个旋转更改为更少的选项(例如 rand()%2),但这会使最后两个插槽每次都选择相同的一对水果。
作弊。
先决定玩家是否获胜
const bool winner = ( rand() % 100 ) < 40 // 40 % odds (roughly)
然后想出一个支持你决定的结果。
if ( winner )
{
// Pick the one winning fruit.
this->slotOne = this->slotTwo = this->slotThree = rand() % 6 + 1;
}
else
{
// Pick a failing combo.
do
{
this->slotOne = rand() % 6 + 1;
this->slotTwo = rand() % 6 + 1;
this->slotThree = rand() % 6 + 1;
} while ( slotOne == slotTwo && slotTwo == slotThree );
}
您现在可以玩弄玩家的情绪,就像玩拉斯维加斯一样。
我正在做一个简单的(终端)老虎机项目,其中终端会输出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);
根据数量选出一个"fruit",但是三个槽位各有6分之一的几率(看有6个水果)。由于每个单独的插槽有 1/6 的机会,因此整体获胜的概率非常低。
我将如何解决这个问题以创造更好的赔率(或者甚至更好,选择赔率,在需要时改变赔率)?
我想将后两个旋转更改为更少的选项(例如 rand()%2),但这会使最后两个插槽每次都选择相同的一对水果。
作弊。
先决定玩家是否获胜
const bool winner = ( rand() % 100 ) < 40 // 40 % odds (roughly)
然后想出一个支持你决定的结果。
if ( winner )
{
// Pick the one winning fruit.
this->slotOne = this->slotTwo = this->slotThree = rand() % 6 + 1;
}
else
{
// Pick a failing combo.
do
{
this->slotOne = rand() % 6 + 1;
this->slotTwo = rand() % 6 + 1;
this->slotThree = rand() % 6 + 1;
} while ( slotOne == slotTwo && slotTwo == slotThree );
}
您现在可以玩弄玩家的情绪,就像玩拉斯维加斯一样。