项目作者: neelsomani

项目描述 :
Literature card game implementation: https://en.wikipedia.org/wiki/Literature_(card_game)
高级语言: Python
项目地址: git://github.com/neelsomani/literature.git
创建时间: 2019-06-10T05:37:38Z
项目社区:https://github.com/neelsomani/literature

开源协议:MIT License

下载


Literature

Travis CI

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:

  1. >>> from literature import get_game, Card, Suit
  2. >>> import logging
  3. >>> logging.basicConfig(level=logging.INFO)
  4. >>> l = get_game(4)
  5. >>> l.turn
  6. Player 3
  7. >>> l.players[3].hand_to_dict()
  8. Suit.CLUBS: [A of C, K of C]
  9. Suit.DIAMONDS: [2 of D, 10 of D, J of D, Q of D, K of D]
  10. Suit.HEARTS: [A of H, 5 of H, J of H]
  11. Suit.SPADES: [A of S, Q of S]
  12. >>> move = l.players[3].asks(l.players[2]).to_give(Card.Name(3, Suit.DIAMONDS))
  13. >>> l.commit_move(move)
  14. INFO:literature.literature:Failure: Player 3 requested the 3 of D from Player 2

Play against a model that I trained with:

  1. >>> import literature
  2. >>> import logging
  3. >>> logging.basicConfig(level=logging.INFO)
  4. >>> literature.learning.play_against_model('literature/model_10000.out')

See literature.py for documentation.

Limitations

  • 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.
  • 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.
    • 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.