Skip to main content

This is the package for the Software-Challenge Germany 2023. This Season the game will be 'Hey, danke für den Fisch' a.k.a. 'Penguins' in short.

Project description

Software-Challenge Logo

Python Client for the Software-Challenge Germany 2023

GitHub Workflow Status Read the Docs PyPI Discord Documentation Website

Please note that this is a very early version, which may still contain some bugs. However, the client is able to play a game from start to end.

This repository contains the Python package for the Software-Challenge Germany, a programming competition for students. The students have to develop an artificial intelligence that plays and competes against other opponents in an annually changing game.

This year it is the game Hey, danke für den Fisch!.

Installation

Two methods are presented here to install the socha client. The first one is the fastest to get started right away. However, this method will not make it possible to run your player in the competition system, since there is no Internet connection that allows you to download packages. Therefore, the possibility of a virtual environment is presented, which installs the packages inside the folder.

Pleas make sure that you have at least Python 3.10 installed. Check with $ python -V or $ python3 -V.

  • Windows: > winget install -e --id Python.Python.3.10
  • Debian: $ sudo apt install python3.10
  • Arch: $ sudo pacman -S python

Globally

The installation is quite simple with pip.

$ pip install socha

If you want to install the package manually, then you have to download the release of your choice, unpack the package and then run setup.py with Python.

$ python setup.py install --user

This should satisfy the dependencies and you can start right away.

Virtual Environment

To create a virtual environment, you should first create a directory in which you want to develop your player and than enter that directory.

$ mkdir my_player
$ cd my_player

Now you can create the virtual environment (venv).

$ python -m venv venv/

This takes a moment. After the venv is created, you can open it.

On Linux:

$ source venv/bin/activate

On Windows:

> Set-ExecutionPolicy Unrestricted -Scope Process
> .\venv\Scripts\activate

It should open the venv and you can now install packages and run your scripts here. To develop your player you just have to install the package socha with pip.

(venv) $ pip install socha

This should satisfy the dependencies and you can start right away.

Getting Started

If you want to start with the Software-Challenge Python Client, you have to import some dependencies first.

The import is kept very simple, since herewith all needed dependencies are imported, due to changes of the __init__.py. But if you want to avoid unnecessary imports, you can of course import only what you actually need.

from socha import *

If you now want to develop and implement your logic, then the structure of the class should look like this.

class Logic(IClientHandler):
    gameState: GameState

    def calculate_move(self) -> Move:
        possibleMoves = self.gameState.possible_moves
        return possibleMoves[0]

    def on_update(self, state: GameState):
        self.gameState = state

The above example is the simplest working Logic you can build. As you can see the Logic must inherit from the IClientHandler, so that you can overwrite its methods and the api knows where to find your logic.

If you're done with your version of an working player, than you have to finish your file with this function, where you call the Starter with your desired arguments. The following starts the client with the default arguments.

if __name__ == "__main__":
    Starter(Logic())

Start arguments

If you want to run your logic from the console, you can of course pass start arguments.

Note that any arguments passed as startup parameters will override those in the code, including the ones you set yourself.

argument description
--help Prints a help message.
-h HOST , --host HOST The host to connect to. The default is 'localhost'.
-p PORT , --port PORT The port of the host. The default is 13050.
-r RESERVATION , --reservation RESERVATION Reservation code for a prepared game.
-R ROOM , --room ROOM Room Id the client will try to connect.
-s , --survive If present the client will keep running, even if the connection to the server is terminated.
-l , --log If present the client will write a log file to the current directory.

Make your player ready to hand in

To make your player usable for the competition system, you need to create a virtual environment, as described above.

Once you have done this, you still need to create a shell script that uses the contest system as the entry point for your player. It must be named start.sh because otherwise it cannot be found. There you must enter the following and place it in the root of your directory.

#!/bin/sh
chmod +x logic.py
. venv/bin/activate
python ./logic.py "$@"

When you have done this, you should have a directory structure that looks something like this:

my_player/
|- venv/
|- logic.py
|- start.sh

The my_player directory, or whatever you named yours, then just needs to be packaged as a ZIP archive and your player is ready to be uploaded. 🥳🎉

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

socha-0.9.4.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

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

socha-0.9.4-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file socha-0.9.4.tar.gz.

File metadata

  • Download URL: socha-0.9.4.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for socha-0.9.4.tar.gz
Algorithm Hash digest
SHA256 a54e36dd6094861f21fb055e3fa03ba516113a5032896ffa2b402da336890906
MD5 b246bd1a39748b963d244caea64d7343
BLAKE2b-256 14170cd56a9d4f0619522e603972ea51651d5c0fd9aab672e1edefc13956c922

See more details on using hashes here.

File details

Details for the file socha-0.9.4-py3-none-any.whl.

File metadata

  • Download URL: socha-0.9.4-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for socha-0.9.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8e43654b07b337f9828d394075bf76e8cc97f7554f97b7736640dab50b0352dd
MD5 a02a37a8ec3df4731b2ff50041eb2e3c
BLAKE2b-256 0f8d85749edff3c4d93ba9b5a6cc2785fdfe7c7a042901353074aaab5fe0cc83

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