Skip to main content

A Python Package for Card Games and Machine Learning

Project description

Toulouse: A Python Package for Card Games and Machine Learning 🃏

Toulouse is a Python package designed for creating and manipulating standard playing cards and decks, with a focus on applications in machine learning. It offers a simple yet powerful interface for card game simulation and analysis, providing binary representations of cards suitable for machine learning models.

Installation

Toulouse can be installed easily via pip. Open your terminal and run the following command:

pip install toulouse

Ensure you have Python 3.8 or higher installed on your system to use Toulouse.

Classes

Card

The Card class represents a single playing card.

Inputs:

  • value (int): The value of the card (1-13, where 1 is Ace, 11 is Jack, 12 is Queen, and 13 is King in a case of 52 deck size).
  • suit (int): The suit of the card (0-3, representing Spades ♠️, Hearts ♥️, Diamonds ♦️, and Clubs ♣️, respectively).
  • deck_size (int, optional): The size of the deck, default is 52.
  • language (str, optional): The language for card representation, default is 'en' (English).

You can choose between 'en' 🇬🇧, 'fr' 🇫🇷, 'it' 🇮🇹, 'es' 🇪🇸 and 'de' 🇩🇪

Deck

The Deck class represents a collection of Card objects.

Inputs:

  • cards (List[Card], optional): A list of Card objects to initialize the deck. Default is None, which initializes a standard deck.
  • new (bool, optional): If True, creates a new standard deck. Default is False.
  • sort_type (str, optional): Determines how the deck is sorted or shuffled ('sort' for sorted, 'shuffle' for shuffled). Default is 'sort'.
  • deck_size (int, optional): The size of the deck, affects card distribution if new is True. Default is 52.
  • language (str, optional): The language for card representations within the deck. Default is 'en'.

Use Cases

Manipulating Cards and Decks

  • Creating a New Deck: deck = Deck(new=True)
  • Drawing Cards from the Deck: drawn_cards = deck.draw(5)
  • Adding a Card to the Deck: deck.append(Card(1, 0)) (Adds an Ace of Spades)
  • Removing a Card from the Deck: deck.remove(some_card)
  • Shuffling the Deck: Set deck.sort_type = 'shuffle' then deck.update_sort()

Machine Learning Use Case

For machine learning applications, especially in game simulation and strategy analysis, the binary representation of cards can be utilized as features for models.

Binary Representation:

Each card can be represented as a binary vector where only one element is set to 1, and the rest are 0. This one-hot encoding allows the model to easily process card information.

card = Card(1, 0)  # Ace of Spades
binary_representation = card.state

This representation can be used as input for neural networks, decision trees, or any other machine learning model to analyze card games or simulate strategies.

Example: Training a Model

Imagine you're building a model to predict the outcome of a card game. You could use the binary representations of drawn cards as features:

features = np.array([card.state for card in drawn_cards])
# Assume labels are the outcomes you want to predict
model.fit(features, labels)

This simplistic example shows how you might begin to incorporate card data into a machine learning model. For more complex games or analysis, you might combine features from multiple cards, include game state information, or use embeddings.


This README provides a basic overview of the Toulouse package, its installation, class inputs, and use cases.

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

toulouse-0.0.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

toulouse-0.0.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file toulouse-0.0.1.tar.gz.

File metadata

  • Download URL: toulouse-0.0.1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for toulouse-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4a6dc754b7f28a98da25c7f316913d53e12c0b656197d7f00df1c06da70ba37a
MD5 caed4a4464bb1b6107b328eed4f7f736
BLAKE2b-256 9eb0b0fa91f0fa4f413139086acc809da5c95ee084b3e24ba0927e6b29cbfdfc

See more details on using hashes here.

File details

Details for the file toulouse-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: toulouse-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for toulouse-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e3fa911c1b4811e87e07799a251b1a59600b60ea0368b84d35904914e012746d
MD5 6169fa2521c36a0eaab40ff7f604512d
BLAKE2b-256 f618c712b4335ac4092d0b6e1c11b1f82a7da4280d7d9446373b552464278080

See more details on using hashes here.

Supported by

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