connect-four-game


Nameconnect-four-game JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/will-flemmer/connect-4
SummaryExample PyPI (Python Package Index) Package
upload_time2023-07-14 15:40:00
maintainer
docs_urlNone
authorWill Flemmer
requires_python>=3.6
license
keywords connect_four_game pypi package
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ### Installation

```
pip install connect-four-game
```

## Usage

### Human vs Human
```python
from connect_four_game import Game, Agent

if __name__ == '__main__':
  red_agent = Agent('RED TEAM', 'red')
  blue_agent = Agent('BLUE TEAM', 'blue')
  lcm = Game(red_agent, blue_agent)
  lcm.start_game()
```

### AI vs AI
```python
from connect_four_game import Game

COLUMN_COUNT = 12 # normally 7
ROW_COUNT = 9 # normally 6

if __name__ == '__main__':
  red_rl_agent = RLAgent('red') # RLAgent is not included in the package
  blue_rl_agent = RLAgent('blue')
  game = Game(red_rl_agent, blue_rl_agent, row_count=ROW_COUNT, column_count=COLUMN_COUNT)
  game.start_game()
```

#### Example of an RL Agent which randomly chooses columns

```python
import random
from connect_four_game import BaseAgent
import numpy as np

class RLAgent(BaseAgent):
  def __init__(self, color: str, initial_exploration_rate=0.9):
    self.name = f'RL-Agent-{color.capitalize()}'
    self.color = color
    self.symbol = color[0].capitalize()

  def choose_action(self):
    return random.randint(0, len(self.game.grid[0]) - 1)

  def place_block(self):
    column = self.choose_action()
    return self.board.place_block(column, self.symbol)

  def post_evaluation_hook(self):
    print('This method is called after each move has been evaluated')
```

### Human vs AI
On the way...



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/will-flemmer/connect-4",
    "name": "connect-four-game",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "connect_four_game,pypi,package",
    "author": "Will Flemmer",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/cc/ad/cbb4417b8620bd683d76d5933eee21b1a71b4b7843d26c050aa520e9c1cb/connect_four_game-0.1.6.tar.gz",
    "platform": null,
    "description": "### Installation\n\n```\npip install connect-four-game\n```\n\n## Usage\n\n### Human vs Human\n```python\nfrom connect_four_game import Game, Agent\n\nif __name__ == '__main__':\n  red_agent = Agent('RED TEAM', 'red')\n  blue_agent = Agent('BLUE TEAM', 'blue')\n  lcm = Game(red_agent, blue_agent)\n  lcm.start_game()\n```\n\n### AI vs AI\n```python\nfrom connect_four_game import Game\n\nCOLUMN_COUNT = 12 # normally 7\nROW_COUNT = 9 # normally 6\n\nif __name__ == '__main__':\n  red_rl_agent = RLAgent('red') # RLAgent is not included in the package\n  blue_rl_agent = RLAgent('blue')\n  game = Game(red_rl_agent, blue_rl_agent, row_count=ROW_COUNT, column_count=COLUMN_COUNT)\n  game.start_game()\n```\n\n#### Example of an RL Agent which randomly chooses columns\n\n```python\nimport random\nfrom connect_four_game import BaseAgent\nimport numpy as np\n\nclass RLAgent(BaseAgent):\n  def __init__(self, color: str, initial_exploration_rate=0.9):\n    self.name = f'RL-Agent-{color.capitalize()}'\n    self.color = color\n    self.symbol = color[0].capitalize()\n\n  def choose_action(self):\n    return random.randint(0, len(self.game.grid[0]) - 1)\n\n  def place_block(self):\n    column = self.choose_action()\n    return self.board.place_block(column, self.symbol)\n\n  def post_evaluation_hook(self):\n    print('This method is called after each move has been evaluated')\n```\n\n### Human vs AI\nOn the way...\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Example PyPI (Python Package Index) Package",
    "version": "0.1.6",
    "project_urls": {
        "Bug Reports": "https://github.com/will-flemmer/connect-4/issues",
        "Documentation": "https://github.com/will-flemmer/connect-4",
        "Homepage": "https://github.com/will-flemmer/connect-4",
        "Source Code": "https://github.com/will-flemmer/connect-4"
    },
    "split_keywords": [
        "connect_four_game",
        "pypi",
        "package"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "39a67c34d9afab25ed1e09d8b3e99edb5f528b36a00e32a596e734dd401810f7",
                "md5": "52c7c44c41a6ec053d37dc16f30e4531",
                "sha256": "53fee8ce16fc3d3336dab1479c9c0ff437f53ec95e10f1c2436fb4ab0b411ee1"
            },
            "downloads": -1,
            "filename": "connect_four_game-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "52c7c44c41a6ec053d37dc16f30e4531",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 9993,
            "upload_time": "2023-07-14T15:39:59",
            "upload_time_iso_8601": "2023-07-14T15:39:59.470872Z",
            "url": "https://files.pythonhosted.org/packages/39/a6/7c34d9afab25ed1e09d8b3e99edb5f528b36a00e32a596e734dd401810f7/connect_four_game-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ccadcbb4417b8620bd683d76d5933eee21b1a71b4b7843d26c050aa520e9c1cb",
                "md5": "90a0ee80ef25c567674c5e53153c959e",
                "sha256": "18ace31b0f6b39083ec56d8ad2862c6a6a7b82b90fb1cd439998772d9997bf5d"
            },
            "downloads": -1,
            "filename": "connect_four_game-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "90a0ee80ef25c567674c5e53153c959e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6902,
            "upload_time": "2023-07-14T15:40:00",
            "upload_time_iso_8601": "2023-07-14T15:40:00.894943Z",
            "url": "https://files.pythonhosted.org/packages/cc/ad/cbb4417b8620bd683d76d5933eee21b1a71b4b7843d26c050aa520e9c1cb/connect_four_game-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-14 15:40:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "will-flemmer",
    "github_project": "connect-4",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "connect-four-game"
}
        
Elapsed time: 0.12278s