pymasep.interface.ui_board
Classes
Base class for UIBoard modes. |
|
UIBoard run mode. Select the agent action when a key is pressed on the board |
|
UIBoard select square mode. Select a square with mouse. |
|
UIBoard select a piece on the board. Select a piece with mouse. |
|
Element that can be put on the board |
|
Token that can be put on the board. At the moment, a Token is not different from an Element |
|
Square of the board |
|
Board with square where token can be put. |
Module Contents
- class pymasep.interface.ui_board.UIBoardMode(board)
Base class for UIBoard modes.
- Parameters:
board – the UIBoard where this mode is defined
- board
the board
- class pymasep.interface.ui_board.UIBoardModeRun(board)
Bases:
UIBoardModeUIBoard run mode. Select the agent action when a key is pressed on the board
- Parameters:
board – the UIBoard where this mode is defined
- process_event(event)
process the event received by the UIBoard
- Parameters:
event (pygame.event.Event) – event to process
- Returns:
true if the event has been processed
- Return type:
bool
- init()
Init the mode
- clean()
Clean the mode
- class pymasep.interface.ui_board.UIBoardModeSelectSquare(board)
Bases:
UIBoardModeUIBoard select square mode. Select a square with mouse.
- Parameters:
board – the UIBoard where this mode is defined
- process_event(event)
process the event received by the UIBoard
- Parameters:
event (pygame.event.Event) – event to process
- Returns:
true if the event has been processed
- Return type:
bool
- init()
Init the mode
- Return type:
None
- clean()
Clean the mode. Remove already selected square
- Return type:
None
- class pymasep.interface.ui_board.UIBoardModeSelectPiece(board)
Bases:
UIBoardModeUIBoard select a piece on the board. Select a piece with mouse.
- Parameters:
board – the UIBoard where this mode is defined
- process_event(event)
process the event received by the UIBoard
- Parameters:
event (pygame.event.Event) – event to process
- Returns:
true if the event has been processed
- Return type:
bool
- init()
Init the mode
- Return type:
None
- clean()
Clean the mode. Remove an already selected piece
- Return type:
None
- class pymasep.interface.ui_board.UIBoardElement(manager, board, board_pos, square_size, image_surface=None)
Bases:
pygame_gui.elements.UIImageElement that can be put on the board
- Parameters:
manager – Manager (from pygame_gui)
board – Board where this element is put
board_pos (tuple) – Position where this element put (board coordinates)
square_size (int) – square size (in pixel)
image_surface – image surface of the element to be displayed
- STATE_HOVERED = 0
The element is hovered by mouse
- STATE_SELECTED = 1
The element is selected
- STATE_ERROR = 2
The element is displayed as an error
- NB_STATES = 3
max number of possible states
- state = None
state of the board element
- previous_state = None
previous state of the board element
- square_size
square size of the element
- base_alpha = 150
base alpha color to display over the element
- alpha
current alpha color of the display over the element
- board
board where this element is put
- base_image
base image surface of the element
- _board_pos = None
- property board_pos: tuple
return the board position.
- Returns:
the board position
- Return type:
tuple
- hovered_for_action = False
is the element hovered in order to make an action on it
- was_hovered = False
was the element hovered
- update(time_delta)
update the element.
- Parameters:
time_delta (float) – time passed since the last call
- Return type:
None
- class pymasep.interface.ui_board.UIBoardToken(manager, board, position, square_size, image_surface)
Bases:
UIBoardElementToken that can be put on the board. At the moment, a Token is not different from an Element
- Parameters:
manager – Manager (from pygame_gui)
board – Board where this element is put
position – Position where this element put (board coordinates)
square_size – square size (in pixel)
image_surface – image surface of the element to be displayed
- class pymasep.interface.ui_board.UIBoardSquare(manager, board, square_size, board_pos)
Bases:
UIBoardElementSquare of the board
- Parameters:
manager – Manager (from pygame_gui)
board – Board where this element is put
board_pos – Position where this element put (board coordinates)
square_size – square size (in pixel)
- surface
- class pymasep.interface.ui_board.UIBoard(relative_rect, manager, container, sub_application, image_surface, game_data, game_class_, origin_coord_map, square_size, player_name)
Bases:
pygame_gui.core.UIContainerBoard with square where token can be put.
- For information, layer of elements:
background : 90 agents tokens: 100 selected square: 150
- Parameters:
relative_rect (pygame.Rect) – position and dimensions of the board (pixels)
manager (pygame_gui.core.interfaces.IUIManagerInterface) – Manager (from pygame_gui)
container (pygame_gui.core.interfaces.IContainerLikeInterface) – Container of the board (form pygame_gui)
sub_application – sub application instance (the interface)
image_surface (pygame.Surface) – the image surface to display the board
game_data – the data map (see @GridTools)
game_class – the class of the game
origin_coord_map (tuple) – pixel coordinate of the origin of the (0, 0) map position
square_size (int) – size of a square of the boad
player_name (str) – name of the player handle by the board
- RUN_MODE = 'Run'
Mode of the board : Rune
- SELECT_SQUARE_MODE = 'SelectSquare'
Mode of the board : Select a square
- SELECT_PIECE_MODE = 'SelectPiece'
Mode of the board : Select a piece on the board
- background_image
bacground image of the board
- game_data
data of the board
- game_class_
- sub_application
interface pointer
- origin_coord_map
pixel origin of the (0, 0) map position
- square_size
square size of the element in pixel
- player_name
name of the player handle by the board
- agents_tokens
agent UITokens
- objects_tokens
object UITokens
- spotlight_squares
squares that are spotlight
- hovered_board_pos = None
position of the board that is hovered
- modes
possible mode of the board
- current_mode = None
current mode of the board
- board_debug_info_idx
idx of the board debug info
- last_step_updated = None
the last step when the board has been updated
- add_spotlight_square_state(board_pos, state)
Set a spotlight square at a desired state
- Parameters:
board_pos – Position on the board
state – state to set see @UIBoardElement
- Return type:
None
- remove_spotlight_square_state(board_pos, state)
Remove a spotlighted square which is at a desired state
- Parameters:
board_pos – Position on the board
state – state which will be removed
- Return type:
None
- map_pos_to_surface_pos(map_pos)
Convert a map position to the surface position (pixel)
- Parameters:
map_pos – Position on the map (tuple)
- Returns:
surface position (tuple of pixel)
- Return type:
tuple
- surface_pos_to_map_pos(surface_pos)
convert the surface position to a map position
- Parameters:
surface_pos – the surface position (pixel)
- Returns:
the map position (tuple)
- Return type:
tuple
- get_spotlight_squares_from_state(state)
get all the squares on the baard that are on a certain state
- Parameters:
state – state to find
- Returns:
List of squares
- update_with_observation(time_delta)
Part of the update directly depending on the observation and that must be called only once per observation
- Parameters:
time_delta (float) – Time passed since the last call
- update(time_delta)
Update the element of the board according to the observation
- Parameters:
time_delta (float) – Time passed since the last call
- process_event(event)
Process an event on the board.
- Parameters:
event (pygame.event.Event) – The event to process
- Returns:
True the event has been processed
- Return type:
bool
- set_mode(mode)
Set the mode of the board. :param mode: Mode of the board.
- Return type:
None