如何使用扑克骰子产生五个或满座的房子?

时间:2018-11-10 13:47:35

标签: javascript html html5

function getTotal(){

var answers = ["A","K","Q","J", "10","9"]

var randomAnswer = answers[Math.floor(Math.random() * answers.length)];

const side1 = answers[Math.floor(Math.random() * answers.length)];
const side2 = answers[Math.floor(Math.random() * answers.length)];
const side3 = answers[Math.floor(Math.random() * answers.length)];
const side4 = answers[Math.floor(Math.random() * answers.length)];
const side5 = answers[Math.floor(Math.random() * answers.length)];
const diceTotal = side1 + side2 + side3 + side4 + side5;
console.log("diceTotal == " + diceTotal)
}
getTotal();

上面的代码是获得随机的五个数字,例如假设“ AJK10Q”, 这里是数组A-Ace,K-King,Q-Queen,J-Jack,10和9。

我们如何产生不同的牌局可能性,例如 五种,满屋,直两对等。 如果有人可以对此发表想法或摘要,那会很好吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

一种简单的方法是拥有4个任意数字,然后随机通过它们,然后弹出卡,这样一来,您将不会获得5 As或5 Ks。

1:3