team

Defines how a team is created, drawn and updated

Override the set_players and move method to create a valid custom team

(You can use a custom agent in your custom team)

Team Objects

class Team(ABC)

Abstract class that controls a team of agents.

Implement the move and set_players methods to instantiate

__init__

 | __init__(color=(0, 0, 0), formation='default', ids=list(range(NUM_TEAM)))

Initialize the teams (not completely, some paramters are set using the init() method)

Attributes:

  • color tuple - The RGB value of the team
  • formation string - The team's formation of the team. Must be a key of FORM from const.py
  • ids [int] - Players to include in the team (identified by their ids)

init

 | init(id, dir, diff)

Set the teams id, direction and difficulty (only for AI teams) Also recolor the sprites based on the team's chosen color

Attributes:

  • id int - The team's id (must be either 1 or 2)
  • dir str - The team's direction (must be either 'L' or 'R')
  • diff float - The game difficult (between 0-1)

Calls set_players() and set_color()

set_color

 | set_color()

Recolor the sprites using this team's color

set_formation

 | set_formation(formation)

Set the teams formation

formation_toggle

 | formation_toggle()

Toggle whether the team maintains its formation

draw

 | draw(win, cam, debug=False)

Draw the team

Basically calls each players' draw() method

update

 | update(action, ball)

Update the team's state

Basically calls each players' update() method

set_players

 | @abstractmethod
 | set_players(ids=list(range(NUM_TEAM)))

Implement this method to instantiate a valid team.

Add players (of relevant class) to the team

Attributes:

  • ids list - IDs of players to include in the team (defaults to all the players)

Requirements:

  • Players are added to a list called players
  • Their ids match their respective index in the array

move

 | @abstractmethod
 | move(state_prev, state, reward)

Implement this method for a valid team

Attributes:

  • state_prev dict - The lsat to last game state
  • state dict - The last game state
  • reward list - Reward returned from this state (Not implemented)

Should return a list of valid actions (in the same order as each of the players)