dc3client package

Submodules

dc3client.dc3client module

class dc3client.dc3client.BaseClient(timeout: int = 10, buffer: int = 1024, log_level: int = 20)[source]

Bases: object

receive() dict[str, Any][source]

receive message from server until ” “

Returns:

dict[str, Any]: received message

send(message: str = '')[source]

send message to server

Parameters:

message (str, optional) – massage content. Defaults to “”.

class dc3client.dc3client.SocketClient(host: str = 'dc3-server', port: int = 10000, client_name: str = 'AI0', auto_start: bool = True, rate_limit: float = 0.2)[source]

Bases: BaseClient

concede() None[source]

Concede

convert_dc(dc_data: ServerDC) dict[str, Any][source]

convert ServerDC to dict

convert_is_ready(is_ready: IsReady) dict[str, Any][source]

convert IsReady to dict

Parameters:

is_ready (IsReady) – is_ready

Returns:

converted is_ready

Return type:

dict

convert_trajectory(trajectory_data: Trajectory) dict[str, Any][source]

convert trajectory to dict

Parameters:

trajectory_data (Trajectory) – trajectory

Returns:

dict of trajectory

Return type:

dict[str, Any]

convert_update(update_data: Update, remove_trajectory: bool = True) dict[str, Any][source]

convert Update to dict

Parameters:
  • update_data (Update) – Update

  • remove_trajectory (bool) – Delete trajectory data from Update? Defaults to True.

Returns:

converted Update

Return type:

dict

dc_ok() None[source]

send dc_ok

dc_recv()[source]

receive dc

get_dc() ServerDC[source]

get dc data

get_is_ready() IsReady[source]

get is_ready data

get_match_data() MatchData[source]

get match data

get_move_info() list[ShotInfo][source]

get move info

get_my_team() str[source]

get my team name

Returns:

my team name

Return type:

str

get_new_game()[source]

receive new_game

get_next_team() str[source]

get next team name

get_update_and_trajectory(remove_trajectory: bool = True) tuple[list[Update], list[Trajectory]][source]

get update and trajectory

Parameters:

remove_trajectory (bool, optional) – Delete trajectory data from Update?. Defaults to True.

Returns:

update list and trajectory list

Return type:

tuple[list[Update], list[Trajectory]]

get_winner() str | None[source]

get winner

is_ready_recv()[source]

receive is_ready

move(x: float = 0.0, y: float = 2.4, rotation: StoneRotation = StoneRotation.counterclockwise) None[source]

Shot Stone

Parameters:
  • x (float, optional) – Velocity in x-axis direction. Defaults to 0.0.

  • y (float, optional) – Velocity in y-axis direction. Defaults to 2.4. rotation (StoneRotation, optional): Rotation of stone. Defaults to StoneRotation.outturn.

ready_ok(player_order: list = [0, 1, 2, 3]) None[source]

send ready_ok

start_game()[source]

start game

update()[source]

receive update

dc3client.models module

class dc3client.models.ActualMove(rotation: str | None, type: str | None, velocity: Velocity)[source]

Bases: object

Actual Move

rotation: str | None
type: str | None
velocity: Velocity
class dc3client.models.Concede(type: str = 'concede')[source]

Bases: object

type: str = 'concede'
class dc3client.models.Coordinate(angle: float | None, position: list[Position])[source]

Bases: object

Position and Angle

angle: float | None
position: list[Position]
exception dc3client.models.DCNotFoundError[source]

Bases: Exception

class dc3client.models.ExtraEndScore(team0: int, team1: int)[source]

Bases: object

ExtraEnd Score

team0: int
team1: int
class dc3client.models.ExtraEndThinkingTime(team0: float, team1: float)[source]

Bases: object

Thinking time per end of ExtraEnd

team0: float
team1: float
class dc3client.models.Finish(team0: list[Coordinate], team1: list[Coordinate])[source]

Bases: object

Stone placement at end of shot

team0: list[Coordinate]
team1: list[Coordinate]
class dc3client.models.Frame(team: str | None, index: int | None, value: Coordinate | None)[source]

Bases: object

The position and angle of the stones at each time interval, denoted by seconds_per_frame. Each frame is represented as the difference from the previous frame (the first frame is start).

index: int | None
team: str | None
value: Coordinate | None
class dc3client.models.FrameArray(array: Frame | None)[source]

Bases: object

Frame Array

array: Frame | None
class dc3client.models.GameResult(winner: str | None, reason: str | None)[source]

Bases: object

Game Result

reason: str | None
winner: str | None
exception dc3client.models.GameResultNotFoundError[source]

Bases: Exception

class dc3client.models.GameRule(players: Players, rule: str, setting: Setting, simulator: Simulator)[source]

Bases: object

Game Rule

players: Players
rule: str
setting: Setting
simulator: Simulator
class dc3client.models.IsReady(cmd: str, team: str, game: GameRule)[source]

Bases: object

Match settings

cmd: str
game: GameRule
team: str
exception dc3client.models.IsReadyNotFoundError[source]

Bases: Exception

class dc3client.models.LastMove(actual_move: ActualMove | Concede, free_guard_zone_foul: bool, trajectory: Trajectory | None)[source]

Bases: object

Results of previous shot

actual_move: ActualMove | Concede
free_guard_zone_foul: bool
trajectory: Trajectory | None
class dc3client.models.MatchData(server_dc: ~dc3client.models.ServerDC | None = None, is_ready: ~dc3client.models.IsReady | None = None, new_game: ~dc3client.models.NewGame | None = None, update_list: list[~dc3client.models.Update] = <factory>)[source]

Bases: object

Match Data

is_ready: IsReady | None = None
new_game: NewGame | None = None
server_dc: ServerDC | None = None
update_list: list[Update]
class dc3client.models.NewGame(cmd: str, name: dict)[source]

Bases: object

Signal for the start of the match

cmd: str
name: dict
class dc3client.models.PlayerInfo(max_speed: float, seed: None, stddev_angle: float, stddev_speed: float, randomness: str)[source]

Bases: object

Maximum velocity of the stone and standard deviation of normally distributed random numbers applied to the initial velocity and initial angle

max_speed: float
randomness: str
seed: None
stddev_angle: float
stddev_speed: float
class dc3client.models.Players(team0: list[PlayerInfo], team1: list[PlayerInfo])[source]

Bases: object

Pool of players per team

team0: list[PlayerInfo]
team1: list[PlayerInfo]
class dc3client.models.Position(x: float | None, y: float | None)[source]

Bases: object

Stone Position

x: float | None
y: float | None
class dc3client.models.Scores(team0: list, team1: list)[source]

Bases: object

team0: list
team1: list
class dc3client.models.ServerDC(date_time: str, game_id: str, cmd: str, version: Version)[source]

Bases: object

Server Info

cmd: str
date_time: str
game_id: str
version: Version
class dc3client.models.Setting(extra_end_thinking_time: ExtraEndThinkingTime, five_rock_rule: bool, max_end: int, sheet_width: float, thinking_time: ThinkingTime)[source]

Bases: object

Match Setting

extra_end_thinking_time: ExtraEndThinkingTime
five_rock_rule: bool
max_end: int
sheet_width: float
thinking_time: ThinkingTime
class dc3client.models.ShotInfo(velocity_x: float, velocity_y: float, rotation: StoneRotation)[source]

Bases: object

Shot Info

rotation: StoneRotation
velocity_x: float
velocity_y: float
class dc3client.models.Simulator(seconds_per_frame: float, simulator_type: str)[source]

Bases: object

Simulator Settings

seconds_per_frame: float
simulator_type: str
class dc3client.models.Start(team0: list[Coordinate], team1: list[Coordinate])[source]

Bases: object

Stone placement at the start of the shot

team0: list[Coordinate]
team1: list[Coordinate]
class dc3client.models.State(end: int, extra_end_score: ExtraEndScore, game_result: GameResult, hammer: str, scores: Scores, shot: int, stones: Stones, thinking_time_remaining: ThinkingTimeRemaining)[source]

Bases: object

Match State

end: int
extra_end_score: ExtraEndScore
game_result: GameResult
hammer: str
scores: Scores
shot: int
stones: Stones
thinking_time_remaining: ThinkingTimeRemaining
class dc3client.models.StoneRotation(value)[source]

Bases: str, Enum

Stone Rotation Direction

clockwise = 'cw'
counterclockwise = 'ccw'
inturn = 'cw'
outturn = 'ccw'
class dc3client.models.Stones(team0: list[Coordinate], team1: list[Coordinate])[source]

Bases: object

Stone Positions of each team

team0: list[Coordinate]
team1: list[Coordinate]
class dc3client.models.ThinkingTime(team0: float, team1: float)[source]

Bases: object

Thinking time not including ExtraEnd

team0: float
team1: float
class dc3client.models.ThinkingTimeRemaining(team0: float, team1: float)[source]

Bases: object

Thinking time remaining

team0: float
team1: float
class dc3client.models.Trajectory(seconds_per_frame: float | None, start: Start, finish: Finish, frames: list[FrameArray] | None)[source]

Bases: object

Trajectory of each stone

finish: Finish
frames: list[FrameArray] | None
seconds_per_frame: float | None
start: Start
class dc3client.models.Update(cmd: str, next_team: str, state: State, last_move: LastMove | None)[source]

Bases: object

Match information on each shot

cmd: str
last_move: LastMove | None
next_team: str
state: State
class dc3client.models.Velocity(x: float | None, y: float | None)[source]

Bases: object

x: float | None
y: float | None
class dc3client.models.Version(major: int, minor: int)[source]

Bases: object

Version Info

major: int
minor: int

Module contents