A Scrabble® game implemented in Python.
See the video below for example gameplay.
gameplay720p30s.mov
- A fully terminal-based user interface
- Uses websockets to enable playing with friends over a network.
- Includes a move generation algorithm that powers move validation and computer opponents.
- SocketIO - for client-server communication
- Redis - for storing game state and lobby data
- ncurses - for creating the terminal UI
- Create a new game lobby by running
python run_network_game.py your_name
- Share the 4 digit room ID with other players (who have network access to your host machine)
- Join an existing game lobby by running
python run_network_game.py your_name room_id
- Start the game, closing the lobby, once all players have joined
- Enter the direction, location, and word to play when prompted
- Moves will be rejected per the official game rules
- If the word does not exist in the game's
dictionary.txt
- If the word does not connect to an existing tile
- If the player's rack is missing required tiles to play a word
- If the word does not exist in the game's
- Moves are scored according to tile values and board multiplier squares
Run the Docker application, which contains a Redis container and game server container, which are started automatically.
~ docker-compose up
[+] Running 2/0
⠿ Container pyscrabble-redis-1 Created 0.0s
⠿ Container pyscrabble-wss-1 Created 0.0s
Attaching to pyscrabble-redis-1, pyscrabble-wss-1
Launch the network game inside the game server.
~ docker exec -it pyscrabble-wss-1 python run_network_game.py your_name
Use Python 3.7 or 3.8
Create a Python virtual environment, using venv
or any alternative.
~ python -m venv pyscrabble
~ cd pyscrabble
~ source bin/activate
Next clone this repo and install the dependencies.
(pyscrabble) ~ git clone https://github.com/danesolberg/PyScrabble.git
(pyscrabble) ~ cd PyScrabble
(pyscrabble) ~ pip install -r requirements.txt
Install Redis (if required)
~ brew install redis
~ brew services start redis
Start the game server
(pyscrabble) ~ python start_server.py
* Restarting with stat
* Debugger is active!
* Debugger PIN: 734-552-454
(pid) wsgi starting up on http://0.0.0.0:5000
(pyscrabble) ~ pytest
In development environment
(pyscrabble) ~ python run_local_game.py
In Docker container
~ docker exec -it pyscrabble-wss-1 python run_local_game.py
To launch a network game (currently defaulting to localhost), first create a new game room.
(pyscrabble) ~ python run_network_game.py <your_name>
or
~ docker exec -it pyscrabble-wss-1 python run_network_game.py <your_name>
This will open a new game room and present a room code to share with up to three other players.
Players can join this game by appending the room code as an argument to run_network_game.py
. In the image above, the room code is 4b82.
(pyscrabble) ~ python run_network_game.py <your_name> <room_code>
or
~ docker exec -it python run_network_game.py <your_name> <room_code>