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.
Python Client for the Software-Challenge Germany 2023
Hey there! To help you out, it's best to start by checking out the documentation for this client before you ask any questions or open an issue. It'll provide you with some helpful information!
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!.
Table of Contents
- Getting Started
- Preparing Your Player for the Competition
Two methods are presented here to install the
The first one is the fastest to get started right away.
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.
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.6 installed. Check with
$ python -Vor
$ python3 -V.
If not present you can install python with the following commands:
> winget install -e --id Python.Python.3.6
$ sudo apt install python3.6
$ sudo pacman -S python
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.
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.
$ source venv/bin/activate
> 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
(venv) $ pip install socha
This should satisfy the dependencies and you can start right away.
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
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 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
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())
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.
|--help||Prints the help message.|
|-h, --host||The host to connect to. The default is 'localhost'.|
|-p, --port||The port of the host. The default is 13050.|
|-r, --reservation||Reservation code for a prepared game.|
|-R, --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.|
|-v, --verbose||Verbose option for logging.|
|--auto-reconnect||Automatically reconnect to the server if the connection is lost.|
|-b, --build||Builds this script into a package with all its dependencies.|
Preparing Your Player for the Competition
To ensure that your player is usable for the competition system, you need to download all the dependencies that your client uses because the system will run on a docker container without access to the internet and sudo permission.
The package has made things easier for you! You can use it to handle almost everything by itself. All you need is a
requirements.txtfile that lists all your dependencies. To start, simply run the following command in your terminal:
$ python <your_main_script>.py --build <your_directory_name>
This will trigger the package to do its magic and build your project.
If you want to do it manually, follow the steps below to download the dependencies:
- Open your terminal or console wherever you want to create your directory that you will upload.
mkdir my_playerto create a new directory named
my_player. You can name yours whatever you want.
- Enter the directory using
- Run the command:
pip download socha xsdata==22.7 -d dependenciesin the directory. This command downloads the dependencies you need into the folder
- Ensure to add all your dependencies that your client uses.
- After the download, create a last directory using
Once you have downloaded all the dependencies,
you need to create a shell script that uses the contest system as the entry point for your player.
It must be named
start.sh and must be on the top level of your directory; otherwise, it cannot be found.
Follow the steps below to create your shell script:
Ensure that you create your shell script in a UNIX-Environment, or if you use Windows, you can do this with WSL or Notepad++. If you use Notepad++, you need to go to Bearbeiten->Format Zeilenende->Unix(LF). This step ensures that your line endings are
CR, which may cause problems on the contest system.
Ensure that your shell script has the following structure:
#!/bin/sh # Exit immediately if any command fails set -e # Sets the environment variable, which specifies the location for pip to store its cache files export XDG_CACHE_HOME=./my_player/.pip_cache # Sets the environment variable, which adds the directory to the list of paths that Python searches for modules and packages when they are imported. export PYTHONPATH=./my_player/packages:$PYTHONPATH # Install the socha package pip install --no-index --find-links=./my_player/dependencies/ ./my_player/dependencies/socha-1.0.1-py3-none-any.whl ./my_player/dependencies/xsdata-22.7-py3-none-any.whl --target=./my_player/packages/ --cache-dir=./my_player/.pip_cache # Run the logic.py script with start arguments python3 ./my_player/logic.py "$@"
- Ensure that you add all your dependencies that your client is using to this script.
Once you have created your shell script, you should have a directory structure that looks like this:
my_player/ ├── .pip_cache/ ├── dependencies/ ├── logic.py └── start.sh
my_player directory or whatever you named yours just needs to be packaged as a ZIP archive,
and your player is ready to be uploaded. Congratulations! 🥳🎉
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.