用Java设计德州扑克的手历史课

rnd*_*ogy 5 java poker

我正在努力想出德州扑克的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;
}
Run Code Online (Sandbox Code Playgroud)

因此,对于每个betround,我们存储一个链接的hashmap,其键是整数,它是从第一个位置开始为该betround行动的偏移量,因此翻牌前UTG为0.

我们已经按位置顺序生成了动作,因此使用链接的hashmap,这样我们可以稍后很好地迭代并跳过坐在外面的位置等.

每个arraylist将包含该位置在该betround中的行为.大多数情况下,这个数组将有一个元素,但在像limps然后调用的情况下,它将有两个元素.

任何人都可以看到更好的数据结构用于此吗?

tot*_*to2 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;
}
Run Code Online (Sandbox Code Playgroud)

我想你还应该知道每个玩家有多少钱。您可以通过“投注”类中的第三个字段(投注前的总现金)来跟踪这一情况。