Skip to main content

Lugo4Py is a Python3 implementation of a client player for Lugo game.

Project description

Lugo4Py - A Lugo Bots Client

Lugo4Py is a Python implementation of a client player for Lugo game.

It is not a bot that plays the game, it is only the client to connect to the game server.

This package implements many methods that does not affect the player intelligence/behaviour/decisions. It is meant to reduce the developer concerns on communication, protocols, attributes, etc.

Using this client, you just need to implement the Artificial Intelligence of your player and some other few methods to support your strategy (see the project exampe folder).

Installation

pip install lugo4py

Usage

Lugo4Py implements a very basic logic to reduce the code boilerplate. This client will wrap most repetitive code that handles the raw data got by the bot and will identify the player state.

Implement the Bot interface to handle each player state based on the ball possession.

class Bot(ABC):
    @abstractmethod
    def onDisputing (self, orderSet: lugo4py.OrderSet, snapshot: GameSnapshot) -> OrderSet:
        # onDisputing is called when no one has the ball possession
        pass

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

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

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

    @abstractmethod
    def asGoalkeeper (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 gettingReady (self, snapshot: GameSnapshot):
        # gettingReady 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

Kick-start

You may copy the code from the example directory to start you bot, but we encourage you to clone The Dummies Py project and start from there. The read me file will have all details you need.

Deploying you bots

After developing your bot, you may share it with other developers.

Please find the instructions for uploading your bot on lugobots.dev.

There is a Dockerfile template in the example directory to guide you how to create a container.

Helpers

There are a many things that you will repeatedly need to do on your bot code, e.g. getting your bot position, creating a move/kick/catch order, finding your teammates positions, etc.

This package brings a collection of functions that will help you get that data from the game snapshot:

config = EnvVarLoader()

reader = GameSnapshotReader(snapshot, self.side)

Mapper and Region

This package also provides a quite useful pair: the Mapper and Region classes.

The Mapper

Mapper slices the field in columns and rows, so your bot does not have to care about precise coordinates or the team side. The mapper will automatically translate the map position to the bot side.

And you may define how many columns/rows your field will be divided into.

# let's create a map 10x5 
map = Mapper(10, 5, config.getBotTeamSide())


targetRegion = map.getRegion(5, 2)

The Region

The Mapper will slice the field into Regions. The Region struct helps your bot to move over the field without caring about coordinates or team side.

regionInFrontOfMe = targetRegion.front()

moveOrder, err_ := reader.makeOrderMoveMaxSpeed(position, regionInFrontOfMe.center)

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

lugo4py-0.0.1a1.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

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

lugo4py-0.0.1a1-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file lugo4py-0.0.1a1.tar.gz.

File metadata

  • Download URL: lugo4py-0.0.1a1.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for lugo4py-0.0.1a1.tar.gz
Algorithm Hash digest
SHA256 a04a50d12c23f0bcb15d4f5b736ecbdc03d098a092c0128f582cfb1df4947bc3
MD5 c34d9011dcf11e0abc2828ab3efc5384
BLAKE2b-256 5faadbefdb311a43942b998060a30c46d13ebf0b390c220bbf7f27b4e262223e

See more details on using hashes here.

File details

Details for the file lugo4py-0.0.1a1-py3-none-any.whl.

File metadata

  • Download URL: lugo4py-0.0.1a1-py3-none-any.whl
  • Upload date:
  • Size: 30.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for lugo4py-0.0.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 805c031a9cdade0edd586989c986bacbf1d8de1f82dafbfe03155bfae590d002
MD5 7ff4a010ce3ea4514edd839f61e747b2
BLAKE2b-256 cc552fc8a41bb906622c32d0c7c01df28fe81a45c2cdabc9ca65cafd91f7889d

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