gpt4 book ai didi

javascript - 确定牌 table 位置 - Sit'n Go 锦标赛

转载 作者:数据小太阳 更新时间:2023-10-29 05:32:33 28 4
gpt4 key购买 nike

Note: I do the javascript code according to the ajrwhite answer. Hope it helps someone.

Link: http://codepen.io/eMineiro/pen/EKrNBe

Open codepen console to see the examples working.

在扑克中,我们根据庄家定义玩家位置。像这样:

enter image description here

蓝色:小盲注和大盲注位置

绿色:迟到和经销商/迟到位置

黄色:中间位置

粉红色:早期位置

所以,假设这两个数组:

players:[1,2,3,4,5,6,7,8,9,10];
positions:["bb","sb","btn","late","medium","medium","medium","early","early","early"];

在这种情况下,“玩家 1”是“大盲注”,“玩家 2”是“小盲注”,“玩家 3”是“按钮”......

我想在调用 changePositions(dealer) 时对玩家数组进行排序。示例:

changePosition(10); //means that "player10" now is the new Dealer

结果应该是:

players:[2,1,10,9,8,7,6,5,4,3];
positions:["bb","sb","btn","late","medium","medium","medium","early","early","early"];

在游戏过程中,玩家可能会被淘汰。所以我有一个功能可以排除“位置数组”中的“最后位置”并排除玩家。然后我需要再次调用 changePosition(X),其中 X 是“player10”(实际发牌人)左侧的下一个未被淘汰的玩家。

被淘汰的“玩家 1”的例子,新数组应该是:

players:[2,10,9,8,7,6,5,4,3];
positions:["bb","sb","btn","late","medium","medium","medium","early","early"];

我需要再次调用 changePosition(X) 来确定新位置,在本例中 X=2,因为“player2”在实际发牌人“player10”的左侧

changePosition(2);

结果应该是:

players:[4,3,2,10,9,8,7,6,5];
positions:["bb","sb","btn","late","medium","medium","medium","early","early"];

玩家被淘汰后如何找到新的庄家?

Note: I created a function named changeNextDealer(). Negative index was not the problem, because the next dealer is clockwise. It's in the code pen link.

dealerArrayPosition-1; //But if bigBlind and smallBlind was eliminated simultaneously I get a negative position.

如何将负索引(如 -1)映射到最后一个位置。或者 -2 到 LastPosition-1?有什么快速的方法吗?

Note: This question is still no answered, but is not the main question of this discussion. I think a will ask in a separated post.

我应该怎么做 changePosition(dealer) 功能?

我已经尝试了很多,但不知道该怎么做。

Note: I created a function named changePosition(). It's in the codepen link.

最佳答案

让我们假设玩家总是编号为 1-10。我们不需要两个数据结构来存储玩家的位置和状态。我们只需要一个索引数据结构来存储玩家状态:

状态 1

positions:["btn","sb","bb","early","early","early","medium","medium","medium","late"];

状态 2

positions: ["late","btn","sb","bb","early","early","early","medium","medium","medium"]

状态 3

positions: ["eliminated","late","btn","sb","bb","early","early","early","medium","medium"];

这存储的信息量与您的两个数组相同,并且更加一致。您只需访问 positions[0] 即可查看玩家 1 的状态或访问 positions[9] 查看玩家 10。

现在有了这种更一致的结构,应该更容易处理每一轮结束时的状态变化。

淘汰玩家

每一轮结束后,将被淘汰玩家的状态更改为"eliminated"。此时您可能需要一个临时数组,以便您可以检查上一轮发生的事情仍然会为下一轮更新信息。

如何把数组看成一个圆

将经销商筹码 "btn" 移动到 (currentPositionOfBtn+1)%10 - 这意味着按钮从 1 移动到 2 再到 3,等等,但是通过使用余数运算符和玩家总数,我们确保从位置 9(玩家 10)开始的移动循环回到 0(玩家 1)。

如果 currentPositionOfBtn+1)%10 中的玩家已被淘汰,则检查 currentPositionOfBtn+2)%10 等等 - 这是一个易于实现的循环.

重新计算位置

现在鉴于位置的描述随着玩家被淘汰而改变(到最后你没有“早期”或“中等”),我建议在每轮结束时从庄家开始重新计算位置,跳过超过任何标记为“淘汰”的玩家。

关于javascript - 确定牌 table 位置 - Sit'n Go 锦标赛,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37091503/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com