SAMPLE_TEAM.gcreceiver

This module shows how the GameController Communication protocol can be used in python and also allows to be changed such that every team using python to interface with the GC can utilize the new protocol.

Modded by Egor Davydenko egordv@gmail.com for elsiros league

Module Contents

Classes

GameStateReceiver

This class puts up a simple UDP Server which receives the

SampleGameStateReceiver

This class puts up a simple UDP Server which receives the

ThreadedGameStateReceiver

This class puts up a simple UDP Server which receives the

Attributes

logger

console_handler

DEFAULT_LISTENING_HOST

GAME_CONTROLLER_LISTEN_PORT

GAME_CONTROLLER_ANSWER_PORT

parser

SAMPLE_TEAM.gcreceiver.logger[source]
SAMPLE_TEAM.gcreceiver.console_handler[source]
SAMPLE_TEAM.gcreceiver.DEFAULT_LISTENING_HOST = 0.0.0.0[source]
SAMPLE_TEAM.gcreceiver.GAME_CONTROLLER_LISTEN_PORT = 3838[source]
SAMPLE_TEAM.gcreceiver.GAME_CONTROLLER_ANSWER_PORT = 3939[source]
SAMPLE_TEAM.gcreceiver.parser[source]
class SAMPLE_TEAM.gcreceiver.GameStateReceiver(team, player, is_goalkeeper, addr=(DEFAULT_LISTENING_HOST, GAME_CONTROLLER_LISTEN_PORT), answer_port=GAME_CONTROLLER_ANSWER_PORT)[source]

Bases: object

This class puts up a simple UDP Server which receives the addr parameter to listen to the packages from the game_controller.

If it receives a package it will be interpreted with the construct data structure and the on_new_gamestate() will be called with the content.

After this we send a package back to the GC

_open_socket(self)[source]

Erzeugt das Socket

receive_forever(self)[source]

Waits in a loop that is terminated by setting self.running = False

receive_once(self)[source]

Receives a package and interprets it. Calls on_new_gamestate() Sends an answer to the GC

answer_to_gamecontroller(self, peer)[source]

Sends a life sign to the game controller

abstract on_new_gamestate(self, state)[source]

Is called with the new game state after receiving a package Needs to be implemented or set :param state: Game State

get_last_state(self)[source]
get_time_since_last_package(self)[source]
stop(self)[source]
set_manual_penalty(self, flag)[source]
class SAMPLE_TEAM.gcreceiver.SampleGameStateReceiver(team, player, is_goalkeeper, addr=(DEFAULT_LISTENING_HOST, GAME_CONTROLLER_LISTEN_PORT), answer_port=GAME_CONTROLLER_ANSWER_PORT)[source]

Bases: GameStateReceiver

This class puts up a simple UDP Server which receives the addr parameter to listen to the packages from the game_controller.

If it receives a package it will be interpreted with the construct data structure and the on_new_gamestate() will be called with the content.

After this we send a package back to the GC

on_new_gamestate(self, state)[source]

Is called with the new game state after receiving a package Needs to be implemented or set :param state: Game State

class SAMPLE_TEAM.gcreceiver.ThreadedGameStateReceiver(team, player, is_goalkeeper, addr=(DEFAULT_LISTENING_HOST, GAME_CONTROLLER_LISTEN_PORT), answer_port=GAME_CONTROLLER_ANSWER_PORT)[source]

Bases: GameStateReceiver

This class puts up a simple UDP Server which receives the addr parameter to listen to the packages from the game_controller.

If it receives a package it will be interpreted with the construct data structure and the on_new_gamestate() will be called with the content.

After this we send a package back to the GC

start(self)[source]
on_new_gamestate(self, state)[source]

Is called with the new game state after receiving a package Needs to be implemented or set :param state: Game State