加倍游戏模拟

Doubling Game Simulation

我想知道这个模拟器是否正常工作,因为我不认为这些是合乎逻辑的答案,但也无法捕获错误。

我已经为以下游戏编写了一个模拟器(给定一副纸牌和 1 点)以找到最佳策略(庄家继续游戏的最高牌是什么)

 1. Dealer picks a card and shows it to you(Dealer can't pick Joker)
 2. You decide whether to play or no
 3.1. If you don't play you get current points and finish game
 3.2. If you play you pick a Card
 3.2.1. If your card is higher you get double points and go back to step 1
 3.2.2. If your and dealer's cards are equal you go back to step 1
 3.2.3. If dealer's card is higher you lose all points and finish

模拟显示选择每张 MAX 卡的获胜系数 play.It 显示这些数字非常值得怀疑 me.I 预计它会增长到 1.5 直到 7 然后回到 1。

(First-Win/number次模拟,庄家可以拿到Second-Max牌供您继续游戏)

1 -1
1.0853817 0
1.1872532 1
1.3126581 2
1.4672619 3
1.6704736 4
1.9485809 5
2.2674231 6
2.9993735 7
3.5692085 8
4.3581477 9
4.0109722 10
2.3629856 11
0 12

这是 C# 代码:

using System;

namespace Codeforces
{
    class Program
    {
    static int[] k = new int[54];

    static Random rand = new Random();

    static long Doubling(int i, long f)
    {
        int d = rand.Next(52);

        if (k[d] > i) return f;

        int ch = d;
        while (ch == d) ch = rand.Next(54);

        if (k[d] > k[ch]) return 0;

        if (k[d] == k[ch]) return Doubling(i, f);

        return Doubling(i, f * 2);
    }

    static void Main(string[] args)
    {
        for (int i = 0; i < 54; i++) k[i] = i / 4;

        for (int i = -1; i < 13; i++)
        {
            long sum = 0;
            for (int j = 0; j < 1e7; j++)
            {
                sum += Doubling(i, 1);
            }

            Console.WriteLine(sum / 1.0e7 + " " + i);
        }
    }
}

}

我不是 C# 程序员,但看起来您的基本方法大部分是正确的。我建议使用循环而不是递归。

关于王牌的价值以及庄家是在抽到王牌时丢弃王牌还是神奇地不抽到王牌,您的问题描述含糊不清——如果我正确阅读了您的代码,您似乎选择了后者。

似乎您实现递归的方式在每次玩游戏后隐式替换了牌组中的牌,而不是玩完牌组。

当我用另一种语言独立实现它时,我得到了类似的结果。在我看来你的直觉是错误的。