Skip to main content

The shared libraries for CUWAIS competitions

Project description

AIWarSoc Common

The common code and data shared by the other modules.

Contains:

  • A python repository defining the database tables and connection methods, as well as a config file parser and gamemode definitions
  • A default_config.yml file used by many other modules, which gives all of the available config options and their defaults

Usage

Python

You can add the python module using pip install cuwais-common

From there you can use a database connection in the following way:

with cuwais.database.create_session() as db_session:
  user_scores = db_session.query(
    User,
    func.sum(Result.points_delta).label("total_score")
  ).outerjoin(User.submissions) \
  .outerjoin(Submission.results) \
  .group_by(User.id) \
  .order_by("total_score") \
  .all()

or get a gamemode and all of its data by using Gamemode.get(‘game-name’)

Config

The default config file can be got using wget default_config.yml https://raw.githubusercontent.com/AI-Wars-Soc/common/main/default_config.yml

Contributing

First ensure that you have read all of the Contributing rules within the server repository. If you do not set up your contribution environment correctly then you may end up missing a step.

Gamemodes

The most common way of contributing to this repository is to add a new gamemode. A gamemode describes a possible game that can be used in a competition, eg. chess.

To add a new gamemode you must do the following:

  • Add any libraries required by your gamemode to setup.py
  • Add a new class which implements the abstract class Gamemode within gamemodes.py
  • Allow your gamemode to be found by adding it to the get(gamemode_name: str) function in the Gamemode class.

Once you have done this, it will be possible for AIs to be written and battled for your new game. HOWEVER this does not mean that your game is fully implemented! You must also ensure that the sandbox docker image contains all of the libraries that you have used in your gamemode, and if you want your game to be playable in the browser then you must also add rendering code to web-app. Head to both of these repositories to find relevant contribution instructions.

Config

The other way of contributing to this repository is by adding options to the default_config.yml file. This file is included in the build step of all relevant docker images, so the only tricky bit to remember when contributing here is that you must ensure that you merge your updates to the default_config.yml file here before you merge your updates to whatever needs the new config options. That way the default_config.yml file will be the new version when your new changes in the other modules are built.

Along the same lines, if you change a default value then all of the modules that use that value must be rebuilt so that they are aware of the change.

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

cuwais-common-1.3.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cuwais_common-1.3.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file cuwais-common-1.3.1.tar.gz.

File metadata

  • Download URL: cuwais-common-1.3.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for cuwais-common-1.3.1.tar.gz
Algorithm Hash digest
SHA256 494b9015434d572fac53a815b3cc0311034e69c72fe1754879fe1dc1db9f0e29
MD5 0cb95486162e4f3e9fe0670f0718e8df
BLAKE2b-256 004211ebdbea82c583d347494a389e34009b2e29278817308ba28f8095663509

See more details on using hashes here.

File details

Details for the file cuwais_common-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: cuwais_common-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for cuwais_common-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88802e8bfde05873a894f5e99a2dc92ddcd780b3fd4130a13d0f154e37ec8f86
MD5 3d7f56784801c08be4dfe5469edcb16d
BLAKE2b-256 fae750b4685f8816093a371c91a96792afe97f70c5a96909efdfdcb8cb7b0c78

See more details on using hashes here.

Supported by

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