Skip to main content

Tilted is a lightweight, open-source Python package with a simple interface for poker hand evaluation & comparison.

Project description

Tilted

Tilted is a lightweight, open-source Python package with a simple interface for poker hand evaluation & comparison.



Installation

With Poetry:

poetry add tilted

With Pip:

pip install tilted

Basic Usage

Tilted can be used to generate, evaluate and compare 5-card poker hands.

Hand Generation

To generate a random hand:

from tilted import Deck, Hand


deck = Deck()
unknown_hand = Hand(deck.draw_many(5))

unknown_hand  # <Hand: 8♦ T♠ T♣ Q♣ K♥>
unknown_hand.hand_rank  # <HandRank.PAIR: 2>

Hand Evaluation

To evaluate an unknown hand:

from tilted import Card, CardRank, CardSuit, Hand


unknown_hand = Hand([
  Card(CardRank.TEN, CardSuit.SPADES),
  Card(CardRank.JACK, CardSuit.SPADES),
  Card(CardRank.QUEEN, CardSuit.SPADES),
  Card(CardRank.KING, CardSuit.SPADES),
  Card(CardRank.ACE, CardSuit.SPADES),
])

unknown_hand.hand_rank  # <HandRank.ROYAL_FLUSH: 10>

Hand Comparison

To compare two hands:

from tilted import Card, CardRank, CardSuit, Hand


royal_flush = Hand([
  Card(CardRank.TEN, CardSuit.SPADES),
  Card(CardRank.JACK, CardSuit.SPADES),
  Card(CardRank.QUEEN, CardSuit.SPADES),
  Card(CardRank.KING, CardSuit.SPADES),
  Card(CardRank.ACE, CardSuit.SPADES),
])

straight_flush = Hand([
  Card(CardRank.NINE, CardSuit.HEARTS),
  Card(CardRank.TEN, CardSuit.HEARTS),
  Card(CardRank.JACK, CardSuit.HEARTS),
  Card(CardRank.QUEEN, CardSuit.HEARTS),
  Card(CardRank.KING, CardSuit.HEARTS),
])

royal_flush > straight_flush  # True

Game & Dealing

To create a game, deal cards to the board and determine the winning player:

from tilted import Game


num_players = 2
game = Game(num_players)

game.deal_next_street()
game.board.flop  # [A♦, A♠, A♣]

game.deal_next_street()
game.board.turn  # K♣

game.deal_next_street()
game.board.river  # Q♣

game.board.cards  # [A♦, A♠, A♣, K♣, Q♣]

game.players[0].name  # "Player #1"
game.players[0].hole_cards  # [A♥, K♥]
game.players[1].name  # "Player #2"
game.players[1].hole_cards  # [T♦, Q♦]

game.get_winner()  # [<Player: Player #1>]

NOTE: get_winner returns a list to account for split pots (when two players have the winning hand).

Roadmap

Features

  • Hand evaluation
  • Hand comparison
  • Deck support
  • Board & dealing (Flop, Turn, River)
  • Player support
  • Full board & hole card evaluation
  • Buttons & betting
  • Game state serialization
  • Simulations API and/or simulation examples

Deployment

  • CI
  • Badges

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tilted-0.1.4.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tilted-0.1.4-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file tilted-0.1.4.tar.gz.

File metadata

  • Download URL: tilted-0.1.4.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.4 Darwin/19.6.0

File hashes

Hashes for tilted-0.1.4.tar.gz
Algorithm Hash digest
SHA256 509f0abdded44d5c52b13bd6778ec4898660f53e221d76cebadbc10cd5ad39ec
MD5 ad4d2e5859d7230e2fc3d999ce3bc16d
BLAKE2b-256 846d08935b86b6749cdf89498b28264fa52b85adde6932633475617f423e836e

See more details on using hashes here.

File details

Details for the file tilted-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: tilted-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.4 Darwin/19.6.0

File hashes

Hashes for tilted-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 deecb972dec46d4941e52db081dd1815fd11efdf8d4a4f74a2195fcd3846a9ff
MD5 87aac218119dd5836673340d9304f2c1
BLAKE2b-256 d7dc97fd4a82c483233c9bf73f0449ddda7f3272c29d03d0b8c84572bddbc732

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page