StateGrid.hpp
StateGrid maintains a rectilinear grid that agents can traverse.
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 equilv.), 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)
-
class StateGridInfo
- #include <StateGrid.hpp>
Full information about the states available in a state grid and meanings of each state.
Public Functions
-
inline StateGridInfo()
-
StateGridInfo(const StateGridInfo&) = default
-
StateGridInfo(StateGridInfo&&) = default
-
inline ~StateGridInfo()
-
StateGridInfo &operator=(const StateGridInfo&) = default
-
StateGridInfo &operator=(StateGridInfo&&) = default
-
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
-
inline size_t GetKey(int state_id) const
-
inline size_t GetKey(char symbol) const
Protected Attributes
-
struct StateInfo
- #include <StateGrid.hpp>
Information about what a particular state type means in a state grid.
-
inline StateGridInfo()
-
class StateGrid
- #include <StateGrid.hpp>
A StateGrid describes a map of grid positions to the current state of each position.
Public Functions
-
inline StateGrid()
-
inline StateGrid(StateGridInfo &_i, size_t _w = 1, size_t _h = 1, int init_val = 0)
-
inline StateGrid(StateGridInfo &_i, const std::string &filename)
-
inline ~StateGrid()
-
inline size_t GetWidth() const
-
inline size_t GetHeight() const
-
inline size_t GetSize() const
-
inline const StateGridInfo &GetInfo() const
-
inline int &operator()(size_t x, size_t y)
-
inline int operator()(size_t x, size_t y) const
-
inline int GetState(size_t x, size_t y) const
-
inline int GetState(size_t id) const
-
inline char GetSymbol(size_t x, size_t y) const
-
inline double GetScoreChange(size_t x, size_t y) const
-
inline BitVector IsState(int target_state)
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.
-
inline StateGrid()
-
class StateGridStatus
- #include <StateGrid.hpp>
Information about a particular agent on a state grid.
Public Functions
-
inline StateGridStatus()
-
StateGridStatus(const StateGridStatus&) = default
-
StateGridStatus(StateGridStatus&&) = default
-
StateGridStatus &operator=(const StateGridStatus&) = default
-
StateGridStatus &operator=(StateGridStatus&&) = default
-
inline size_t GetX() const
-
inline size_t GetY() const
-
inline size_t GetFacing() const
-
inline bool IsAt(size_t x, size_t y) const
-
inline bool WasAt(size_t x, size_t y) const
-
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(size_t _x, size_t _y, size_t _f)
-
inline StateGridStatus &SetX(size_t _x)
-
inline StateGridStatus &SetY(size_t _y)
-
inline StateGridStatus &SetPos(size_t _x, size_t _y)
-
inline StateGridStatus &SetFacing(size_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?
-
inline StateGridStatus()