Curling
Curling
#
__init__(self, starting_color: Optional[StoneColor] = None)
special
#
initialise curling game
Parameters:
Name | Type | Description | Default |
---|---|---|---|
starting_color |
Optional[StoneColor] |
color of starting player (or None for random). Defaults to None. |
None |
reset(self, starting_color: Optional[StoneColor] = None)
#
reset curling game
Parameters:
Name | Type | Description | Default |
---|---|---|---|
starting_color |
Optional[StoneColor] |
color of starting player (or none for random). Defaults to None. |
None |
step(self, simulation_constants: SimulationConstants = SimulationConstants(time_intervals=array([0.3 , 0.1 , 0.05]), num_points_on_circle=array(20), eps=array(1.e-06), accuracy=<Accuracy.LOW: 0>)) -> SimulationState
#
step the simulation one timestep (simulation_constants.dt)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation_constants |
SimulationConstants |
specify a set of constants to use for the simulation step. Defaults to SimulationConstants(). |
SimulationConstants(time_intervals=array([0.3 , 0.1 , 0.05]), num_points_on_circle=array(20), eps=array(1.e-06), accuracy=<Accuracy.LOW: 0>) |
Returns:
Type | Description |
---|---|
SimulationState |
whether the simulation is finished or not |
render(self) -> Canvas
#
create a canvas and render the curling game
Returns:
Type | Description |
---|---|
Canvas |
canvas with rendered curling game |
out_of_bounds(self, stone: Stone) -> bool
#
check if a stone is out of bounds
button_distance(self, stone: Stone) -> float
#
calculate the distance from the button to a stone
in_house(self, stone: Stone) -> bool
#
determines if a stone is in the house
in_fgz(self, stone: Stone) -> bool
#
determines if a stone is in the free guard zone
display(self, constants: SimulationConstants = SimulationConstants(time_intervals=array([0.3 , 0.1 , 0.05]), num_points_on_circle=array(20), eps=array(1.e-06), accuracy=<Accuracy.LOW: 0>))
#
display the curling game
Parameters:
Name | Type | Description | Default |
---|---|---|---|
constants |
SimulationConstants |
specify a set of constants to use for the simulation step. Defaults to SimulationConstants(). |
SimulationConstants(time_intervals=array([0.3 , 0.1 , 0.05]), num_points_on_circle=array(20), eps=array(1.e-06), accuracy=<Accuracy.LOW: 0>) |
create_stone(self, stone_throw: StoneThrow) -> Stone
#
create a stone from a stone throw
throw(self, stone_throw: StoneThrow, constants: SimulationConstants = SimulationConstants(time_intervals=array([0.3 , 0.1 , 0.05]), num_points_on_circle=array(20), eps=array(1.e-06), accuracy=<Accuracy.LOW: 0>), display: bool = False)
#
update the curling game with a stone throw
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stone_throw |
StoneThrow |
stone throw of current player |
required |
constants |
SimulationConstants |
specify a set of constants to use for the simulation. Defaults to SimulationConstants(). |
SimulationConstants(time_intervals=array([0.3 , 0.1 , 0.05]), num_points_on_circle=array(20), eps=array(1.e-06), accuracy=<Accuracy.LOW: 0>) |
display |
bool |
whether to display the throw. Defaults to False. |
False |
evaluate_position(self) -> int
#
evaluate the current position of the stones the score is n * color, where n is the number of stones of the color closest to the button a score of 0 means all stones are out of the house
Returns:
Type | Description |
---|---|
int |
score of the current position |