Skip to content

About

iOS Texas Hold'em Poker Game

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

160 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿƒ iOS Texas Hold'em Poker

Swift iOS License Status

A professional Texas Hold'em poker game built with SwiftUI

English | ไธญๆ–‡


โœจ Features

๐ŸŽฎ Game Modes

  • Tournament Mode - Compete against AI players with increasing blind levels
  • Cash Game Mode - Flexible play with buy-in/top-up system

๐ŸŽฏ Core Game Engine

  • Complete Texas Hold'em rules implementation
  • Multi-player support (2-8 players)
  • Advanced betting system (check, call, raise, fold, all-in)
  • Buy-in and top-up support for cash games
  • Session tracking and profit analysis

๐Ÿค– AI Opponents (7 Unique Personalities)

Character Style VPIP Aggression Description
๐Ÿชจ Rock Tight-Aggressive 15% High Plays only premium hands
๐Ÿ˜ˆ Maniac Loose-Aggressive 55% Very High Bets constantly, never folds
๐Ÿ‘ฉ Anna Loose-Passive 40% Very Low Calls everything, never raises
๐ŸฆŠ Fox Balanced 45% Medium Hard to read, strategic play
๐Ÿฆˆ Shark Position-Play 45% High Exploits position, harvests fish
๐Ÿ‘ฉโ€๐Ÿซ Amy GTO-Math 50% Medium Mathematical optimal play
๐Ÿ˜ค David Tilt-Based Dynamic Dynamic Emotional player, can go on tilt

๐Ÿง  Advanced AI System

  • Monte Carlo simulation for win rate calculation
  • ICM (Independent Chip Model) for tournament play
  • Position-based strategy adjustment
  • Opponent modeling and profiling
  • Bluff frequency and timing optimization

๐Ÿ“Š Statistics & Tracking

  • Hands played
  • Win rate by position
  • VPIP/PFR tracking
  • Session history
  • Performance graphs
  • Cash game profit/loss tracking
  • Session duration and stats

๐Ÿ›  Technology Stack

Layer Technology
Language Swift 5.9+
UI Framework SwiftUI (iOS 15+)
State Management Combine + ObservableObject
Architecture MVVM + Finite State Machine
Persistence Core Data + UserDefaults
Testing XCTest

๐Ÿ“ Project Structure

TexasPoker/
โ”œโ”€โ”€ App/
โ”‚   โ””โ”€โ”€ TexasPokerApp.swift          # App entry point
โ”‚
โ”œโ”€โ”€ Core/
โ”‚   โ”œโ”€โ”€ AI/
โ”‚   โ”‚   โ”œโ”€โ”€ AIProfile.swift          # AI personality definitions
โ”‚   โ”‚   โ”œโ”€โ”€ DecisionEngine.swift      # AI decision making
โ”‚   โ”‚   โ”œโ”€โ”€ BluffDetector.swift      # Bluff probability
โ”‚   โ”‚   โ”œโ”€โ”€ ICMCalculator.swift      # Tournament equity
โ”‚   โ”‚   โ”œโ”€โ”€ MonteCarloSimulator.swift # Win rate calculation
โ”‚   โ”‚   โ”œโ”€โ”€ OpponentModeler.swift    # Player profiling
โ”‚   โ”‚   โ”œโ”€โ”€ RangeAnalyzer.swift      # Hand range analysis
โ”‚   โ”‚   โ””โ”€โ”€ DifficultyManager.swift   # AI difficulty levels
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ Data/
โ”‚   โ”‚   โ”œโ”€โ”€ PersistenceController.swift # Core Data stack
โ”‚   โ”‚   โ”œโ”€โ”€ StatisticsCalculator.swift  # Stats computation
โ”‚   โ”‚   โ”œโ”€โ”€ ProfileManager.swift        # Player profile management
โ”‚   โ”‚   โ”œโ”€โ”€ DataMigrationManager.swift # Schema migration
โ”‚   โ”‚   โ”œโ”€โ”€ ActionRecorder.swift       # Hand history
โ”‚   โ”‚   โ””โ”€โ”€ DataExporter.swift         # Export functionality
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ Engine/
โ”‚   โ”‚   โ”œโ”€โ”€ PokerEngine.swift            # Main game loop
โ”‚   โ”‚   โ”œโ”€โ”€ HandEvaluator.swift          # Hand strength evaluation
โ”‚   โ”‚   โ”œโ”€โ”€ BettingManager.swift         # Betting logic
โ”‚   โ”‚   โ”œโ”€โ”€ DealingManager.swift         # Card dealing
โ”‚   โ”‚   โ”œโ”€โ”€ ShowdownManager.swift        # Win determination
โ”‚   โ”‚   โ”œโ”€โ”€ TournamentManager.swift      # Tournament logic
โ”‚   โ”‚   โ”œโ”€โ”€ CashGameManager.swift        # Cash game logic
โ”‚   โ”‚   โ”œโ”€โ”€ GameResultsManager.swift     # Result calculation
โ”‚   โ”‚   โ””โ”€โ”€ TiltManager.swift            # Emotional state tracking
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ FSM/
โ”‚   โ”‚   โ”œโ”€โ”€ GameState.swift           # State definitions
โ”‚   โ”‚   โ”œโ”€โ”€ GameEvent.swift           # Game events
โ”‚   โ”‚   โ””โ”€โ”€ PokerGameStore.swift      # State machine
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ Models/
โ”‚   โ”‚   โ”œโ”€โ”€ Card.swift                # Card model
โ”‚   โ”‚   โ”œโ”€โ”€ Deck.swift               # Deck management
โ”‚   โ”‚   โ”œโ”€โ”€ Player.swift              # Base player
โ”‚   โ”‚   โ”œโ”€โ”€ HumanPlayer.swift         # Human player
โ”‚   โ”‚   โ”œโ”€โ”€ AIPlayer.swift            # AI player wrapper
โ”‚   โ”‚   โ”œโ”€โ”€ Pot.swift                 # Pot model
โ”‚   โ”‚   โ”œโ”€โ”€ ActionLogEntry.swift      # Action logging
โ”‚   โ”‚   โ”œโ”€โ”€ BlindLevel.swift          # Blind structure
โ”‚   โ”‚   โ”œโ”€โ”€ GameRecord.swift          # Game records
โ”‚   โ”‚   โ”œโ”€โ”€ GameSettings.swift        # Game settings
โ”‚   โ”‚   โ”œโ”€โ”€ GameMode.swift            # Game mode enum
โ”‚   โ”‚   โ”œโ”€โ”€ TournamentConfig.swift    # Tournament config
โ”‚   โ”‚   โ”œโ”€โ”€ CashGameConfig.swift      # Cash game config
โ”‚   โ”‚   โ”œโ”€โ”€ CashGameSession.swift      # Cash game session
โ”‚   โ”‚   โ””โ”€โ”€ more models...
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ Utils/
โ”‚       โ”œโ”€โ”€ ColorTheme.swift          # UI theming
โ”‚       โ”œโ”€โ”€ DeviceHelper.swift        # Device adaptation
โ”‚       โ””โ”€โ”€ Constants.swift           # App constants
โ”‚
โ”œโ”€โ”€ UI/
โ”‚   โ”œโ”€โ”€ Components/
โ”‚   โ”‚   โ”œโ”€โ”€ CardView.swift           # Card visualization
โ”‚   โ”‚   โ”œโ”€โ”€ ChipStackView.swift      # Chip stack display
โ”‚   โ”‚   โ”œโ”€โ”€ FlippingCard.swift       # Card flip animation
โ”‚   โ”‚   โ””โ”€โ”€ ActionButtons.swift      # Game actions
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ Views/
โ”‚       โ”œโ”€โ”€ GameTableView.swift      # Main table view
โ”‚       โ”œโ”€โ”€ PlayerView.swift         # Player info display
โ”‚       โ”œโ”€โ”€ ControlPanel.swift       # Player controls
โ”‚       โ”œโ”€โ”€ SettingsView.swift       # Settings screen
โ”‚       โ”œโ”€โ”€ StatisticsView.swift     # Stats dashboard
โ”‚       โ”œโ”€โ”€ RankingsView.swift       # Leaderboards
โ”‚       โ””โ”€โ”€ GameSubviews/           # Sub-components
โ”‚           โ”œโ”€โ”€ GameTopBar.swift
โ”‚           โ”œโ”€โ”€ GamePotDisplay.swift
โ”‚           โ”œโ”€โ”€ GameHeroControls.swift
โ”‚           โ”œโ”€โ”€ GameActionLogPanel.swift
โ”‚           โ”œโ”€โ”€ GameTournamentInfo.swift
โ”‚           โ”œโ”€โ”€ BuyInView.swift
โ”‚           โ”œโ”€โ”€ TopUpView.swift
โ”‚           โ”œโ”€โ”€ LeaveTableButton.swift
โ”‚           โ””โ”€โ”€ CashSessionSummaryView.swift
โ”‚
โ”œโ”€โ”€ Resources/
โ”‚   โ”œโ”€โ”€ Assets.xcassets
โ”‚   โ”œโ”€โ”€ Sounds/
โ”‚   โ””โ”€โ”€ Data/
โ”‚
โ””โ”€โ”€ TexasPokerTests/
    โ”œโ”€โ”€ Core/
    โ”‚   โ””โ”€โ”€ Engine/
    โ”‚       โ”œโ”€โ”€ HandEvaluatorTests.swift
    โ”‚       โ””โ”€โ”€ PokerEngineTests.swift
    โ”œโ”€โ”€ UI/
    โ”‚   โ”œโ”€โ”€ ColorThemeTests.swift
    โ”‚   โ””โ”€โ”€ GameViewLayoutTests.swift
    โ”œโ”€โ”€ CashGameConfigTests.swift
    โ”œโ”€โ”€ CashGameManagerTests.swift
    โ”œโ”€โ”€ CashGameSessionTests.swift
    โ””โ”€โ”€ UncalledBetTests.swift

๐Ÿš€ Getting Started

Prerequisites

  • macOS 14+ or macOS 15+ (Apple Silicon recommended)
  • Xcode 15+
  • iOS 15.0+ Simulator or Device

Installation

# Clone the repository
git clone https://github.com/yourusername/ios-poker-game.git
cd ios-poker-game

# Open in Xcode
open TexasPoker.xcodeproj

# Select a simulator and run (Cmd+R)

Building from Command Line

xcodebuild -project TexasPoker.xcodeproj \
           -scheme TexasPoker \
           -destination 'platform=iOS Simulator,name=iPhone 15' \
           -configuration Debug \
           build

๐Ÿ“– Usage

Starting a Game

  1. Launch the app
  2. Select game mode (Cash Game / Tournament)
  3. Choose opponents (1-7 AI players)
  4. Set buy-in amount
  5. Press "Deal" to start

Game Controls

  • Check: Available when no bet pending
  • Call: Match the current bet
  • Raise: Increase the bet
  • Fold: Surrender the hand
  • All-In: Commit all chips

AI Customization

Each AI opponent can be customized:

  • Personality profile
  • Starting stack
  • Difficulty level
  • Avatar selection

๐Ÿงช Testing

# Run all tests
xcodebuild test -project TexasPoker.xcodeproj \
                -scheme TexasPoker \
                -destination 'platform=iOS Simulator,name=iPhone 15'

# Run specific test class
xcodebuild test -project TexasPoker.xcodeproj \
                -scheme TexasPoker \
                -destination 'platform=iOS Simulator,name=iPhone 15' \
                -only-testing:TexasPokerTests/Core/Engine/HandEvaluatorTests

๐Ÿ“ˆ Architecture

State Machine

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Game States                           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  idle โ†’ preFlop โ†’ flop โ†’ turn โ†’ river โ†’ showdown       โ”‚
โ”‚    โ†‘                                                    โ”‚
โ”‚    โ””โ”€โ”€โ”€loop (new hand)                                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Decision Flow

Player Action
    โ†“
Game Context (pot, position, hand strength)
    โ†“
AI Decision Engine
    โ”œโ”€โ”€ Check hand strength (Monte Carlo)
    โ”œโ”€โ”€ Calculate pot odds
    โ”œโ”€โ”€ Apply personality adjustments
    โ””โ”€โ”€ Select action (weighted random)
    โ†“
Execute Action

๐ŸŽจ Screenshots

Game Table Player View Statistics

Screenshots coming soon - replace with actual game screenshots


๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • SwiftUI - Apple's modern UI framework
  • Combine - Reactive programming framework
  • XCTest - Testing framework

Made with โค๏ธ by the Poker AI Team

About

iOS Texas Hold'em Poker Game

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages