【问题标题】:Doubling Game Simulation加倍游戏模拟
【发布时间】:2018-01-18 19:48:57
【问题描述】:

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

我已经为以下游戏编写了一个模拟器(给定一副牌和 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 卡的获胜系数。它显示了这些让我非常怀疑的数字。我预计它会增长到 1.5 到 7 然后再回到 1。

(先胜/模拟次数,第二最大发牌员可以让你继续游戏)

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);
        }
    }
}

}

【问题讨论】:

  • 那么问题或问题是什么?
  • 抱歉忘记加了,想知道这个模拟器好不好用
  • 你的意思是“pick”(你选择卡片的地方)还是“draw”(随机分配的地方)?
  • 我的意思是你随机抽卡,你不知道你得到了什么。

标签: c# algorithm statistics simulation probability


【解决方案1】:

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

关于百搭牌的价值以及庄家是在抽牌时丢弃百搭牌还是魔法不抽牌,你的问题描述含糊不清——如果我没看错你的代码,你似乎选择了后者。

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

当我用另一种语言独立实现这一点时,我得到了可比较的结果。在我看来你的直觉是错误的。

【讨论】:

    猜你喜欢
    • 2019-05-09
    • 2010-11-28
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 2011-02-17
    • 2017-03-01
    相关资源
    最近更新 更多