socha._socha#
Module Contents#
Classes#
- class socha._socha.PluginConstants#
- ROUND_LIMIT: int#
- START_COAL: int#
- MIN_SPEED: int#
- MAX_SPEED: int#
- FREE_ACC: int#
- FREE_TURNS: int#
- FINISH_POINTS: int#
- POINTS_PER_PASSENGER: int#
- POINTS_PER_SEGMENT: int#
- NUMBER_OF_PASSENGERS: int#
- SEGMENT_FIELDS_WIDTH: int#
- SEGMENT_FIELDS_HEIGHT: int#
- NUMBER_OF_SEGMENTS: int#
- MAX_SPECIAL: int#
- MIN_SPECIAL: int#
- MAX_ISLANDS: int#
- MIN_ISLANDS: int#
- class socha._socha.CartesianCoordinate(x: int, y: int)#
- x: int#
- y: int#
- to_cube() CubeCoordinates#
- to_index() int | None#
- from_index() CartesianCoordinate#
- class socha._socha.CubeCoordinates(q: int, r: int)#
- q: int#
- r: int#
- s: int#
- coordinates() List[int]#
- x() int#
- y() int#
- to_cartesian() CartesianCoordinate#
- times(count: int) CubeCoordinates#
- plus(other: CubeCoordinates) CubeCoordinates#
- minus(other: CubeCoordinates) CubeCoordinates#
- unary_minus() CubeCoordinates#
- rotated_by(turns: int) CubeCoordinates#
- distance_to(other: CubeCoordinates) int#
- turn_count_to(target: CubeDirection) int#
- class socha._socha.CubeDirection#
- Right: int#
- DownRight: int#
- DownLeft: int#
- Left: int#
- UpLeft: int#
- UpRight: int#
- vector() CubeCoordinates#
- angle() int#
- with_neighbors() List[CubeDirection]#
- opposite() CubeDirection#
- turn_count_to(target: CubeDirection) int#
- rotated_by(turns: int) CubeDirection#
- ordinal() int#
- class socha._socha.Move(actions: List[Accelerate | Advance | Push | Turn])#
- actions: List[Accelerate | Advance | Push | Turn]#
- class socha._socha.Ship(position: CubeCoordinates, team: TeamEnum, direction: CubeDirection | None = None, speed: int | None = None, coal: int | None = None, passengers: int | None = None, free_turns: int | None = None, points: int | None = None)#
-
- position: CubeCoordinates#
- direction: CubeDirection#
- speed: int#
- coal: int#
- passengers: int#
- free_turns: int#
- points: int#
- free_acc: int#
- movement: int#
- can_turn() bool#
- max_acc() int#
- accelerate_by(diff: int) None#
- read_resolve() None#
- resolve_direction(reverse: bool) None#
- update_position(distance: int, advance_info: AdvanceInfo) None#
- __str__() str#
Return str(self).
- class socha._socha.AccelerationProblem#
- ZeroAcc: Any#
- AboveMaxSpeed: Any#
- BelowMinSpeed: Any#
- InsufficientCoal: Any#
- OnSandbank: Any#
- message() str#
- class socha._socha.AdvanceProblem#
- MovementPointsMissing: Any#
- InsufficientPush: Any#
- InvalidDistance: Any#
- ShipAlreadyInTarget: Any#
- FieldIsBlocked: Any#
- MoveEndOnSandbank: Any#
- message() str#
- class socha._socha.PushProblem#
- MovementPointsMissing: Any#
- SameFieldPush: Any#
- InvalidFieldPush: Any#
- BlockedFieldPush: Any#
- SandbankPush: Any#
- BackwardPushingRestricted: Any#
- message() str#
- class socha._socha.Push(direction: CubeDirection)#
- direction: CubeDirection#
- class socha._socha.TurnProblem#
- RotationOnSandbankNotAllowed: Any#
- NotEnoughCoalForRotation: Any#
- RotationOnNonExistingField: Any#
- message() str#
- class socha._socha.Turn(direction: CubeDirection)#
- direction: CubeDirection#
- class socha._socha.Passenger#
- direction: CubeDirection#
- passenger: int#
- class socha._socha.Segment(direction: CubeDirection, center: CubeCoordinates, fields: List[List[Field]])#
- direction: CubeDirection#
- center: CubeCoordinates#
- tip() CubeCoordinates#
- get(coordinates: CubeCoordinates) Field | None#
- set(coordinates: CubeCoordinates, field: Field) None#
- local_to_global(coordinates: CubeCoordinates) CubeCoordinates#
- global_to_local(coordinates: CubeCoordinates) CubeCoordinates#
- contains(coordinates: CubeCoordinates) bool#
- array_coords(coords: CubeCoordinates) CartesianCoordinate#
- cube_coords(coords: CartesianCoordinate) CubeCoordinates#
- class socha._socha.Board(segments: List[Segment], next_direction: CubeDirection)#
-
- next_direction: CubeDirection#
- segment_with_index_at(coords: CubeCoordinates) tuple[int, Segment] | None#
- get(coords: CubeCoordinates) Field | None#
- does_field_have_current(coords: CubeCoordinates) bool#
- does_field_have_stream(coords: CubeCoordinates) bool#
- get_field_in_direction(direction: CubeDirection, coords: CubeCoordinates) Field | None#
- set_field_in_direction(direction: CubeDirection, coords: CubeCoordinates, field: Field) None#
- get_coordinate_by_index(segment_index: int, x_index: int, y_index: int) CubeCoordinates#
- segment_distance(coordinate1: CubeCoordinates, coordinate2: CubeCoordinates) int#
- segment_index(coordinate: CubeCoordinates) int | None#
- find_segment(coordinate: CubeCoordinates) Segment | None#
- neighboring_fields(coords: CubeCoordinates) List[Field | None]#
- is_sandbank(coords: CubeCoordinates) bool#
- pickup_passenger_at_position(pos: CubeCoordinates) Field | None#
Picks up a passenger at the specified position using the CubeCoordinates.
- Args:
pos (CubeCoordinates): The CubeCoordinates representing the position to check.
- Returns:
Optional[Field]: The Field containing a passenger with a passenger count greater than 0, or None if no such Field is found in any adjacent direction.
- find_nearest_field_types(start_coordinates: CubeCoordinates, field_type: FieldType) Set[CubeCoordinates]#
A function to find the nearest field(s) of a specific type from a starting point in a hexagonal grid.
- Args:
start_coordinates (CubeCoordinates): A CubeCoordinates object representing the starting point for the search. field_type (FieldType): A FieldType object representing the type of field being searched for.
- Returns:
list of CubeCoordinates: A list of CubeCoordinates corresponding to the location of the nearest field(s) of the specified type.
- Note:
This function will always return the coordinates of the nearest field(s) of the specified type, if such a field(s) exist. If multiple fields of the same type are at the same minimum distance, it returns all of them. If there isn’t a field of the specified type or path to it, it will return an empty list.
- Examples:
```python from plugin import Board, CubeCoordinates, FieldType
board = Board() board.find_nearest_field_types(CubeCoordinates(0, 0), FieldType.Water) ```
- class socha._socha.AdvanceInfo#
- costs: int#
- problem: AdvanceProblem#
- cost_until(distance: int) int#
- distance() int#
- class socha._socha.GameState(board: Board, turn: int, current_ship: Ship, other_ship: Ship, last_move: Move | None)#
-
- turn: int#
- is_current_ship_on_current() bool#
- remove_passenger_at(coords: CubeCoordinates) bool#
- pick_up_passenger_current_ship() None#
- pick_up_passenger_other_ship() None#
- must_push() bool#
- check_ship_advance_limit(ship: Ship) AdvanceInfo#
- calculate_advance_info(start: CubeCoordinates, direction: CubeDirection, max_movement_points: int) AdvanceInfo#
- possible_accelerations() List[Accelerate]#
- possible_action_comb(current_state: GameState, current_actions: List[Accelerate | Advance | Push | Turn], depth: int, max_depth: int) List[List[Accelerate | Advance | Push | Turn]]#
- possible_actions(rank: int) List[Accelerate | Advance | Push | Turn]#
- coal_for_action(action: Accelerate | Advance | Push | Turn) int#
- can_move() bool#
- is_over() bool#
- get_points_for_team(ship: Ship) TeamPoints#