Skip to main content

Playing cards in numpy decks.

Project description

numpyDealer version 1.0.0

This package is designed to be used to speed up operations involving decks of playing cards by utilizing the popular Numpy package.
The meat of the package is numpyDeck. This is a managed array of playing cards, starting at the standard 52.
Below I will go through the functions of the Card object, then the Deck object (which holds a numpy array of Cards).

Additionally, I intend to add more examples, documentation, and features soon, so please feel free to send feedback!
Finally, the license MIT. I would love to see what the world does with my stuff, but y'all do what you want with it.
Thanks for downloading, have fun!

Note: I use Jokers as sentry values in Deck functions.

Card
To import:
from numpyDealer.Card import Card

__init__(rank (string), suit (string), value (int))
EX: ace_of_spades = Card("A","S",14)

The == operator comapares based on rank and suit.

The > and < operators compares based on value.

The - operator returns the distance between 2 cards.
EX: King of Hearts - Ten of Clubs = 13

__str__ calls the Card as a string, and returns the Rank and Suit
EX: ace_of_spades.__str__() returns "AS"


numpyDeck
to import:
from numpyDealer.numpyDeck import Deck


__init__()
EX: new_deck = Deck()
This creates a full deck, in order
All Ranks are 1 character strings, 2,3..., 9,T,J,Q,K,A.
All Suits are 1 character strings, S,H,C,D

__iter__() returns an iterable version, lets you use for loops.

deal() returns the top Card from the deck, and removes it.

dealByRankSuit(rank, suit) deals the specified card, if it is in the deck.
else returns a red joker. (Card("Joker ", "Red", -1))

dealRand() deals a random card.

+ and - operators are overloaded, do what you'd think.
They CAN take iterable objects of Cards, or just single Cards

Note on the print functions: These are available, but you can use a for loop to print each element.
print() prints a list of the cards in the deck, in the order they are in.

printBySuit() prints all the cards in the deck in 4 rows, 1 for each suit.
THIS DOES NOT SORT THE DECK, ONLY PRINTS THEM IN THE ROWS
THIS DOES NOT PRINT JOKERS, USE THE OTHER PRINTS TO FIND THOSE

shuffle() Shuffles the deck. DOES NOT return a value.

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

numpyDealer-1.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

numpyDealer-1.0.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file numpyDealer-1.0.2.tar.gz.

File metadata

  • Download URL: numpyDealer-1.0.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for numpyDealer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 21f9e7b0e7a0d7330af27a962d4d5b1edb16cedbb55ddd317c8dfb937e215a9a
MD5 3fb6261625a9e1b3ad22b13f34c08317
BLAKE2b-256 9704d5d2c57166b1635281a5c84e35b2cc18946c49fdbe0d378e96b5d25fc028

See more details on using hashes here.

File details

Details for the file numpyDealer-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: numpyDealer-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for numpyDealer-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1d1a75c3e676684489efc13e9e60b51cc1406ff33305bad48df29f99a45935c7
MD5 e8400b881c295226319611050072844b
BLAKE2b-256 28b64d91c54824ae6d5eabe62319a99b26e909ad9c450b03ae909bfd6fd925b0

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