Literature
Literature card game implementation: https://en.wikipedia.org/wiki/Literature_(card_game)
Setup
Install with pip install literature. Built for Python 3.6.0.
Example gameplay:
>>> from literature import get_game, Card, Suit
>>> import logging
>>> logging.basicConfig(level=logging.INFO)
>>> l = get_game(4)
>>> l.turn
Player 3
>>> l.players[3].hand_to_dict()
Suit.CLUBS: [A of C, K of C]
Suit.DIAMONDS: [2 of D, 10 of D, J of D, Q of D, K of D]
Suit.HEARTS: [A of H, 5 of H, J of H]
Suit.SPADES: [A of S, Q of S]
>>> move = l.players[3].asks(l.players[2]).to_give(Card.Name(3, Suit.DIAMONDS))
>>> l.commit_move(move)
INFO:literature.literature:Failure: Player 3 requested the 3 of D from Player 2
Play against a model that I trained with:
>>> import literature
>>> import logging
>>> logging.basicConfig(level=logging.INFO)
>>> literature.learning.play_against_model('literature/model_10000.out')
See literature.py for documentation.
Limitations
- The bots only consider asking for a
Cardthat they know aPlayerdoes not possess in the case that there are no other possibleMoves. I made this simplification because the initial training took too long otherwise. - The game state for a given
Playerencodes what thatPlayerknows that all otherPlayersknow about each other's hands, but I don't encode any levels further than that. For example, the game state forPlayer idoesn't encode whatPlayer jknows thatPlayer kknows thatPlayer lknows.- I chose not to represent this because it vastly increases the dimensionality of the problem, and I don't think that the information is particularly valuable.
- During training, the bots will occasionally get caught in an infinite loop. To mitigate this, I add noise to the scores for each move and kill games after 200 moves.
- I'm only training the bots for games of four right now. The code can be easily adapted to work for a different number of players.
Metadata
Release files for literature 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| literature-1.0.0.tar.gz | 21.5 kB | Without provenance | Details for literature-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| literature-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for literature-1.0.0-py3-none-any.whl |
Total release size: 46.3 kB
Release files / literature-1.0.0.tar.gz
| Download URL | literature-1.0.0.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80cde9e921fc4ff9758e5fedebf53569dad454e8b677fc5de50a9f20efd0234e
|
|
BLAKE2b-256 checksum How to use checksums |
987ed50c56114e49681f91f8eca478d11d29ddd4e176796f46c7835980c2a570
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / literature-1.0.0-py3-none-any.whl
| Download URL | literature-1.0.0-py3-none-any.whl |
|---|---|
| Size | 24.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed52b4f04a330c15b6bda05233ccb3500009fd49b9ab609c371d12ee66270f89
|
|
BLAKE2b-256 checksum How to use checksums |
06d0136d93df3bf7b29dc61f995b193539f2caa0f4e1ceb81900592f1d4701fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for literature 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.