gamble

🎲 A python library with various gambling and gaming classes

Popularity
1.1
Declining
Activity
5.7
Growing
23
1
9

Description

gamble is a simple library that implements a collection of some common gambling-related classes Features

die, dice, d-notation cards, decks, hands poker ranks, hand comparison

Programming language: Python
License: MIT License
Latest version: v0.8

gamble alternatives and similar packages

Based on the "Miscellaneous" category.
Alternatively, view gamble alternatives based on common mentions on social networks and blogs.

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.

Do you think we are missing an alternative of gamble or a related project?

Add another 'Miscellaneous' Package

README

image PyPI version Code style: black Python 3.6+ supported Documentation style: archives

gamble is a simple library that implements a collection of some common gambling-related classes

Features

  • die, dice, d-notation
  • cards, decks, hands
  • poker ranks, hand comparison

Usage

Installation

pip install gamble

Basic Usage

Dice

import gamble
# create dice, defaults to 2 6-sided dice
dice = gamble.Dice()
# roll
dice.roll()
>>> 6
dice.rolls
>>> 1
# max, min
dice.max
>>> 12
dice.min
>>> 2
# d-notation for dice constructor
dice = gamble.Dice('d20+8')
# max, min
dice.max
>>> 28
dice.min
>>> 9
# parts
dice.parts
>>> [<d20 Die>, 8]
# roll_many
dice.roll_many(2)
>>> [8, 4]
# max_of, min_of
dice.max_of(3)
>>> (11, [7, 3, 11])
dice.min_of(3)
>>> (2, [2, 9, 4])

Cards

import gamble
# create a deck, defaults to the standard 52 card deck, no jokers
# the deck will be shuffled by default, unless you pass shuffle=False
deck = gamble.Deck()
deck.cards_left
>>> 52
deck.top
>>> <Card:7β™ >
deck.bottom
>>> <Card:9β™ >
deck.shuffle() # you can also pass times=(int) to shuffle more than once
card = deck.draw() # you can also pass times=(int) to draw a list of cards
>>> <Card:Aβ™ >
# the unicode cards icons are implemented as well!
card.unicode
>>> "πŸ‚‘"
# draw a poker hand, default size 5
hand = deck.draw_hand(). # you can pass size=(int) to draw a different size hand
>>> <Hand[5](straight flush) [Aβ™ , 2β™ , 3β™ , 4β™ , 5β™ ]>
hand.rank
>>> Rank(name='straight flush', value=8)
# arbitrary hand, from text notation
new_hand = gamble.Hand.get("2c,3c,4c,Kc,Kh")
>>> <Hand[5](pair) [2♣, 3♣, 4♣, K♣, Kβ™₯]>
new_hand.rank
>>> Rank(name='pair', value=1)
hand > new_hand
>>> True

Todo

  • hand equals/ge/le method
  • hand ranking when hands are very similar

Do not miss the trending, packages, news and articles with our weekly report.

Awesome Python is part of the LibHunt network. Terms. Privacy Policy.

(CC)
BY-SA
We recommend Spin The Wheel Of Names for a cryptographically secure random name picker.

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /