Skip to content
uconn code

uconn codePoker hand engine

Poker hand engine

Personal project · 2004 · Java

In 2004 I wrote a Texas Hold'em odds calculator, the Pokernator 3000, as a Java servlet at pokernator.com. This is its engine: cards and hands, a hand evaluator that turns any five to seven cards into a comparable code, and analyzers that compare your hand against every other two-card hand and work out the odds of improving on the turn and river.

In 2026 it was rebuilt from scratch in TypeScript, and the new engine still reproduces the numbers this one published.

Play the Pokernator 3000 →

Source code

11 files, 2,912 lines, exactly as written apart from line endings.

card.java · 165 lines
package com.bassoli.poker;

public class Card
{
	String suit;
	String value;
	int valueInt;

	public Card()
	{
	}
	public Card(String suit, String value)
	{
		this.suit = suit;
		this.value = value;
		this.valueInt = this.getValueInt(this);
	}
	public Card(String card)
	{
		this.suit = card.substring(0,1);
		this.value = card.substring(1,2);	
		this.valueInt = this.getValueInt(this);
	}
	public String toString()
	{
		return suit + value;	
	}

	public String getSuit()
	{
		return suit;
	}

	public String getValue()
	{
		return value;
	}
	
	public int getValueInt(Card card)
	{
		switch (card.getValue().charAt(0))
		{
			case '2': return 1;		
			case '3': return 2;	
			case '4': return 3;
			case '5': return 4;
			case '6': return 5;
			case '7': return 6;
			case '8': return 7;
			case '9': return 8;
			case 'T': return 9;
			case 'J': return 10;
			case 'Q': return 11;
			case 'K': return 12;
			case 'A': return 13;
		}	
		return 0;
	}
	
	public int getValueInt()
	{
		return valueInt;
	}
	
	public boolean isGreaterThan(Card card)
	{
		if (this.getValueInt() > card.getValueInt())
			return true;	
		else
			return false;
	}
	public boolean isGreaterThan_aceProvision(Card card)
	{
		if (this.getValueInt()%13 > card.getValueInt()%13)
			return true;	
		else
			return false;
	}
	
	public boolean isLessThan(Card card)
	{
		if (this.getValueInt() < card.getValueInt())
			return true;	
		else
			return false;
	}
	
	public boolean isSameCard(Card card)
	{
		return this.toString().equals(card.toString());
	}
	
	public boolean isSameValue(Card card)
	{
		return this.getValueInt() == card.getValueInt();
	}

	public boolean isSameSuit(Card card)
	{
		return this.getSuit().equals(card.getSuit());	
	}
	
	public boolean isNextCardBelow(Card card)
	{
		return this.getValueInt() - 1 == card.getValueInt()%13; 	
	}

	public boolean isNextCardAbove(Card card)
	{
		return this.getValueInt() + 1 == card.getValueInt(); 	
	}
	
	public static void main(String args[])
	{
		Card card = new Card("HJ");
		Card card2 = new Card("HJ");
		System.out.println(card.isGreaterThan(card2));	
	}
	
	public static int getValueInt(String alpha)
	{
		switch (alpha.charAt(0))
		{
			case '2': return 1;		
			case '3': return 2;	
			case '4': return 3;
			case '5': return 4;
			case '6': return 5;
			case '7': return 6;
			case '8': return 7;
			case '9': return 8;
			case 'T': return 9;
			case 'J': return 10;
			case 'Q': return 11;
			case 'K': return 12;
			case 'A': return 13;
		}	
		return 0;
	}	
	public static int getValueInt(char alpha)
	{
		switch (alpha)
		{
			case '2': return 1;		
			case '3': return 2;	
			case '4': return 3;
			case '5': return 4;
			case '6': return 5;
			case '7': return 6;
			case '8': return 7;
			case '9': return 8;
			case 'T': return 9;
			case 'J': return 10;
			case 'Q': return 11;
			case 'K': return 12;
			case 'A': return 13;
		}	
		return 0;
	}	
	public Object clone()
	{
		Card newCard = new Card(this.toString());	
		return newCard;
	}
}

card.java as plain text

hand.java · 68 lines

hand.java as plain text

deck.java · 78 lines

deck.java as plain text

sorthand.java · 192 lines

sorthand.java as plain text

handanalyzer.java · 508 lines

handanalyzer.java as plain text

allhandsanalyzer.java · 150 lines

allhandsanalyzer.java as plain text

winanalyzer.java · 175 lines

winanalyzer.java as plain text

pocketboardanalyzer.java · 883 lines

pocketboardanalyzer.java as plain text

handpossibilities.java · 633 lines

handpossibilities.java as plain text

probability.java · 25 lines

probability.java as plain text

constants.java · 35 lines

constants.java as plain text