Skip to content

BH1SCW/javapokertexasholdem

 
 

Repository files navigation

It’s a Java SE implemention for Texas Hold’em Poker

You can see the Texas Hold’em Poker implementation in action on pablocantero.com/javapokertexasholdem-demo

The javapokertexasholdem-demo is not part of this implemetation, it’s external project

The Texas Hold’em Poker implementation is only a ‘core engine’ without presentation tier

My suggest is to use this project like a black box library. If your system uses other types of card or game flow, the best way is encapsulate it, in an Adapter, Decorator, Proxy or other design patterns

Check out the following example

GameTexasHoldem game = new GameTexasHoldem(); IPlayer homer = new Player(); IPlayer flanders = new Player(); IDeck deck = new Deck(); //The Deck and Player used in the GameTexasHoldem are interfaces. GameTexasHoldem avoids strong relationships //The newGame signature: public void newGame(IDeck deck, IPlayer player1, IPlayer… _players) //First player is obrigatory to start the game, but you can add N other players after the first (Java Varargs) game.newGame(deck, homer, flanders); game.deal(); game.callFlop(); game.betRiver(); game.betTurn(); List<IPlayer> winnerList = game.getWinner(); if(winnerList.size() > 1){ //DRAW GAME } if(winnerList.contains(homer)) { //HOMER WINNER //WINNER HAND: homer.getRankingEnum(); } if(winnerList.contains(flanders)) { //FLANDERS WINNER //WINNER HAND: flanders.getRankingEnum(); } //The table cards game.getTableCards(); //To get the player actual ranking homer.getRankingEnum(); flanders.getRankingEnum(); //IPlayer.getRankingEnum() can be changed in deal, call flop, bet river and bet turn

The IPlayer.getRankingEnum() method returns RankingEnum that contains the actual ranking of the player public static enum RankingEnum { ROYAL_FLUSH, STRAIGHT_FLUSH, FOUR_OF_A_KIND, FULL_HOUSE, FLUSH, STRAIGHT, THREE_OF_A_KIND, TWO_PAIR, ONE_PAIR, HIGH_CARD }

Performance test

GameTexasHoldemRunner.main() execute this performance tests and output two CSV reposts

  • Macbook pro

  • HD ATA de 320 GB (5.400 rpm)

  • Memory 4GB 1066MHz DDR3 SDRAM - 2x2GB

  • Processor 2.53GHz Intel Core 2 Duo

  • O.S. Snow Leopard

  • 100000 executions = 6 seconds

  • 10000 executions = 1 seconds

Reports

Example for 10000 executions

executions: 10000, minutes: 0, seconds: 1 getStatsSimple - OK - /Users/pablo/workspace/javapokertexasholdem/stats10000-simple.csv getStatsFull - OK - /Users/pablo/workspace/javapokertexasholdem/stats10000-full.csv

getStatsSimple

Columns:

  • STATS = RankingEnum winner

  • COUNT = how many times the same RankingEnum winner occurs

  • PERCENT = percentual of the COUNT compared with all executions

getStatsFull

Columns:

  • DEALER DEAL = dealer RankingEnum in the deal step

  • PLAYER DEAL = player RankingEnum in the deal step

  • DEALER CALL FLOP = dealer RankingEnum in the call flop step

  • PLAYER CALL FLOP = player RankingEnum in the call flop step

  • DEALER BET TURN = dealer RankingEnum in the bet turn step

  • PLAYER BET TURN = player RankingEnum in the bet turn step

  • DEALER BET RIVER = dealer RankingEnum in the bet river step

  • PLAYER BET RIVER = player RankingEnum in the bet river step

  • WINNER = winner name (player or dealer)

  • COUNT = how many times the same game occurs

  • PERCENT = percentual of the COUNT compared with all executions

About

It's a Java SE implemention for Texas Hold'em Poker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published