semvec/pypi-packages huggingface dataset:
gameservice 3.0.1
A package for various game implementations on python
Requires Python: >=3.7

GameService
===========

GameService provides a general framework for board games and implements Tic Tac Toe and No Limit Texas Hold'em Poker
games.


Installation
------------

```bash
pip install gameservice
```

Implementation Notes
--------------------

GameService currently implements No Limit Texas Hold'em and Tic Tac Toe games. As it stands right now, you can run ~5000
tic tac toe games per second, and ~100 games per second of 9-Max NLHE with maximum of 20 bet sizes if players take
random actions.

Note that, in poker games, the vast majority of the actions will be raises (you can see why if you play around with the
library). But, in real life, the percentages of calls, checks, folds, and all-ins will be disproportionally large.
Therefore, the real life performance of this library is expected to be larger.


Creating No Limit Texas Hold'em Games
-------------------------------------

To create NLHE games, you first have to define the game parameters, as seen below:

```python
from gameservice.poker import NLHEGame


class TestGame(NLHEGame):
    @property
    def starting_stacks(self):
        return [200, 400, 300]  # Starting stacks also describe the number of players

    @property
    def blinds(self):
        return [1, 2]  # Small blind and big blind.

    @property
    def ante(self):
        return 0  # Ante


game = TestGame()  # Create a game
```

Creating Tic Tac Toe Games
--------------------------

Tic Tac Toe games are more straight-forward to create.

```python
from gameservice.tictactoe import TTTGame

game = TTTGame()
```

Interacting with Games
----------------------

TicTacToeGame and NLHEGame are subclasses of SeqGame (Sequential Game). The way you interact with instances of
sequential games are the same.

```python
import json

from gameservice.tictactoe import TTTGame

game = TTTGame()

while not game.terminal:
    print(json.dumps(game.player.info_set.serialize(), indent=4))

    actions = game.player.actions

    for action in actions:
        print(action)

    actions[0 if len(actions) == 1 else int(input('Action index: '))].act()

print(json.dumps((game.players[0] if game.nature is None else game.nature).info_set.serialize(), indent=4))
```

Infoset has a serialize method that converts all known info of player to be stored inside a dictionary. Please try out
different games to see the infoset.

License
-------
[MIT](https://choosealicense.com/licenses/mit/)