Multiplayer client/server for CSD BattleShip
Project description
This package provides a simple client and server for the Battleship game. It tries to be roughly compatible with the Collaborative Software Design implementation. Behind the scenes, it uses WebSocket for communication between client and server.
Client Usage
The entire client functionality is encapsulated by battleship_mp.client.GameSession. This allows to join a game, transmit a board of set ships, and exchange shots. Note that the server does not perform any notable game state evaluation; multiplayer peers must exchange their game state (notably, their entire game board) to locally check the game progress. See the class’ description on how to use it.
Set the environment variable BMP_SERVER_URL to the server’s websocket URL. For example, if the server runs locally on port 8765 then use BMP_SERVER_URL="ws://localhost:8765" before starting the program. Alternatively, this can also be set inside Python by using os.environ["BMP_SERVER_URL"] = "ws://localhost:8765".
Server Usage
The server is self-contained and does not need to be embedded in a program. It can be run directly from the command line, requiring a port and optionally the addresses/hostnames to bind to. For testing, it is suitable to bind to localhost:
~ $ python3 -m battleship_mp.server 8765 localhost
See the --help flag for options.
Installation
You can install the package directly via pip; only Python >= 3.8 is required.
~ $ python3 -m pip install kcsd-battleship-mp
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
Hashes for kcsd_battleship_mp-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b052cb1b9672ec0a16c2e9623919d71bca9a381d82c3e24b067287992366fd0 |
|
MD5 | f4e6758deb122b758cadfe04777632ce |
|
BLAKE2b-256 | e57472f86d1f576ba154ef2f7fd0c921a9337ce11dca6689590b1e7e0f89fe1e |