socha.api.networking.utils#

Module Contents#

Functions#

_convert_board(→ socha._socha.Board)

Converts a protocol Board to a usable game board for using in the logic.

direction_from_string(→ socha._socha.CubeDirection)

direction_to_string(→ str)

handle_move(move_response)

_merge_advances(actions)

Merges consecutive Advance actions into a single action by adding their distances.

if_last_game_state(message, last_game_state)

if_not_last_game_state(→ socha._socha.GameState)

socha.api.networking.utils._convert_board(protocol_board: socha.api.protocol.protocol.Board) socha._socha.Board#

Converts a protocol Board to a usable game board for using in the logic. :param protocol_board: A Board object in protocol format :type protocol_board: Board :return: A Board object in the format used by the game logic :rtype: penguins.Board

socha.api.networking.utils.direction_from_string(cube_direction: str) socha._socha.CubeDirection#
socha.api.networking.utils.direction_to_string(cube_direction: socha._socha.CubeDirection) str#
socha.api.networking.utils.handle_move(move_response)#
socha.api.networking.utils._merge_advances(actions)#

Merges consecutive Advance actions into a single action by adding their distances. This is a workaround for handling multiple Advance actions in a sequence.

Args:

actions (list): A list of actions.

Returns:

list: A new list of actions where consecutive Advance actions have been merged.

Note:

This function modifies the input list ‘actions’ in-place.

socha.api.networking.utils.if_last_game_state(message, last_game_state)#
socha.api.networking.utils.if_not_last_game_state(message) socha._socha.GameState#