StateGrid.hpp
StateGrid maintains a rectilinear grid that agents can traverse.
This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2017-2018 Michigan State University MIT Software license; see doc/LICENSE.md
State grids are a matrix of values, representing states of a 2D environment that an organism can traverse.
- Todo:
Functions such as Load() should throw exceptions (or equiv.), not use asserts.
Need to figure out a default mapping for how outputs translate to moves around a state grid. -1 = Back up ; 0 = Turn left ; 1 = Move fast-forwards ; 2 = Turn right
Allow StateGridInfo to be built inside of StateGrid (change reference to pointer and possible ownership)
Defines
-
INCLUDE_EMP_EVOLVE_STATE_GRID_HPP_GUARD
-
class StateGridInfo
- #include <StateGrid.hpp>
Full information about the states available in a state grid and meanings of each state.
Public Types
-
using key_t = uint32_t
Public Functions
-
inline size_t GetNumStates() const
-
inline char GetSymbol(int state_id) const
-
inline double GetScoreChange(int state_id) const
-
inline int GetState(char symbol) const
Protected Functions
Protected Attributes
-
struct StateInfo
- #include <StateGrid.hpp>
Information about what a particular state type means in a state grid.
-
using key_t = uint32_t
-
class StateGrid
- #include <StateGrid.hpp>
A StateGrid describes a map of grid positions to the current state of each position.
Public Types
-
using key_t = StateGridInfo::key_t
Public Functions
-
StateGrid() = default
-
inline StateGrid(StateGridInfo &_i, key_t _w = 1, key_t _h = 1, int init_val = 0)
-
inline StateGrid(StateGridInfo &_i, const std::string &filename)
-
~StateGrid() = default
-
inline size_t GetSize() const
-
inline const StateGridInfo &GetInfo() const
-
inline BitVector IsState(int target_state) const
Return a BitVector indicating which positions in the state grid have a particular state.
-
template<typename ...Ts>
inline void AddState(Ts&&... args) Setup the StateGridInfo with possible states.
-
template<typename ...Ts>
inline StateGrid &Load(Ts&&... args) Load in the contents of a StateGrid using the file information provided.
-
using key_t = StateGridInfo::key_t
-
class StateGridStatus
- #include <StateGrid.hpp>
Information about a particular agent on a state grid.
Public Types
-
using key_t = StateGridInfo::key_t
Public Functions
-
StateGridStatus() = default
-
StateGridStatus(const StateGridStatus&) = default
-
StateGridStatus(StateGridStatus&&) = default
-
~StateGridStatus() = default
-
StateGridStatus &operator=(const StateGridStatus&) = default
-
StateGridStatus &operator=(StateGridStatus&&) = default
-
inline BitVector GetVisited(const StateGrid &grid) const
Get a BitVector indicating the full history of which positions this organism has traversed.
-
inline StateGridStatus &TrackMoves(bool track = true)
-
inline StateGridStatus &Set(key_t _x, key_t _y, key_t _f)
-
inline StateGridStatus &SetX(key_t _x)
-
inline StateGridStatus &SetY(key_t _y)
-
inline StateGridStatus &SetPos(key_t _x, key_t _y)
-
inline StateGridStatus &SetFacing(key_t _f)
-
inline void Rotate(int turns = 1)
Rotate starting from current facing.
Protected Functions
-
inline void UpdateHistory()
If we are tracking moves, store the current position in the history.
Protected Attributes
-
bool track_moves
Should we record every move made by this organism?
-
using key_t = StateGridInfo::key_t