{"id":27202497,"url":"https://github.com/neelsomani/literature","last_synced_at":"2025-04-09T22:00:11.759Z","repository":{"id":40963857,"uuid":"191103528","full_name":"neelsomani/literature","owner":"neelsomani","description":"Literature card game implementation: https://en.wikipedia.org/wiki/Literature_(card_game)","archived":false,"fork":false,"pushed_at":"2024-06-17T23:09:41.000Z","size":15579,"stargazers_count":10,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-08T04:36:24.054Z","etag":null,"topics":["artificial-intelligence","card-game","machine-learning","neural-network","q-learning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neelsomani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-10T05:37:38.000Z","updated_at":"2025-02-13T07:44:25.000Z","dependencies_parsed_at":"2022-08-27T02:57:58.235Z","dependency_job_id":null,"html_url":"https://github.com/neelsomani/literature","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neelsomani%2Fliterature","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neelsomani%2Fliterature/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neelsomani%2Fliterature/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neelsomani%2Fliterature/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neelsomani","download_url":"https://codeload.github.com/neelsomani/literature/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247856541,"owners_count":21007620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","card-game","machine-learning","neural-network","q-learning"],"created_at":"2025-04-09T22:00:10.911Z","updated_at":"2025-04-09T22:00:11.743Z","avatar_url":"https://github.com/neelsomani.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Literature\n![Travis CI](https://travis-ci.org/neelsomani/literature.svg?branch=master)\n\nLiterature card game implementation: https://en.wikipedia.org/wiki/Literature_(card_game)\n\n## Setup\n\nInstall with `pip install literature`. Built for Python 3.6.0.\n\nExample gameplay:\n\n```\n\u003e\u003e\u003e from literature import get_game, Card, Suit\n\u003e\u003e\u003e import logging\n\u003e\u003e\u003e logging.basicConfig(level=logging.INFO)\n\u003e\u003e\u003e l = get_game(4)\n\u003e\u003e\u003e l.turn\nPlayer 3\n\u003e\u003e\u003e l.players[3].hand_to_dict()\nSuit.CLUBS: [A of C, K of C]\nSuit.DIAMONDS: [2 of D, 10 of D, J of D, Q of D, K of D]\nSuit.HEARTS: [A of H, 5 of H, J of H]\nSuit.SPADES: [A of S, Q of S]\n\u003e\u003e\u003e move = l.players[3].asks(l.players[2]).to_give(Card.Name(3, Suit.DIAMONDS))\n\u003e\u003e\u003e l.commit_move(move)\nINFO:literature.literature:Failure: Player 3 requested the 3 of D from Player 2\n```\n\nPlay against a model that I trained with:\n\n```\n\u003e\u003e\u003e import literature\n\u003e\u003e\u003e import logging\n\u003e\u003e\u003e logging.basicConfig(level=logging.INFO)\n\u003e\u003e\u003e literature.learning.play_against_model('literature/model_10000.out')\n```\n\nSee `literature.py` for documentation.\n\n## Limitations\n\n* The bots only consider asking for a `Card` that they know a `Player` does not possess in the case that there are no other possible `Moves`. I made this simplification because the initial training took too long otherwise.\n* The game state for a given `Player` encodes what that `Player` knows that all other `Players` know about each other's hands, but I don't encode any levels further than that. For example, the game state for `Player i` doesn't encode what `Player j` knows that `Player k` knows that `Player l` knows.\n  * 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.\n* 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.\n* 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_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneelsomani%2Fliterature","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneelsomani%2Fliterature","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneelsomani%2Fliterature/lists"}