### Run Example with Docker Compose Source: https://github.com/lugobots/lugo4py/blob/master/example/simple/README.md Starts the pybot service using Docker Compose. Ensure your docker-compose.yml is correctly configured. ```bash docker compose up ``` -------------------------------- ### Run Lugo Server and Client Source: https://github.com/lugobots/lugo4py/blob/master/README.md Instructions to run the Lugo server in development mode and start the RL client. ```bash docker run -p 8080:8080 -p 5000:5000 lugobots/server:latest play --dev-mode --timer-mode=remote python3 -m example.rl.main ``` -------------------------------- ### Start Training Session with Zombie Players Source: https://github.com/lugobots/lugo4py/blob/master/src/lugo4py/rl/src/README.md Starts the training session and automatically includes 'Zombie Players' to fill the remaining team slots. This is an alternative to starting the training directly. ```Python gym.with_zombie_players(grpc_address).start(lugo_client, players_executor) ``` -------------------------------- ### Start Lugo Server Headless Source: https://github.com/lugobots/lugo4py/blob/master/src/lugo4py/rl/src/README.md Command to run the Lugo Game Server in development mode without the frontend. This can improve performance by saving resources. ```Bash docker run -p 8080:8080 -p 5000:5000 lugobots/server:v1.0.0-beta.6-rc.1 play --dev-mode --timer-mode=remote --headless ``` -------------------------------- ### Initialize and Use Mapper Source: https://github.com/lugobots/lugo4py/blob/master/README.md Create a Mapper instance to divide the game field into regions. Use it to get a region from coordinates or a point. ```python # let's create a map 10x5 map = lugo4py.Mapper(10, 5, config.get_bot_team_side()) targetRegion = map.get_region(5, 2) my_region = mapper.get_region_from_point(me.position) ``` -------------------------------- ### Start Game Server in Dev Mode Source: https://github.com/lugobots/lugo4py/blob/master/example/rl/README.md Run the lugobots/server Docker image in development mode with remote timer mode enabled. This allows the RL environment to control the server. Access the training session at http://localhost:8080/. ```shell docker run -p 8080:8080 -p 5000:5000 lugobots/server:v1.0.0-beta.6-rc.1 play --dev-mode --timer-mode=remote ``` -------------------------------- ### Interact with Regions Source: https://github.com/lugobots/lugo4py/blob/master/README.md Utilize Region objects to navigate the game field. Get adjacent regions, column, and row information. ```python target_region = map.get_region_from_point(bot.position) region_in_front_of_me = target_region.front() region_in_back_of_me = target_region.back() region_in_left_of_me = target_region.left() region_in_right_of_me = target_region.right() my_col = target_region.get_col() my_row = target_region.get_row() moveOrder, err_ := reader.makeOrderMoveMaxSpeed(position, region_in_front_of_me.center) ``` -------------------------------- ### Create Turn Orders with SnapshotReader Source: https://github.com/lugobots/lugo4py/blob/master/README.md Generate turn orders for bot actions like jumping, kicking, and moving using GameSnapshotReader. ```python reader = lugo4py.GameSnapshotReader(snapshot, bot.side) reader.make_order_jump(origin, target, speed) reader.make_order_kick(ball, target, speed) reader.make_order_kick_max_speed(ball, target) reader.make_order_move(origin, target, speed) reader.make_order_move_from_vector(direction, speed) reader.make_order_move_max_speed(origin, target) reader.make_order_catch() ``` -------------------------------- ### Run Training Script Source: https://github.com/lugobots/lugo4py/blob/master/example/rl/README.md Execute the main training script using Python 3. This script utilizes a training function that picks random actions and prints outputs. ```shell python3 main.py ``` -------------------------------- ### Build pybot Docker Image Source: https://github.com/lugobots/lugo4py/blob/master/example/simple/README.md Builds the pybot Docker image using the provided Dockerfile. This command tags the image as 'pybot'. ```bash docker build -t pybot -f ./Dockerfile ../.. ``` -------------------------------- ### Helper Functions for Game Data Access Source: https://github.com/lugobots/lugo4py/blob/master/README.md Provides utility functions for interacting with game data. `EnvVarLoader` is used for loading environment configurations, and `GameSnapshotReader` assists in parsing game snapshots based on the bot's side. ```python config = lugo4py.EnvVarLoader() reader = lugo4py.GameSnapshotReader(snapshot, bot.side) ``` -------------------------------- ### Abstract Bot Class Interface Source: https://github.com/lugobots/lugo4py/blob/master/README.md Defines the interface for implementing bot behavior based on game states like disputing, defending, holding, and supporting. The `as_goalkeeper` method handles the goalkeeper role, and `getting_ready` is for pre-game or post-goal initialization. ```python class Bot(ABC): @abstractmethod def on_disputing (self, orderSet: lugo4py.OrderSet, snapshot: lugo4py.GameSnapshot) -> lugo4py.OrderSet: # on_disputing is called when no one has the ball possession pass @abstractmethod def on_defending (self, orderSet: lugo4py.OrderSet, snapshot: lugo4py.GameSnapshot) -> lugo4py.OrderSet: # OnDefending is called when an opponent player has the ball possession pass @abstractmethod def on_holding (self, orderSet: lugo4py.OrderSet, snapshot: lugo4py.GameSnapshot) -> lugo4py.OrderSet: # OnHolding is called when this bot has the ball possession pass @abstractmethod def on_supporting (self, orderSet: lugo4py.OrderSet, snapshot: lugo4py.GameSnapshot) -> lugo4py.OrderSet: # OnSupporting is called when a teammate player has the ball possession pass @abstractmethod def as_goalkeeper (self, orderSet: lugo4py.OrderSet, snapshot: lugo4py.GameSnapshot, state: PLAYER_STATE) -> lugo4py.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: lugo4py.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 ``` -------------------------------- ### Connect to Remote Control Source: https://github.com/lugobots/lugo4py/blob/master/src/lugo4py/rl/src/README.md Establishes a connection to the game server's remote control service. Requires the gRPC address of the server. ```Python rc = RemoteControl() rc.connect(grpc_address) ``` -------------------------------- ### Move by Direction with SnapshotReader Source: https://github.com/lugobots/lugo4py/blob/master/README.md Control bot movement using directional commands provided by GameSnapshotReader. ```python reader.make_order_move_by_direction(DIRECTION.FORWARD) reader.make_order_move_by_direction(DIRECTION.BACKWARD) reader.make_order_move_by_direction(DIRECTION.LEFT) reader.make_order_move_by_direction(DIRECTION.RIGHT) reader.make_order_move_by_direction(DIRECTION.BACKWARD_LEFT) reader.make_order_move_by_direction(DIRECTION.BACKWARD_RIGHT) reader.make_order_move_by_direction(DIRECTION.FORWARD_LEFT) reader.make_order_move_by_direction(DIRECTION.FORWARD_RIGHT) ``` -------------------------------- ### Extract Game Data with SnapshotReader Source: https://github.com/lugobots/lugo4py/blob/master/README.md Use GameSnapshotReader to extract team information, ball possession, goals, and player details from a game snapshot. ```python reader = lugo4py.GameSnapshotReader(snapshot, self.side) reader.get_my_team() reader.get_team(side) reader.is_ball_holder(player) reader.get_opponent_side() reader.get_my_goal() reader.get_opponent_goal() reader.get_player(side, number) ``` -------------------------------- ### Define Training Function Signature Source: https://github.com/lugobots/lugo4py/blob/master/src/lugo4py/rl/src/README.md Defines the expected signature for a training function. The function receives a TrainingController to manage the training flow. ```Python TrainingFunction = Callable[[TrainingController], None] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.