我目前正在写一个函数,会问你,你的甲板尺寸,你在甲板上有一个特定的卡,你最初的手掌大小,卡量的复印量你(我们正在将图形卡放在一边画图,然后将混合后的牌洗牌回来),以及你想要画什么牌。万智牌抽概率函数在C
从本质上讲,我乘不拉丝卡在一起(然后做1个减去概率)给我画一个特定的卡由特定转的概率的所有可能性。到目前为止,我的功能如下所示:
void card_probability() {
int total;
int numCopies;
int n;
int m;
int turn;
double initial_draw_prob;
double mulligan_prob;
double draw_prob;
double neg_probability;
double probability;
printf("Enter how many total cards there are in the deck: ");
scanf("%d", &total);
printf("Enter how many copies of the card that you are looking for are
in the deck: ");
scanf("%d", &numCopies);
printf("Enter your initial hand size: ");
scanf("%d", &n);
printf("Enter how many cards you are mulliganing: ");
scanf("%d", &m);
printf("Enter what turn you want to draw the card by: ");
scanf("%d", &turn);
initial_draw_prob = ((total - numCopies)/total);
//for loop{}
mulligan_prob = ((total - numCopies - n)/(total - n));
//for loop{}
draw_prob = ((total - numCopies - n - m)/(total - n - m));
//for loop{}
neg_probability = initial_draw_prob * mulligan_prob * draw_prob;
probability = 1 - neg_probability
printf("The probability of drawing at least one of the cards by turn %d
given you mulliganed %d cards is %lf", turn, m, probability);
}
int main(){
card_probability();
return 0;
}
我无法设置这些循环以正常工作。本质上发生的是三个不同的概率部分:
1.)不是在第一手牌中画出所需牌的概率 (total - numCopies)/(总数)是在第一次抽牌时不抽牌的概率。然后,例如,如果你画了7张牌,你会继续前进,并将概率乘以一致直到达到该项(总数 - 总数 - 7)
2.)不抽牌的概率在你修改了一个指定的金额后。
3)不领取该卡由指定的转概率。
谁能帮我设置这些for循环?我无法获得正确的增量。我没有在纸上的数学,并与10甲板的尺寸,卡我想,2手的大小,1·穆利根2份,和3选择转我得到不拉丝卡的16.66%%的机率=>大约83%的转3.
为什么你的标题中使用C语言,而标签中使用C++?你在用哪个?例如,如果你使用的是C++,你应该使用'std :: string'代替文本,'std :: vector'代替数组。 –
我正在使用C.我编辑了标签。感谢您的关注! – jzurks
倾向于使用'fscanf'而不是[危险'scanf'](https://www.google.com/search?q=scanf+danger&ie=utf-8&oe=utf-8)。 –