Installation
pip install connect-four-game
Usage
Human vs Human
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
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
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...
Release files for connect-four-game 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| connect_four_game-0.1.6.tar.gz | 6.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| connect_four_game-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.9 kB
Release files / connect_four_game-0.1.6.tar.gz
| Download URL | connect_four_game-0.1.6.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18ace31b0f6b39083ec56d8ad2862c6a6a7b82b90fb1cd439998772d9997bf5d
|
|
BLAKE2b-256 checksum How to use checksums |
ccadcbb4417b8620bd683d76d5933eee21b1a71b4b7843d26c050aa520e9c1cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.17
|
Release files / connect_four_game-0.1.6-py3-none-any.whl
| Download URL | connect_four_game-0.1.6-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53fee8ce16fc3d3336dab1479c9c0ff437f53ec95e10f1c2436fb4ab0b411ee1
|
|
BLAKE2b-256 checksum How to use checksums |
39a67c34d9afab25ed1e09d8b3e99edb5f528b36a00e32a596e734dd401810f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.17
|