破译RayW扑克手牌评估器
Deciphering RayW Poker Hand Evaluator
我正在尝试破译这段代码:https://github.com/tangentforks/TwoPlusTwoHandEvaluator/blob/master/generate_table.cpp
该代码用于生成一个巨大的查找表,然后用于查找 7 手牌的手牌排名。我很难准确破译为什么主方法以这种方式编写。据我所知,第一个 for 循环会暴力破解每个卡片组合,并在必要时替换适当的花色抽象,但我不确定为什么在下一节中重复这样做,或者为什么它按 53 倍缩放然后加 53。谁能对此有所了解?
这是有问题的代码:
printf("nGetting Card IDs!n");
// Jmd: Okay, this loop is going to fill up the IDs[] array which has
// 612,967 slots. as this loops through and find new combinations it
// adds them to the end. I need this list to be stable when I set the
// handranks (next set) (I do the insertion sort on new IDs these)
// so I had to get the IDs first and then set the handranks
for (IDnum = 0; IDs[IDnum] || IDnum == 0; IDnum++) {
// start at 1 so I have a zero catching entry (just in case)
for (card = 1; card < 53; card++) {
// the ids above contain cards upto the current card. Now add a new card
ID = MakeID(IDs[IDnum], card); // get the new ID for it
// and save it in the list if I am not on the 7th card
if (numcards < 7) holdid = SaveID(ID);
}
printf("rID - %d", IDnum); // show progress -- this counts up to 612976
}
// main()
printf("nSetting HandRanks!n");
// this is as above, but will not add anything to the ID list, so it is stable
for (IDnum = 0; IDs[IDnum] || IDnum == 0; IDnum++) {
// start at 1 so I have a zero catching entry (just in case)
for (card = 1; card < 53; card++) {
ID = MakeID(IDs[IDnum], card);
if (numcards < 7) {
// when in the index mode (< 7 cards) get the id to save
IDslot = SaveID(ID) * 53 + 53;
} else {
// if I am at the 7th card, get the equivalence class ("hand rank") to save
IDslot = DoEval(ID);
}
maxHR = IDnum * 53 + card + 53; // find where to put it
HR[maxHR] = IDslot; // and save the pointer to the next card or the handrank
}
if (numcards == 6 || numcards == 7) {
// an extra, If you want to know what the handrank when there is 5 or 6 cards
// you can just do HR[u3] or HR[u4] from below code for Handrank of the 5 or
// 6 card hand
// this puts the above handrank into the array
HR[IDnum * 53 + 53] = DoEval(IDs[IDnum]);
}
printf("rID - %d", IDnum); // show the progress -- counts to 612976 again
}
目前也在做同样的事情。它被移动了 53,因为有 52 张牌。指向无效状态后,将转换为 0。从那里开始,您选择的任何卡仍然必须导致无效状态,因此前 53 个条目 0 + 52 排名指向 0。第一个有意义的条目出现在 53..(53+53(。
首先尝试理解概念。该表是一个巨大的有向图,其中每个节点有 52 个子节点和一个索引 0 处的"评估当前-手-排名节点"。poker-ai.org 和原始线程提供了许多有用的信息。另请查看CactusKevs的想法,通过使用质数获得牌上的手牌排名顺序。天才。这一切都涉及到这一点。
相关文章:
- 使用std::multimap迭代器创建std::list
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- Linux的Cpp上的计时器
- std::condition_variable::wait()如何评估给定的谓词
- Ardunio UNO解决了多个重叠的定时器循环
- 提升 ASIO 无法识别计时器对象
- 破译RayW扑克手牌评估器
- 它可能的 C++ 正则表达式评估器与 Lambda 像 Ruby 一样?
- 在新表达式中,在内存分配后评估了初始化器
- 如何在三角形曲面细分评估着色器中插值 UV 映射坐标?
- C/C++优化器是否可以决定延迟评估仅用于短路评估的值
- 镶嵌评估着色器链接错误
- 用于编码竞赛的C编码评估器
- 中缀到后缀转换器 + 评估程序正确打印到控制台,但不正确地打印到文本文件
- C++:传递结构与提供评估器功能
- C++ 业务规则表达式解析器/评估
- 在评估中使用多个'greater-than / less-than'比较器是否合适?
- 在取消引用-*iter++之后对迭代器进行后递增.它是如何评估的
- 评估牌的一手视频扑克
- 二加二扑克手牌评估器:牌是如何映射到整数的