Skip to main content

Multiplayer client/server for CSD BattleShip

Project description

Documentation Status Available on PyPI License

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.


You can install the package directly via pip; only Python >= 3.8 is required.

~ $ python3 -m pip install kcsd-battleship-mp

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kcsd-battleship-mp-1.1.0.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distribution

kcsd_battleship_mp-1.1.0-py3-none-any.whl (9.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page