This is the environment (language, IDE, tools) recommended for development
- Python 3.8
- Visual Studio Code, Recommended extensions: Python, Docker, LiveShare
- Git
- Docker
- Make sure you have Git installed on your machine
- In Github, click on the green button label "Code" in top right of the repository
- Copy the HTTPS url
- Open a terminal in the folder where you want the your code repository to be
- Run:
git clone [HTTPS url]
If you need more help click Here
- Make sure to have Python 3.8 installed on your machine
- Clone code repository (see section above to know how)
- Open a terminal in the root of the project
- Run:
pip install -r requirements.txt
After you are all set up, you are finally ready to code! ;)
But where to start? In the GitHub repository you just cloned, you will find a file named Src/brain.py
. In this file, you have the function on_next_move(turn_info)
and it is in this function that you have to code your AI. It takes as parameter a turn_info
which contains all the information given by the GameSever so that your AI can make a decision on its next move. You can find this model in Src/Models/turnInformation.py
. The function must return a direction (up, down, left, right). If it fails to do this 3 times in a row, the GameServer will consider your AI to be obsolete. You can find these constants in Src/Models/direction.py
(If you change these values, your next moves will be considered invalid). Another function found in brain.py
is on_finalized(turn_info)
. Once a game is finished, this method is triggered with the final state of the map and nothing needs to be returned to the GameServer.
The map you receive is encoded in a list of strings. Some of the encodings are:
- “P0*” : represente the head of the player with the id 0
- “P0” : represente part of the body of the player with id 0
- “p0” : represente part of the neck of the player with id 0
- “W” : A wall
Now you know where to start coding. As a first goal, try to get your AI from point A to point B as simply as possible.
Good luck!
- Make sure you have Docker installed on your machine and running
- Login into docker:
- With Docker Hub:
docker login
- With Github:
docker login https://docker.pkg.github.com
- You can login using your password or a personal access tokens
- If using a personal access tokens:
- Create your personal access tokens Here
- Make sure you give it the following scope:
read:packages
- Login using the command:
docker login -u [GITHUB_USERNAME] -p [TOKEN_ID]
- With Docker Hub:
- Pull Docker images:
- Windows or MacOs:
docker pull docker.pkg.github.com/readyaicode-2020/gslocal/gslocal:win_mac
- Linux:
docker pull docker.pkg.github.com/readyaicode-2020/gslocal/gslocal:linux
- Windows or MacOs:
- Run the following command to know if the images was correctly loaded:
docker images
- You should see a repository with the name of your images you just pull
- To know how to clean up your docker environment at the end of the competition, see the last section of this ReadMe
-
Run code
- Open a terminal in the root of the project
- Make sure the required packages are installed (see section Install required python packages)
- Run:
python main.py
- If it is not starting a game, sometime you need to restart the GameServer Local container
- You can stop the execution by doing ctrl-c in the terminal
-
Run the local GameServer in Docker container
- Make sure docker image in install (see section Setup GameServer Local)
- In a terminal run:
- Windows or MacOs:
docker run --rm -d -p 5001:5001 --name gs_container docker.pkg.github.com/readyaicode-2020/gslocal/gslocal:win_mac
- Linux:
docker run --rm -d --network host -p 5001:5001 --name gs_container docker.pkg.github.com/readyaicode-2020/gslocal/gslocal:linux
- --rm: Remove the container when stop
- -d: Hide the outputs, remove if you want see them
- Windows or MacOs:
- You can verify if the container is running with:
docker ps
-
Connect the Dashboard UI to the GameServer Local
- Make sure the GameServer Local container is running
- Go to the section Local debug in the event dashboard
- Click on the button Start
- Attention: If you restart the GameServer Local container you will need to repeat this step to reconnect the UI
-
In case its not working, here’s a few things to try:
- You can restart the container with:
docker restart gs_container
- You can stop the container with:
docker stop gs_container
and then repeat the steps fromRun the local GameServer in Docker container
- You can restart the container with:
-
If you installed and are using new packages, in requirements.txt add the packages names and its version. Otherwise your code will not work in deployment
- [PACKAGE NAME]==[PACKAGER VERSION]
- Attention Do not use:
pip freeze > requirements.txt
-
Push the code on the Master branch
- Open a terminal in the root of the project
- Stage all changes:
git add .
- You can also stage on file at a time:
git add [file_path]
- You can also stage on file at a time:
- Commit changes:
git commit -m "Descriptive message"
- Push code:
git push
-
See the status if your deployment
- Go to the Actions tab in the Github repository
- See on the latest workflow
- If it is on going it will have a yellow spinning wheel next to it
- If it is done successfully it will have a green circle next to it
- If it fails it will have a red cross next to it. Click on the workflow to see the logs and find out why it failed to deploy
-
Wait 2 to 4 minutes after the workflow is done successfully to make sure the deployment is fully completed on are servers
!ATTENTION!: Only push on the Master branch when it's really necessary to avoid problems with the deployment pipeline. Problems may last a while and slow down your developpement process.
- Stop and remove container
docker stop gs_container
- If you remove --rm earlier:
docker rm gs_container
- Remove images
docker rmi [images_name]
- Use
docker images
to see the list of images and find its name or id
- Use
- Logout of docker
docker logout