The Dummies PY is a Python implementation of a player (bot) for Lugo game.
This bot was made using the Python Client Player.
Use this bot as a starting point to a new one.
- Docker (https://docs.docker.com/get-docker/)
- Docker Compose (https://docs.docker.com/compose/install/)
You must install the projects requirements if you want to have the IDE intellisense working correctly in your environment.
- Download the Python 3.9 installer https://www.python.org/downloads/release/python-3912/
- On the Python installing wizard, remember to check the option to install the Pip tool
- On the project directory, run:
pip install virtualenv
python.exe -m venv venv
pip install -r requirements.txt
cd /path/to/your/project
sudo apt install python3.9-venv # não precisa se já tiver o venv instalado
# (pra saber da pra testar o comando
# python3.9 -m venv --help)
python3.9 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
Um possível erro que pode ocorrer nesse pip install é "the ssl module in Python is not available." E outros milhares de erros por faltar bibliotecas no seu pc Para resolver isso faça:
sudo apt install libssl-dev
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev curl libbz2-dev
Depois desinstale o python3.9 e instale novamente para compilá-lo com suporte às bibliotecas
- Vá para algum arquivo python
- No canto inferior direito, clique no botão "Select Python Interpreter"
- Selecione o python3.9 do venv desse projeto
(see https://www.jetbrains.com/help/idea/configuring-local-python-interpreters.html)
- Click on File
- Project Structure
- Click on Project
- Select Python3.9 in the SDK list
The IDE will ask you if you want to install the dependencies.
If not, before continuing, please visit the project website and read about the game.
You may use the SetupEnvPy Docker image to set up the environment for you:
-
(optional to speed up next steps) Download the images that you will need
docker pull lugobots/server docker pull lugobots/the-dummies-go:latest docker pull python:3.9-slim-buster
-
Run the builder service that will install the depencencies you need (wait for the service to finish):
docker compose up builder
-
Test it out: Before any change, make the Dummies Py play to ensure you are not working on a broken code.
docker compose up
and open http://localhost:8080/ to watch the game.
-
Now, make your changes: (see ❓How to change the bot)
-
Play again to see your changes results:
docker compose up
-
Are you ready to compete? Build your Docker image:
docker build -f .lugo/Dockerfile -t repo.lugobots.ai/[bot handle]:[version] .
Main file main.py
You will not change this file. It only initializes the bot.
Settings file settings.py
Settings file only stores configurations that will affect the player behaviour, e.g. positions, tactic, etc.
My bot my_bot.py
👀 This is the most important file!
There will be 5 important methods that you must edit to change the bot behaviour.
def on_disputing(self, inspector: GameSnapshotInspector) -> List[Order]:
# on_disputing is called when no one has the ball possession
pass
@abstractmethod
def on_defending(self, inspector: GameSnapshotInspector) -> List[Order]:
# OnDefending is called when an opponent player has the ball possession
pass
@abstractmethod
def on_holding(self, inspector: GameSnapshotInspector) -> List[Order]:
# OnHolding is called when this bot has the ball possession
pass
@abstractmethod
def on_holding(self, inspector: GameSnapshotInspector) -> List[Order]:
# OnSupporting is called when a teammate player has the ball possession
pass
@abstractmethod
def as_goalkeeper(self, inspector: GameSnapshotInspector, state: PLAYER_STATE) -> List[Order]:
# AsGoalkeeper is only called when this bot is the goalkeeper (number 1). This method is called on every turn,
# and the player state is passed at the last parameter.
pass
@abstractmethod
def getting_ready(self, inspector: GameSnapshotInspector):
# getting_ready will be called before the game starts and after a goal event. You will only need to implement
# this method in very rare cases.
pass
If you want to run the Python code in your machine instead of inside the container, you definitely can do this.
The command to start locally is BOT_TEAM=home BOT_NUMBER=1 python3.9 main.py
. However, when you run the Docker compose
file, all players from both teams will start. Then, if you run another bot directly from your machine, it will not
be allowed to join the game.
But you also cannot start your bot before the game server has started.
You have two options to run your bot locally.
You can edit the file docker-compose.yml
and comment out the player 2 of the home team.
The game server will wait all 11 players from both teams to connect before starting the game.
You can start only the game server with the command docker compose up -d game_server
. The game will wait for the players. Then, you
start your local bot (BOT_TEAM=home BOT_NUMBER=1 python3.9 main.py
), and finally start the rest of the players with the
command docker compose up