14 / 15 PROJECT

Every project

Texas Hold'em Poker in Haskell

A complete Texas Hold'em game in pure Haskell: hand evaluation, blinds, betting rounds, tie-breaking, and four AI strategies to play against.

Read the source

4
distinct ai strategies
Haskell
pure, immutable throughout
Dec 2024
project date

Every hand, ranked

The evaluator covers the whole ladder, royal flush down to high card. Ranking is only half of it: two players can hold the same category and still not split the pot, so every category carries its own comparison rule. Above that sits winner determination across several tied players at once.

Four ways to play

Four distinct strategies ship with it: Random, Passive, Aggressive and Smart. A human can sit at the same table, and human input is validated before it reaches the game. The deck is shuffled and dealt with proper randomisation, which is one of the places the program has to step outside pure functions.

There is no mutable state to fall back on, so the whole game is a value passed forward and returned changed.

Blinds, bets, elimination

The table runs the full loop rather than one hand in isolation. Small and big blinds post each round; fold, check, call and raise each carry the constraints that make them legal; chips are tracked per player and the dealer rotates. Players are eliminated when they run out, and rounds continue on top of that state, so the game runs to a result.

State without mutation

There is no mutable state to fall back on, so the whole game is a value passed forward and returned changed. Shuffling the deck needs randomness and asking a human to act needs input, so those parts sit in a monadic layer while the rules underneath stay pure functions over immutable data.

What it does

  1. Complete poker hand evaluation system (Royal Flush to High Card)
  2. Four distinct AI strategies: Random, Passive, Aggressive, and Smart
  3. Human player interaction with input validation
  4. Full betting mechanics (fold, check, call, raise) with proper constraints
  5. Comprehensive tie-breaking system for all hand types
  6. Proper blind system implementation (small/big blinds)
  7. Multi-round gameplay with chip tracking and dealer rotation
  8. Advanced functional programming patterns and monadic IO
  9. Deck shuffling and card dealing with proper randomization
  10. Complete game state management and player elimination
  11. Sophisticated winner determination with multiple tied players
  12. Pure functional implementation with immutable data structures

Built with

  • Haskell
  • Functional Programming
  • Game Development
  • AI
  • Random Generation
  • Monadic Programming