- Move command-specific logic out of main.rs into Server::handle_* methods
(parsing remains in main and handlers accept already-parsed input).
- Handlers now return Result and return Err("ERROR:...") instead of sending
error messages directly to clients.
- main.rs now logs handler errors to console and sends the error string to
the client (removed `continue` statements after error sends).
- Move end_game_check from main.rs into lib.rs for reuse.
- Update handler implementations to follow the new error-returning pattern.
Connect4 Moderator - Server
A WebSocket server for the RPI Minds & Machines class and the Connect4 Final Project.
Built from the foundation of exoRift/mindsmachines-connect
To Build Your AI
Download the gameloop.py and agent.py files. It is heavily encouraged you only make changes to the agent.py file
In order to run your AI, you'll need:
- Python 3
pip install websockets(Windows) orpip3 install websockets(Linux/macOS)pip install pip-system-certs(Windows) orpip3 install pip-system-certs(Linux/macOS)
To run the example, run python gameloop.py (Windows) or python3 gameloop.py (Linux/macOS).
To Watch Games
The visual client for observing games/tournaments as well as managing games can be found at connect4-moderator-observer.
To Run the Server Locally
- Install Git and the Rust programming language
git clone https://github.com/joshuafhiggins/connect4-moderator-server.gitcd connect4-moderator-servercargo run --release demo
In this mode, you'll play against a player named demo who makes moves at random. If your AI makes invalid moves then your match is terminated and you are kicked from the server. If during the tournament you make an invalid move, you will instead immediately lose your game.
To connect to this server, use the address ws://localhost:8080
For Future Maintainers:
The Google Sheet outlining the communication protocol can be found here.
A JavaScript debug client that takes raw text as input and prints responses is provided,
npm inode debug_client.js
I also apologize in advance for the code you'll go on to read.