【问题标题】:Designing a hand history class for Texas Hold'em in Java用 Java 为德州扑克设计一个手牌历史类
【发布时间】:2011-06-24 18:07:13
【问题描述】:

我正在尝试为德州扑克设计一个 Java 手牌历史课程,并想在这里提出一个想法。

要求是每个动作都被存储,并且有一种有效的方法来遍历每个 HandHistory 对象(这将代表一手牌)以匹配常见的“线”,如标准持续下注(即翻牌前加注者迟到翻牌前的位置和可能在翻牌后的位置被过牌,然后进行 75% 的底池下注)。

暂时忽略每行的定义充其量是模糊的。作为第一次尝试,我正在考虑这样组织它:

public class HandHistory {
    private Integer handnumber;
    //in case we saw things at showdown, put them here
    private HashMap<Player,String> playerHands; 
    private String flopCards;
    private String turnCard;
    private String riverCard;
    private HashMap<BetRound,LinkedHashMap<Integer,ArrayList<PlayerAction>>> actions;
}

因此,对于每个下注轮,我们存储一个链接的哈希图,其键是整数,是从第一个位置开始的偏移量以执行该下注,因此翻牌前 UTG 为 0。

我们已经按照位置顺序生成了动作,所以使用链接的哈希图,这样我们就可以在以后很好地迭代并跳过闲置的位置等。

每个数组列表将包含该位置在该下注轮中的操作。大多数情况下,这个数组只有一个元素,但在像跛入然后跟注这样的情况下,它将有两个元素。

谁能看到更好的数据结构用于此?

【问题讨论】:

    标签: java poker


    【解决方案1】:

    变化不大,因为德州扑克的下注轮数是固定的,也许

    private HashMap<BetRound,LinkedHashMap<Integer,ArrayList<PlayerAction>>> actions;
    

    可能是:

    private LinkedHashMap<Integer,ArrayList<PlayerAction>>[] actions= new ... ;
    

    另外,这里有几本书可能会感兴趣:

    http://www.amazon.com/Poker-strategy-Winning-game-theory/dp/0399506691

    http://www.amazon.com/Mathematics-Poker-Bill-Chen/dp/1886070253

    【讨论】:

      【解决方案2】:
      class Card {
        // ??? probably just an int (0 to 51), but certainly not a String. 
        // Instead of using class Card below, directly using an int woulb be OK.
      }
      
      class Hand {
        Set<Card> hand; // size 2
      }
      
      class Draw { // not sure of the exact poker name for the 5 cards
        Set<Card> flop;  // size 3
        Card turn;
        Card river;
      }
      
      class Bet {
        Player player;
        // or maybe "Double" instead; then amount == null means player dropping out.
        // or use 0.0 to mean dropped out.
        double amount;
      }
      
      class BettingRound {
        // Includes initial "entry" and all subsequent calls.
        // Should include players dropping out also.
        List<Bet> bets;
      }
      
      class Game {
        Draw draw;
        Map<Player, Hand> hands;
        // rounds 0 and 1 are special since turn and river are not shown
        List<BettingRound> rounds;
      }
      

      我猜你也应该知道每个玩家有多少钱。您可以使用 Bet 类中的第三个字段(下注前的总现金)来跟踪这一点。

      【讨论】:

        【解决方案3】:

        想了一会儿,我想我已经回答了我自己的问题。我决定不尝试以表格方式存储每个动作,并尝试快速查找相同数据结构中投注线的频率计数。

        相反,我将使用我上面的类作为类似数据库的磁盘存储,并使用 DAG 作为投注线,其中边是 {action, position, player ahead} 的元组,顶点是频率计数。我认为 DAG 在这里的 trie 是正确的,因为我确实希望多个边进入一个顶点,因为具有共同后缀的线被认为是接近的。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多