Git Product home page Git Product logo

the-dummies-py's Introduction

Lugo - The Dummies Py

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.

Dependencies

Before starting

Are you familiar with Lugo? If not, before continuing, please visit the project website and read about the game.

Quick setup (if you do not want to download or clone the code)

You may use the SetupEnvPy Docker image to set up the environment for you:

  1. Open the terminal on an empty directory that will host your bot's source code (Use Powershell on Windows)
  2. Run the following command to set up the project quick start kit
    # on Lunix or Mac
    docker run -v $(pwd):/output lugobots/setup-env-py:latest
    
    # on Windows
    docker run -v ${PWD}:/output lugobots/setup-env-py:latest 
  3. (only Linux and Mac) Fix the file permissions running chown $USER -R .

How to use this source code

  1. (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
  2. Run the builder service that will install the depencencies you need (wait for the service to finish):

    docker compose up builder
    
  3. 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.

  4. Now, make your changes: (see โ“How to change the bot)

  5. Play again to see your changes results:

    docker compose up
  6. Are you ready to compete? Build your Docker image:

    docker build -t repo.lugobots.dev/[bot handle]:[version] .

How to edit the bot

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, orderSet: lugo4py.OrderSet, snapshot: GameSnapshot) -> OrderSet:
        # on_disputing is called when no one has the ball possession
        pass

    @abstractmethod
    def on_defending (self, orderSet: OrderSet, snapshot: GameSnapshot) -> OrderSet:
        # OnDefending is called when an opponent player has the ball possession
        pass

    @abstractmethod
    def on_holding (self, orderSet: OrderSet, snapshot: GameSnapshot) -> OrderSet:
        # OnHolding is called when this bot has the ball possession
        pass

    @abstractmethod
    def on_supporting (self, orderSet: OrderSet, snapshot: GameSnapshot) -> OrderSet:
        # OnSupporting is called when a teammate player has the ball possession
        pass

    @abstractmethod
    def as_goalkeeper (self, orderSet: OrderSet, snapshot: GameSnapshot, state: PLAYER_STATE) -> OrderSet:
        # 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, snapshot: GameSnapshot):
        # 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

Running directly in your machine (:ninja: advanced)

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.

Option 1 - comment out the bot from the Docker compose file

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.

Option 2 - starting the game server first

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

the-dummies-py's People

Contributors

katipunan98 avatar rubens21 avatar ddarckwolf avatar lnapoleao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.