Play connect 4 in your terminal or online with your friends
Project description
py-connect-4
This is a simple Python script to play connect 4.
Uses rich to represent the board!
Play locally OR online with your friends.
Installation
- With uv (recommended)
❯ uv tool install py-connect-4
❯ py-connect-4 --help
Or simply run it via uvx
❯ uvx py-connect-4 --help
- With pip
❯ pip install py-connect-4
❯ py-connect-4 --help
Usage
Locally
❯ uvx py-connect-4 local
❯ # or after installation via pip
❯ py-connect-4 local
Then play in turns in 1 shell prompt.
Online
One of you needs to spawn 2 processes to HOST and also JOIN the game:
Host:
❯ uvx py-connect-4 online host
❯ # or after installation via pip
❯ py-connect-4 online host
Client:
❯ uvx connect-4 online join
❯ # or after installation via pip
❯ py-connect-4 online join
You'll be prompted to enter the HOST IP or fall back to "0.0.0.0"
Game example
This is an example for a local game
❯ uvx py-connect-4 local
┏━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━╇━━━╇━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼───┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼───┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼───┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼───┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼───┤
│ │ │ │ │ │ │ │
└───┴───┴───┴───┴───┴───┴───┘
Player 🟠. Col: 6
┏━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━╇━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼────┤
│ │ │ │ │ │ │ 🟠 │
└───┴───┴───┴───┴───┴───┴────┘
Player 🔵. Col: 6
┏━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━╇━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼───┼────┤
│ │ │ │ │ │ │ 🔵 │
├───┼───┼───┼───┼───┼───┼────┤
│ │ │ │ │ │ │ 🟠 │
└───┴───┴───┴───┴───┴───┴────┘
Player 🟠. Col: 5
┏━━━┳━━━┳━━━┳━━━┳━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼───┼────┼────┤
│ │ │ │ │ │ │ 🔵 │
├───┼───┼───┼───┼───┼────┼────┤
│ │ │ │ │ │ 🟠 │ 🟠 │
└───┴───┴───┴───┴───┴────┴────┘
Player 🔵. Col: 4
┏━━━┳━━━┳━━━┳━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴───┴───┴────┴────┴────┘
Player 🟠. Col: 5
┏━━━┳━━━┳━━━┳━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ 🟠 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴───┴───┴────┴────┴────┘
Player 🔵. Col: 5
┏━━━┳━━━┳━━━┳━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ 🔵 │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ 🟠 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴───┴───┴────┴────┴────┘
Player 🟠. Col: 4
┏━━━┳━━━┳━━━┳━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ 🔵 │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴───┴───┴────┴────┴────┘
Player 🔵. Col: 6
┏━━━┳━━━┳━━━┳━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ 🔵 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴───┴───┴────┴────┴────┘
Player 🟠. Col: 6
┏━━━┳━━━┳━━━┳━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ 🟠 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ 🔵 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴───┴───┴────┴────┴────┘
Player 🔵. Col: 4
┏━━━┳━━━┳━━━┳━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ 🟠 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🔵 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴───┴───┴────┴────┴────┘
Player 🟠. Col: 5
┏━━━┳━━━┳━━━┳━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ │ 🟠 │ 🟠 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🔵 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🔵 │
├───┼───┼───┼───┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴───┴───┴────┴────┴────┘
Player 🔵. Col: 3
┏━━━┳━━━┳━━━┳━━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼────┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼────┼────┼────┼────┤
│ │ │ │ │ │ 🟠 │ 🟠 │
├───┼───┼───┼────┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🔵 │ 🔵 │
├───┼───┼───┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🔵 │
├───┼───┼───┼────┼────┼────┼────┤
│ │ │ │ 🔵 │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴───┴────┴────┴────┴────┘
Player 🟠. Col: 4
┏━━━┳━━━┳━━━┳━━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━╇━━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼───┼────┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼───┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🟠 │
├───┼───┼───┼────┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🔵 │ 🔵 │
├───┼───┼───┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🔵 │
├───┼───┼───┼────┼────┼────┼────┤
│ │ │ │ 🔵 │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴───┴────┴────┴────┴────┘
Player 🔵. Col: 2
┏━━━┳━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼───┼────┼────┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼───┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🟠 │
├───┼───┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🔵 │ 🔵 │
├───┼───┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🔵 │
├───┼───┼────┼────┼────┼────┼────┤
│ │ │ 🔵 │ 🔵 │ 🔵 │ 🟠 │ 🟠 │
└───┴───┴────┴────┴────┴────┴────┘
Player 🟠. Col: 1
┏━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🟠 │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🔵 │ 🔵 │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🔵 │
├───┼────┼────┼────┼────┼────┼────┤
│ │ 🟠 │ 🔵 │ 🔵 │ 🔵 │ 🟠 │ 🟠 │
└───┴────┴────┴────┴────┴────┴────┘
Player 🔵. Col: 2
┏━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🟠 │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🔵 │ 🔵 │ 🔵 │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ 🔵 │ │ 🟠 │ 🟠 │ 🔵 │
├───┼────┼────┼────┼────┼────┼────┤
│ │ 🟠 │ 🔵 │ 🔵 │ 🔵 │ 🟠 │ 🟠 │
└───┴────┴────┴────┴────┴────┴────┘
Player 🟠. Col: 2
┏━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ │ │ │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🟠 │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ 🟠 │ │ 🔵 │ 🔵 │ 🔵 │
├───┼────┼────┼────┼────┼────┼────┤
│ │ │ 🔵 │ │ 🟠 │ 🟠 │ 🔵 │
├───┼────┼────┼────┼────┼────┼────┤
│ │ 🟠 │ 🔵 │ 🔵 │ 🔵 │ 🟠 │ 🟠 │
└───┴────┴────┴────┴────┴────┴────┘
Player 🔵. Col: 0
┏━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ │ │ │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🟠 │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ 🟠 │ │ 🔵 │ 🔵 │ 🔵 │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ 🔵 │ │ 🟠 │ 🟠 │ 🔵 │
├────┼────┼────┼────┼────┼────┼────┤
│ 🔵 │ 🟠 │ 🔵 │ 🔵 │ 🔵 │ 🟠 │ 🟠 │
└────┴────┴────┴────┴────┴────┴────┘
Player 🟠. Col: 3
┏━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ │ │ │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🟠 │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ 🟠 │ │ 🔵 │ 🔵 │ 🔵 │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ 🔵 │ 🟠 │ 🟠 │ 🟠 │ 🔵 │
├────┼────┼────┼────┼────┼────┼────┤
│ 🔵 │ 🟠 │ 🔵 │ 🔵 │ 🔵 │ 🟠 │ 🟠 │
└────┴────┴────┴────┴────┴────┴────┘
Player 🔵. Col: 3
┏━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┓
┃ 0 ┃ 1 ┃ 2 ┃ 3 ┃ 4 ┃ 5 ┃ 6 ┃
┡━━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━╇━━━━┩
│ │ │ │ │ │ │ │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ │ │ │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ │ │ 🟠 │ 🟠 │ 🟠 │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ 🟠 │ 🔵 │ 🔵 │ 🔵 │ 🔵 │
├────┼────┼────┼────┼────┼────┼────┤
│ │ │ 🔵 │ 🟠 │ 🟠 │ 🟠 │ 🔵 │
├────┼────┼────┼────┼────┼────┼────┤
│ 🔵 │ 🟠 │ 🔵 │ 🔵 │ 🔵 │ 🟠 │ 🟠 │
└────┴────┴────┴────┴────┴────┴────┘
WINNER IS PLAYER 🔵
❯
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_connect_4-0.1.1.tar.gz.
File metadata
- Download URL: py_connect_4-0.1.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a1b533068a566cbb9c8cc8d4d7d154b9a655bc18b1dec820be8620ac11e62b4
|
|
| MD5 |
790f5071a632786f0c39b79fd9c5410e
|
|
| BLAKE2b-256 |
43423771ed595cbc8a4741fe34691734db4e8d9d44d8946c5c6b4854755ed6a0
|
File details
Details for the file py_connect_4-0.1.1-py3-none-any.whl.
File metadata
- Download URL: py_connect_4-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
668b0bf1f3e580aad2453ce58304b001e64dc617f4a0e11661a6f889162bf173
|
|
| MD5 |
8557903d90a92ae1aafe90e2fd7fdbab
|
|
| BLAKE2b-256 |
c480b7c8455fb3479f344eda51444342074427523013ccd7fa25f9a1401c3fb9
|