hyphi_gym.envs.FlatGrid
#
Package Contents#
Classes#
Base for grid-based games managing |
|
Base for grid-based games managing |
|
Base for grid-based games managing |
- class hyphi_gym.envs.FlatGrid.Grid(render_mode: hyphi_gym.common.board.Optional[str] = None, **simargs)#
Bases:
hyphi_gym.common.rendering.Rendering
,hyphi_gym.common.point.Point
Base for grid-based games managing • A layout of a variable size • Containing CELLS ∈ [WALL, FIELD, AGENT, TARGET, HOLE] • Navigable with ACTIONS ∈ [UP, RIGHT, DOWN,LEFT]
- step_scale = 1#
- base_xml#
- metadata#
- render() hyphi_gym.common.board.Optional[hyphi_gym.common.board.np.ndarray] #
Return rendering of current state as np array if render_mode set
- reset(**kwargs) tuple[hyphi_gym.common.board.np.ndarray, dict] #
Gymnasium compliant function to reset the environment
- _distance()#
- execute(action: int) tuple[hyphi_gym.common.board.np.ndarray, dict] #
Helper function to step the environment, executing action, returning its consequences
- class hyphi_gym.envs.FlatGrid.Board(size: tuple[int, int], layout: list[str] | None, bound=None, **kwargs)#
Bases:
hyphi_gym.common.base.Base
Base for grid-based games managing • A layout of a variable size • Containing CELLS ∈ [WALL, FIELD, AGENT, TARGET, HOLE] • Navigable with ACTIONS ∈ [UP, RIGHT, DOWN,LEFT]
- board: numpy.ndarray#
- size: tuple[int, int]#
- layout: numpy.ndarray | None#
- ascii(grid: numpy.ndarray | None = None) list[str] #
Transform 2D-INT Array to list of strings
- _grid(ascii: list[str]) numpy.ndarray #
Transform 1D string to 2D-INT Array
- getpos(board: numpy.ndarray | None = None, cell: str = AGENT) numpy.ndarray #
Position helper for finding the vector position of cell on the board or internal board
- newpos(position: numpy.ndarray | tuple[int, int], action: int, n=1) tuple[int, int] #
Action helper mutating a position tuple by appying action n-times
- iterate_actions(p: tuple[int, int], n=1, condition=lambda act, pos, n: ...) dict[int, tuple[int, int]] #
Return possible n actions in a bounded box given a position p and their mutated positions
- action_possible(act: int, pos: tuple[int, int], n=1) bool #
Return possible n actions act in a bounded box given a position pos
- _generate()#
Random generator for flat grids, creating a grid of size
- _validate(board, error=True, setup=False)#
Overwrite this function to validate layout return steps to solution
- _update(key: str, oldpos, newpos)#
- _randomize(board: numpy.ndarray, key: str)#
Mutation function to randomize the position of cell on board
- reset(**kwargs) tuple[gymnasium.spaces.Space, dict] #
Gymnasium compliant function to reset the environment
- class hyphi_gym.envs.FlatGrid.FlatGrid(size, random=[], render_mode=None, **kwargs)#
Bases:
hyphi_gym.common.grid.Grid
,hyphi_gym.common.board.Board
Base for grid-based games managing • A layout of a variable size • Containing CELLS ∈ [WALL, FIELD, AGENT, TARGET, HOLE] • Navigable with ACTIONS ∈ [UP, RIGHT, DOWN,LEFT]