Literature card game implementation
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
literature-1.0.0.tar.gz
(21.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file literature-1.0.0.tar.gz.
File metadata
- Download URL: literature-1.0.0.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80cde9e921fc4ff9758e5fedebf53569dad454e8b677fc5de50a9f20efd0234e
|
|
| MD5 |
064dbbfce0682298234903f4f7259024
|
|
| BLAKE2b-256 |
987ed50c56114e49681f91f8eca478d11d29ddd4e176796f46c7835980c2a570
|
File details
Details for the file literature-1.0.0-py3-none-any.whl.
File metadata
- Download URL: literature-1.0.0-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed52b4f04a330c15b6bda05233ccb3500009fd49b9ab609c371d12ee66270f89
|
|
| MD5 |
d796123c48313d7b63567b00dc55bc94
|
|
| BLAKE2b-256 |
06d0136d93df3bf7b29dc61f995b193539f2caa0f4e1ceb81900592f1d4701fa
|