turbo_tag module¶
Module: Turbo Tag Game Simulation
This module simulates a game of Turbo Tag, a dynamic team sport emphasizing strategy and agility. It is played on a rectangular field with a goal at each end, involving two teams with a variable number of players. The primary objective is to score points through tagging, ball possession, and goal scoring.
Game Rules:
Team Composition: Teams can have 5 to 9 players. Each additional player beyond five reduces the team’s total band count by 2.
Starting the Game: Begins with a jump ball at the center. The team that secures the ball gains initial possession.
Scoring Points:
Goal Score: Throwing the ball into the opponent’s goal scores 3 points.
Band Capture: Tagging an opponent allows stealing a band, earning 1 point. If the tagged player holds bands of more than one color, the tagging player steals a band of their own team’s color. The tagger only steals a band of the opposing team’s color if the tagged player has only bands of that color.
End of game bonuses, described below.
Tagging Mechanism:
Players can tag opponents to steal their bands.
A player must wait at least 30 seconds before re-tagging the same opponent.
If a tagged player holds the ball, the ball is transferred to the nearest opponent. If this tag occurs within 5 meters of the tagging player’s team’s goal, the tag is also worth one point (this is called a “block-by-tag”).
Time Limit: Two 25-minute halves with a break in between.
Scoring System:
Each goal: 3 points.
Each band captured: 1 point.
Bonus for capturing all opponent bands: At the end of the game, each player that has zero bands of their own color awards their opponent 10 points.
Single color bonus: At the end of the game, each band that a team holds of their opposing team’s color is worth an additional bonus point.
- class turbo_tag.Ball¶
Bases:
objectRepresents the ball used in Turbo Tag.
- class turbo_tag.Game(team1: Team, team2: Team)¶
Bases:
objectRepresents a game of Turbo Tag.
- time_left¶
The time left in the game (in minutes).
- Type:
int
- end_game()¶
Ends the game and calculates final scores.
- class turbo_tag.Player(name: str, team: Team, initial_bands: int)¶
Bases:
objectRepresents a player in the Turbo Tag game.
- name¶
The name of the player.
- Type:
str
- bands¶
A dictionary tracking the count of blue and red bands the player has.
- Type:
dict
- last_tag_time¶
The last time the player tagged someone (given in seconds since the start of the game).
- Type:
int or None
- has_ball¶
Flag indicating whether the player currently has the ball.
- Type:
bool
- class turbo_tag.Team(name: str, player_count: int, team_color: str)¶
Bases:
objectRepresents a team in the Turbo Tag game.
- name¶
The name of the team.
- Type:
str
- score¶
The current score of the team.
- Type:
int
- players¶
A list of Player objects on the team.
- Type:
list
- team_color¶
The color of the team’s bands.
- Type:
str
- adjust_band_count(player_count: int, team_color: str)¶
Adjusts the initial band count for each player based on the team size.
- Parameters:
player_count (int) – The number of players on the team.
team_color (str) – The color of the team’s bands.
- calculate_end_game_bonus()¶
Calculates and adds end-game bonus points to the team’s score.
- score_goal()¶
Updates the team’s score when a goal is scored.