5

我正在尝试为德州扑克设计一个 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。

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

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

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

4

3 回答 3

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

于 2011-06-26T18:46:33.920 回答
0
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 类中的第三个字段(下注前的总现金)来跟踪这一点。

于 2011-06-24T19:05:30.040 回答
0

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

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

于 2011-06-26T16:54:37.713 回答