【发布时间】:2016-09-29 09:14:16
【问题描述】:
我目前正在尝试制作一种扑克算法,可以用 2 张牌创建所有可能的扑克组合。我知道有 1,326 种起手牌组合。 所以我创建了这样的起始牌组:
$startingDeck = array();
for($i=1; $i <= 13; $i++)
{
for($x=0; $x <= 3; $x++)
{
array_push($startingDeck, array("Value" => $i ,"Color" => $x, "key"=> $i.$x));
}
}
我现在想遍历所有卡片并获得所有可能的组合,例如 2 张卡片
: value 1 color 1 and value 1 color 2
: value 1 color 1 and value 1 color 3
... etc
: value 2 color 0 and value 1 color 1
: value 2 color 0 and value 1 color 2
... etc
我想对所有可能的组合执行此操作,但如何操作。
【问题讨论】: