HOG2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SnakeBird::SnakeBird Class Reference

#include <SnakeBird.h>

Inheritance diagram for SnakeBird::SnakeBird:
Inheritance graph
[legend]
Collaboration diagram for SnakeBird::SnakeBird:
Collaboration graph
[legend]

Public Member Functions

 SnakeBird (int width=20, int height=16)
 Construct SnakeBird class. More...
 
void Reset ()
 Reset to initial state and default 20(w)x16(h) map size. More...
 
void BiggerMapHeight ()
 
void BiggerMapWidth ()
 
void SmallerMapHeight ()
 
void SmallerMapWidth ()
 
bool Load (const char *filename)
 Load a map from a filename. More...
 
bool Save (const char *filename)
 Currently not supported. More...
 
std::string EncodeLevel () const
 Convert an ASCII map encoding back to a level. More...
 
bool DecodeLevel (const std::string &)
 Convert a map to an ASCII string. More...
 
void BeginEditing ()
 Before the map is changed, this should be called. More...
 
void EndEditing ()
 Stop editing the map & apply optimizations to internal data structures. More...
 
SnakeBirdState GetStart () const
 The SnakeBird start location and fruit consumption returned is part of the dynamic state. More...
 
void SetStart (const SnakeBirdState &)
 Set the initial state of the game. More...
 
void AddSnake (int x, int y, const std::vector< snakeDir > &body)
 Add a snake to the level at a given location. More...
 
void AddSnakeHead (int x, int y, int whichSnake)
 
snakeDir GetAddingDirection (int x, int y, int endX, int endY)
 
void AddSnakeBody (int x, int y, int whichSnake)
 
void RemoveSnake (int x, int y, int o, int whichSnake)
 
void SetGroundType (int x, int y, SnakeBirdWorldObject o)
 Change the ground type to a new type. More...
 
void RemoveBlock (int x, int y)
 Similar to SetGroundType but only deals with removing blocks. More...
 
int GetNumPortals ()
 
SnakeBirdWorldObject GetGroundType (int x, int y) const
 Return the primary ground type in the map. More...
 
SnakeBirdWorldObject GetRenderedGroundType (const SnakeBirdState &s, int x, int y)
 Return the rendered ground type on the screen - eg accounting for snakes, moving objects, etc. More...
 
int GetWidth () const
 
int GetHeight () const
 
void GetSuccessors (const SnakeBirdState &nodeID, std::vector< SnakeBirdState > &neighbors) const
 Return (via references) all of the legal actions in a state. More...
 
void GetActions (const SnakeBirdState &nodeID, std::vector< SnakeBirdAction > &actions) const
 Return (by reference) the legal actions in a state. More...
 
bool LivingState (const SnakeBirdState &s) const
 
size_t GetNumFruit ()
 
void ApplyAction (SnakeBirdState &s, SnakeBirdAction a) const
 Apply a single action, modifying to the next state. More...
 
bool ApplyPartialAction (SnakeBirdState &s, SnakeBirdAction a, SnakeBirdAnimationStep &step) const
 Do next step of animation. More...
 
bool Legal (SnakeBirdState &s, SnakeBirdAction a)
 Return whether an action is legal. More...
 
void UndoAction (SnakeBirdState &s, SnakeBirdAction a) const
 
void GetNextState (const SnakeBirdState &s1, SnakeBirdAction a, SnakeBirdState &s2) const
 
bool InvertAction (SnakeBirdAction &a) const
 
void StoreGoal (SnakeBirdState &s)
 Stores the goal for use by single-state HCost. More...
 
void ClearGoal ()
 Clears the goal from memory. More...
 
bool IsGoalStored () const
 Returns true if the goal is stored and false otherwise. More...
 
double HCost (const SnakeBirdState &node1, const SnakeBirdState &node2) const
 Heuristic value between two arbitrary nodes. More...
 
double GCost (const SnakeBirdState &node1, const SnakeBirdState &node2) const
 
double GCost (const SnakeBirdState &node, const SnakeBirdAction &act) const
 
bool GoalTest (const SnakeBirdState &node, const SnakeBirdState &goal) const
 
virtual bool GoalTest (const SnakeBirdState &node) const
 Goal Test if the goal is stored. More...
 
uint64_t GetActionHash (SnakeBirdAction act) const
 
uint64_t GetStateHash (const SnakeBirdState &node) const
 
void OpenGLDraw () const
 
void OpenGLDraw (const SnakeBirdState &) const
 
void OpenGLDraw (const SnakeBirdState &, const SnakeBirdState &, float) const
 Draw the transition at some percentage 0...1 between two states. More...
 
void OpenGLDraw (const SnakeBirdState &, const SnakeBirdAction &) const
 
void GLLabelState (const SnakeBirdState &, const char *) const
 
void GLDrawLine (const SnakeBirdState &x, const SnakeBirdState &y) const
 
void GLDrawPath (const std::vector< SnakeBirdState > &x) const
 
void Draw (Graphics::Display &display) const
 
void DrawObjects (Graphics::Display &display, double time=0) const
 
void DrawObject (Graphics::Display &display, int x, int y, SnakeBirdWorldObject o, double time=0) const
 
void Draw (Graphics::Display &display, int x, int y, float width=1.0) const
 
void Draw (Graphics::Display &display, double time) const
 
void Draw (Graphics::Display &display, const SnakeBirdState &) const
 
void Draw (Graphics::Display &display, const SnakeBirdState &, int active) const
 
void Draw (Graphics::Display &display, const SnakeBirdState &, int active, double globalTime) const
 
void Draw (Graphics::Display &display, const SnakeBirdState &, const SnakeBirdState &, int active, double percentComplete, double globalTime) const
 
void DrawLine (Graphics::Display &display, const SnakeBirdState &x, const SnakeBirdState &y, float width=1.0) const
 
void DrawLabel (Graphics::Display &display, int x, int y, const char *str)
 
void DrawSmallLabel (Graphics::Display &display, int x, int y, const char *str)
 
float GetRadius () const
 
bool GetPointFromCoordinate (Graphics::point p, int &x, int &y)
 
int GetIndex (int x, int y) const
 
int GetX (int index) const
 
int GetY (int index) const
 
- Public Member Functions inherited from SearchEnvironment< SnakeBirdState, SnakeBirdAction >
virtual ~SearchEnvironment ()
 
virtual void GetSuccessors (const SnakeBirdState &nodeID, std::vector< SnakeBirdState > &neighbors) const=0
 
virtual void GetActions (const SnakeBirdState &nodeID, std::vector< SnakeBirdAction > &actions) const=0
 
virtual int GetNumSuccessors (const SnakeBirdState &stateID) const
 
virtual SnakeBirdAction GetAction (const SnakeBirdState &s1, const SnakeBirdState &s2) const
 
virtual void ApplyAction (SnakeBirdState &s, SnakeBirdAction a) const=0
 
virtual void UndoAction (SnakeBirdState &s, SnakeBirdAction a) const
 
virtual void GetNextState (const SnakeBirdState &s1, SnakeBirdAction a, SnakeBirdState &s2) const
 
virtual bool InvertAction (SnakeBirdAction &a) const=0
 
virtual void StoreGoal (SnakeBirdState &s)
 Stores the goal for use by single-state HCost. More...
 
virtual bool IsGoalStored () const
 Returns true if the goal is stored and false otherwise. More...
 
virtual double HCost (const SnakeBirdState &node1, const SnakeBirdState &node2) const=0
 Heuristic value between two arbitrary nodes. More...
 
virtual double HCost (const SnakeBirdState &node1, const SnakeBirdState &node2, double parentHCost) const
 
virtual double HCost (const SnakeBirdState &node) const
 Heuristic value between node and the stored goal. More...
 
virtual double GCost (const SnakeBirdState &node1, const SnakeBirdState &node2) const=0
 
virtual double GCost (const SnakeBirdState &node, const SnakeBirdAction &act) const=0
 
virtual bool GoalTest (const SnakeBirdState &node, const SnakeBirdState &goal) const=0
 
virtual bool GoalTest (const SnakeBirdState &node) const
 Goal Test if the goal is stored. More...
 
virtual uint64_t GetMaxHash () const
 
virtual uint64_t GetStateHash (const SnakeBirdState &node) const=0
 
virtual void GetStateFromHash (uint64_t parent, SnakeBirdState &s) const
 
virtual uint64_t GetActionHash (SnakeBirdAction act) const=0
 
virtual double GetPathLength (std::vector< SnakeBirdState > &neighbors)
 
virtual double GetPathLength (const SnakeBirdState &start, std::vector< SnakeBirdAction > &neighbors)
 
virtual OccupancyInterface< SnakeBirdState, SnakeBirdAction > * GetOccupancyInfo ()
 
virtual void SetOccupancyInfo (OccupancyInterface< SnakeBirdState, SnakeBirdAction > *)
 
virtual void OpenGLDraw () const
 
virtual void OpenGLDraw (const SnakeBirdState &) const
 
virtual void OpenGLDraw (const SnakeBirdState &, const SnakeBirdState &, float) const
 Draw the transition at some percentage 0...1 between two states. More...
 
virtual void OpenGLDraw (const SnakeBirdState &, const SnakeBirdAction &) const
 
virtual void GLLabelState (const SnakeBirdState &, const char *) const
 
virtual void GLDrawLine (const SnakeBirdState &x, const SnakeBirdState &y) const
 
virtual void GLDrawPath (const std::vector< SnakeBirdState > &x) const
 
virtual void SetColor (const rgbColor &r) const
 
virtual void SetColor (GLfloat rr, GLfloat g, GLfloat b, GLfloat t=1.0) const
 
virtual void GetColor (GLfloat &rr, GLfloat &g, GLfloat &b, GLfloat &t) const
 
virtual rgbColor GetColor () const
 
virtual void Draw (Graphics::Display &display, const SnakeBirdState &) const
 
virtual void DrawLine (Graphics::Display &display, const SnakeBirdState &x, const SnakeBirdState &y, float width=1.0) const
 
- Public Member Functions inherited from Heuristic< SnakeBirdState >
 Heuristic ()
 
virtual ~Heuristic ()
 

Private Member Functions

std::string Code (int) const
 
int DeCode (const std::string &s, size_t offset) const
 
void SetGroundType (int index, SnakeBirdWorldObject o)
 
bool Render (const SnakeBirdState &s) const
 
bool CanPush (const SnakeBirdState &s, int snake, SnakeBirdWorldObject obj, snakeDir dir, SnakeBirdAction &a) const
 Can the snake push the given object in the given direction? More...
 
bool IsOnSpikes (const SnakeBirdState &s, int which) const
 
TeleportResult HandleTeleports (SnakeBirdState &s, SnakeBirdAction &a, snakeDir lastAction, snakeDir opposite, SnakeBirdAnimationStep step) const
 
SnakeBirdAnimation DoFirstMovement (const SnakeBirdAction &a, int offset, snakeDir opposite, SnakeBirdState &s) const
 
SnakeBirdAnimation DoFall (SnakeBirdAction &a, SnakeBirdState &s) const
 
int GetFruitOffset (int index) const
 
int Distance (int index1, int index2)
 
Graphics::point GetCenter (int x, int y) const
 
void DrawSnakeEnteringGoal (Graphics::Display &display, const SnakeBirdState &s, int snake, bool isActive, double percentComplete) const
 
void DrawTranslatingSnake (Graphics::Display &display, const SnakeBirdState &old, const SnakeBirdState &s, int snake, bool isActive, double percentComplete) const
 
void DrawMovingSnake (Graphics::Display &display, const SnakeBirdState &old, const SnakeBirdState &s, int snake, bool isActive, double percentComplete) const
 
void DrawSnakeSegment (Graphics::Display &display, Graphics::point p, const rgbColor &color, bool head, bool tail, bool awake, snakeDir dirFrom, snakeDir dirTo, int whichSnake, bool isDead) const
 

Private Attributes

int width
 
int height
 
std::array< SnakeBirdWorldObject, 512 > world
 
std::array< SnakeBirdWorldObject, 512 > render
 
std::vector< int > fruit
 
std::array< std::vector< int >, 4 > objects
 
std::array< bool, 4 > objectFullyConnected
 
int portal1Loc
 
int portal2Loc
 
int exitLoc
 
SnakeBirdState startState
 
bool editing
 

Additional Inherited Members

- Public Attributes inherited from Heuristic< SnakeBirdState >
std::vector< HeuristicTreeNodelookups
 
std::vector< Heuristic * > heuristics
 
uint64_t histogram [256]
 
- Protected Attributes inherited from SearchEnvironment< SnakeBirdState, SnakeBirdAction >
bool bValidSearchGoal
 
SnakeBirdState searchGoal
 
rgbColor color
 
GLfloat transparency
 

Detailed Description

Definition at line 280 of file SnakeBird.h.

Constructor & Destructor Documentation

◆ SnakeBird()

SnakeBird::SnakeBird::SnakeBird ( int  width = 20,
int  height = 16 
)

Construct SnakeBird class.

Note that width and height are currently fixed and can't be changed. Eventually this should be fixed.

Definition at line 21 of file SnakeBird.cpp.

References height, SnakeBird::kEmpty, SnakeBird::kSpikes, and width.

Member Function Documentation

◆ AddSnake()

void SnakeBird::SnakeBird::AddSnake ( int  x,
int  y,
const std::vector< snakeDir > &  body 
)

Add a snake to the level at a given location.

Note: Will need to be enhanced to set location of a particular snake.

Definition at line 519 of file SnakeBird.cpp.

References SnakeBird::SnakeBirdState::GetNumSnakes().

◆ AddSnakeBody()

void SnakeBird::SnakeBird::AddSnakeBody ( int  x,
int  y,
int  whichSnake 
)

◆ AddSnakeHead()

void SnakeBird::SnakeBird::AddSnakeHead ( int  x,
int  y,
int  whichSnake 
)

Definition at line 529 of file SnakeBird.cpp.

References height, and width.

◆ ApplyAction()

void SnakeBird::SnakeBird::ApplyAction ( SnakeBirdState s,
SnakeBirdAction  a 
) const

◆ ApplyPartialAction()

bool SnakeBird::SnakeBird::ApplyPartialAction ( SnakeBirdState s,
SnakeBirdAction  act,
SnakeBirdAnimationStep step 
) const

◆ BeginEditing()

void SnakeBird::SnakeBird::BeginEditing ( )

Before the map is changed, this should be called.

It allows for internal optimizations after editing ends.

Definition at line 468 of file SnakeBird.cpp.

◆ BiggerMapHeight()

void SnakeBird::SnakeBird::BiggerMapHeight ( )

Definition at line 49 of file SnakeBird.cpp.

References height, SnakeBird::kEmpty, and width.

◆ BiggerMapWidth()

void SnakeBird::SnakeBird::BiggerMapWidth ( )

Definition at line 207 of file SnakeBird.cpp.

References height, and width.

◆ CanPush()

bool SnakeBird::SnakeBird::CanPush ( const SnakeBirdState s,
int  snake,
SnakeBirdWorldObject  obj,
snakeDir  dir,
SnakeBirdAction a 
) const
private

◆ ClearGoal()

void SnakeBird::SnakeBird::ClearGoal ( )
inlinevirtual

Clears the goal from memory.

Reimplemented from SearchEnvironment< SnakeBirdState, SnakeBirdAction >.

Definition at line 337 of file SnakeBird.h.

◆ Code()

std::string SnakeBird::SnakeBird::Code ( int  v) const
private

Definition at line 1001 of file SnakeBird.cpp.

◆ DeCode()

int SnakeBird::SnakeBird::DeCode ( const std::string &  s,
size_t  offset 
) const
private

Definition at line 1015 of file SnakeBird.cpp.

References SnakeBird::codeSize.

◆ DecodeLevel()

bool SnakeBird::SnakeBird::DecodeLevel ( const std::string &  encoding)

◆ Distance()

int SnakeBird::SnakeBird::Distance ( int  index1,
int  index2 
)
private

Definition at line 2535 of file SnakeBird.cpp.

References GetX(), and GetY().

◆ DoFall()

SnakeBirdAnimation SnakeBird::SnakeBird::DoFall ( SnakeBirdAction a,
SnakeBirdState s 
) const
private

◆ DoFirstMovement()

SnakeBirdAnimation SnakeBird::SnakeBird::DoFirstMovement ( const SnakeBirdAction a,
int  offset,
snakeDir  opposite,
SnakeBirdState s 
) const
private

◆ Draw() [1/7]

void SnakeBird::SnakeBird::Draw ( Graphics::Display display) const
virtual

◆ Draw() [2/7]

void SnakeBird::SnakeBird::Draw ( Graphics::Display display,
const SnakeBirdState s 
) const

Definition at line 2922 of file SnakeBird.cpp.

◆ Draw() [3/7]

void SnakeBird::SnakeBird::Draw ( Graphics::Display display,
const SnakeBirdState old,
const SnakeBirdState s,
int  active,
double  percentComplete,
double  globalTime 
) const

◆ Draw() [4/7]

void SnakeBird::SnakeBird::Draw ( Graphics::Display display,
const SnakeBirdState s,
int  active 
) const

Definition at line 2927 of file SnakeBird.cpp.

◆ Draw() [5/7]

void SnakeBird::SnakeBird::Draw ( Graphics::Display display,
const SnakeBirdState s,
int  active,
double  globalTime 
) const

Definition at line 3288 of file SnakeBird.cpp.

◆ Draw() [6/7]

void SnakeBird::SnakeBird::Draw ( Graphics::Display display,
double  time 
) const

◆ Draw() [7/7]

void SnakeBird::SnakeBird::Draw ( Graphics::Display display,
int  x,
int  y,
float  width = 1.0 
) const

Definition at line 2544 of file SnakeBird.cpp.

References Graphics::Display::FrameRect(), Colors::GetColor(), and width.

◆ DrawLabel()

void SnakeBird::SnakeBird::DrawLabel ( Graphics::Display display,
int  x,
int  y,
const char *  str 
)

◆ DrawLine()

void SnakeBird::SnakeBird::DrawLine ( Graphics::Display display,
const SnakeBirdState x,
const SnakeBirdState y,
float  width = 1.0 
) const

Definition at line 3396 of file SnakeBird.cpp.

◆ DrawMovingSnake()

void SnakeBird::SnakeBird::DrawMovingSnake ( Graphics::Display display,
const SnakeBirdState old,
const SnakeBirdState s,
int  snake,
bool  isActive,
double  percentComplete 
) const
private

◆ DrawObject()

void SnakeBird::SnakeBird::DrawObject ( Graphics::Display display,
int  x,
int  y,
SnakeBirdWorldObject  o,
double  time = 0 
) const

◆ DrawObjects()

void SnakeBird::SnakeBird::DrawObjects ( Graphics::Display display,
double  time = 0 
) const

◆ DrawSmallLabel()

void SnakeBird::SnakeBird::DrawSmallLabel ( Graphics::Display display,
int  x,
int  y,
const char *  str 
)

◆ DrawSnakeEnteringGoal()

void SnakeBird::SnakeBird::DrawSnakeEnteringGoal ( Graphics::Display display,
const SnakeBirdState s,
int  snake,
bool  isActive,
double  percentComplete 
) const
private

◆ DrawSnakeSegment()

void SnakeBird::SnakeBird::DrawSnakeSegment ( Graphics::Display display,
Graphics::point  p,
const rgbColor color,
bool  head,
bool  tail,
bool  awake,
snakeDir  dirFrom,
snakeDir  dirTo,
int  whichSnake,
bool  isDead 
) const
private

◆ DrawTranslatingSnake()

void SnakeBird::SnakeBird::DrawTranslatingSnake ( Graphics::Display display,
const SnakeBirdState old,
const SnakeBirdState s,
int  snake,
bool  isActive,
double  percentComplete 
) const
private

◆ EncodeLevel()

std::string SnakeBird::SnakeBird::EncodeLevel ( ) const

Convert an ASCII map encoding back to a level.

Definition at line 1060 of file SnakeBird.cpp.

References GetX(), GetY(), height, SnakeBird::kDown, SnakeBird::kGround, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kSpikes, SnakeBird::kUp, and width.

◆ EndEditing()

void SnakeBird::SnakeBird::EndEditing ( )

Stop editing the map & apply optimizations to internal data structures.

Definition at line 476 of file SnakeBird.cpp.

◆ GCost() [1/2]

double SnakeBird::SnakeBird::GCost ( const SnakeBirdState node,
const SnakeBirdAction act 
) const
inline

Definition at line 348 of file SnakeBird.h.

◆ GCost() [2/2]

double SnakeBird::SnakeBird::GCost ( const SnakeBirdState node1,
const SnakeBirdState node2 
) const
inline

Definition at line 347 of file SnakeBird.h.

◆ GetActionHash()

uint64_t SnakeBird::SnakeBird::GetActionHash ( SnakeBirdAction  act) const
inline

◆ GetActions()

void SnakeBird::SnakeBird::GetActions ( const SnakeBirdState nodeID,
std::vector< SnakeBirdAction > &  actions 
) const

◆ GetAddingDirection()

snakeDir SnakeBird::SnakeBird::GetAddingDirection ( int  x,
int  y,
int  endX,
int  endY 
)

◆ GetCenter()

Graphics::point SnakeBird::SnakeBird::GetCenter ( int  x,
int  y 
) const
private

Definition at line 2909 of file SnakeBird.cpp.

References Graphics::point::x, and Graphics::point::y.

◆ GetFruitOffset()

int SnakeBird::SnakeBird::GetFruitOffset ( int  index) const
private

Definition at line 2487 of file SnakeBird.cpp.

◆ GetGroundType()

SnakeBirdWorldObject SnakeBird::SnakeBird::GetGroundType ( int  x,
int  y 
) const

Return the primary ground type in the map.

Definition at line 2500 of file SnakeBird.cpp.

◆ GetHeight()

int SnakeBird::SnakeBird::GetHeight ( ) const
inline

Definition at line 309 of file SnakeBird.h.

References height.

◆ GetIndex()

int SnakeBird::SnakeBird::GetIndex ( int  x,
int  y 
) const

Definition at line 2520 of file SnakeBird.cpp.

References height.

◆ GetNextState()

void SnakeBird::SnakeBird::GetNextState ( const SnakeBirdState s1,
SnakeBirdAction  a,
SnakeBirdState s2 
) const
inline

Definition at line 324 of file SnakeBird.h.

◆ GetNumFruit()

size_t SnakeBird::SnakeBird::GetNumFruit ( )
inline

Definition at line 314 of file SnakeBird.h.

◆ GetNumPortals()

int SnakeBird::SnakeBird::GetNumPortals ( )

Definition at line 2473 of file SnakeBird.cpp.

◆ GetPointFromCoordinate()

bool SnakeBird::SnakeBird::GetPointFromCoordinate ( Graphics::point  p,
int &  x,
int &  y 
)

Definition at line 2900 of file SnakeBird.cpp.

References height, Graphics::point::x, and Graphics::point::y.

◆ GetRadius()

float SnakeBird::SnakeBird::GetRadius ( ) const

Definition at line 2917 of file SnakeBird.cpp.

References height, max, and width.

◆ GetRenderedGroundType()

SnakeBirdWorldObject SnakeBird::SnakeBird::GetRenderedGroundType ( const SnakeBirdState s,
int  x,
int  y 
)

Return the rendered ground type on the screen - eg accounting for snakes, moving objects, etc.

Definition at line 2508 of file SnakeBird.cpp.

References SnakeBird::kEmpty, and SnakeBird::kExit.

◆ GetStart()

SnakeBirdState SnakeBird::SnakeBird::GetStart ( ) const

The SnakeBird start location and fruit consumption returned is part of the dynamic state.

Everything inside the SnakeBird class is static. The location of the fruit is static; whether it's been eaten is dynamic.

Definition at line 501 of file SnakeBird.cpp.

◆ GetStateHash()

uint64_t SnakeBird::SnakeBird::GetStateHash ( const SnakeBirdState node) const
inline

Definition at line 356 of file SnakeBird.h.

◆ GetSuccessors()

void SnakeBird::SnakeBird::GetSuccessors ( const SnakeBirdState nodeID,
std::vector< SnakeBirdState > &  neighbors 
) const

Return (via references) all of the legal actions in a state.

Definition at line 1296 of file SnakeBird.cpp.

References SnakeBird::SnakeBirdState::GetNumSnakes(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), and SnakeBird::kDead.

◆ GetWidth()

int SnakeBird::SnakeBird::GetWidth ( ) const
inline

Definition at line 308 of file SnakeBird.h.

References width.

◆ GetX()

int SnakeBird::SnakeBird::GetX ( int  index) const

Definition at line 2525 of file SnakeBird.cpp.

References height.

◆ GetY()

int SnakeBird::SnakeBird::GetY ( int  index) const

Definition at line 2530 of file SnakeBird.cpp.

References height.

◆ GLDrawLine()

void SnakeBird::SnakeBird::GLDrawLine ( const SnakeBirdState x,
const SnakeBirdState y 
) const
inline

Definition at line 368 of file SnakeBird.h.

◆ GLDrawPath()

void SnakeBird::SnakeBird::GLDrawPath ( const std::vector< SnakeBirdState > &  x) const
inline

Definition at line 369 of file SnakeBird.h.

◆ GLLabelState()

void SnakeBird::SnakeBird::GLLabelState ( const SnakeBirdState ,
const char *   
) const
inline

Definition at line 367 of file SnakeBird.h.

◆ GoalTest() [1/2]

virtual bool SnakeBird::SnakeBird::GoalTest ( const SnakeBirdState node) const
inlinevirtual

Goal Test if the goal is stored.

Definition at line 352 of file SnakeBird.h.

References SnakeBird::kInGoal.

◆ GoalTest() [2/2]

bool SnakeBird::SnakeBird::GoalTest ( const SnakeBirdState node,
const SnakeBirdState goal 
) const
inline

Definition at line 349 of file SnakeBird.h.

References GoalTest().

Referenced by GoalTest().

◆ HandleTeleports()

TeleportResult SnakeBird::SnakeBird::HandleTeleports ( SnakeBirdState s,
SnakeBirdAction a,
snakeDir  lastAction,
snakeDir  opposite,
SnakeBirdAnimationStep  step 
) const
private

◆ HCost()

double SnakeBird::SnakeBird::HCost ( const SnakeBirdState node1,
const SnakeBirdState node2 
) const
inline

Heuristic value between two arbitrary nodes.

Definition at line 345 of file SnakeBird.h.

◆ InvertAction()

bool SnakeBird::SnakeBird::InvertAction ( SnakeBirdAction a) const
inline

Definition at line 330 of file SnakeBird.h.

◆ IsGoalStored()

bool SnakeBird::SnakeBird::IsGoalStored ( ) const
inline

Returns true if the goal is stored and false otherwise.

Definition at line 341 of file SnakeBird.h.

◆ IsOnSpikes()

bool SnakeBird::SnakeBird::IsOnSpikes ( const SnakeBirdState s,
int  which 
) const
private

◆ Legal()

bool SnakeBird::SnakeBird::Legal ( SnakeBirdState s,
SnakeBirdAction  a 
)

Return whether an action is legal.

Definition at line 1336 of file SnakeBird.cpp.

◆ LivingState()

bool SnakeBird::SnakeBird::LivingState ( const SnakeBirdState s) const
inline

Definition at line 313 of file SnakeBird.h.

◆ Load()

bool SnakeBird::SnakeBird::Load ( const char *  filename)

◆ OpenGLDraw() [1/4]

void SnakeBird::SnakeBird::OpenGLDraw ( ) const
inline

Definition at line 362 of file SnakeBird.h.

◆ OpenGLDraw() [2/4]

void SnakeBird::SnakeBird::OpenGLDraw ( const SnakeBirdState ) const
inline

Definition at line 363 of file SnakeBird.h.

◆ OpenGLDraw() [3/4]

void SnakeBird::SnakeBird::OpenGLDraw ( const SnakeBirdState ,
const SnakeBirdAction  
) const
inline

Definition at line 366 of file SnakeBird.h.

◆ OpenGLDraw() [4/4]

void SnakeBird::SnakeBird::OpenGLDraw ( const SnakeBirdState ,
const SnakeBirdState ,
float   
) const
inline

Draw the transition at some percentage 0...1 between two states.

Definition at line 365 of file SnakeBird.h.

◆ RemoveBlock()

void SnakeBird::SnakeBird::RemoveBlock ( int  x,
int  y 
)

Similar to SetGroundType but only deals with removing blocks.

Definition at line 2295 of file SnakeBird.cpp.

References GetX(), GetY(), height, min(), and width.

◆ RemoveSnake()

void SnakeBird::SnakeBird::RemoveSnake ( int  x,
int  y,
int  o,
int  whichSnake 
)

◆ Render()

bool SnakeBird::SnakeBird::Render ( const SnakeBirdState s) const
private

◆ Reset()

void SnakeBird::SnakeBird::Reset ( )

Reset to initial state and default 20(w)x16(h) map size.

Definition at line 34 of file SnakeBird.cpp.

References height, SnakeBird::kEmpty, SnakeBird::kSpikes, and width.

◆ Save()

bool SnakeBird::SnakeBird::Save ( const char *  filename)

Currently not supported.

Definition at line 996 of file SnakeBird.cpp.

◆ SetGroundType() [1/2]

void SnakeBird::SnakeBird::SetGroundType ( int  index,
SnakeBirdWorldObject  o 
)
private

Definition at line 2287 of file SnakeBird.cpp.

References GetX(), and GetY().

◆ SetGroundType() [2/2]

void SnakeBird::SnakeBird::SetGroundType ( int  x,
int  y,
SnakeBirdWorldObject  o 
)

◆ SetStart()

void SnakeBird::SnakeBird::SetStart ( const SnakeBirdState start)

Set the initial state of the game.

Definition at line 509 of file SnakeBird.cpp.

◆ SmallerMapHeight()

void SnakeBird::SnakeBird::SmallerMapHeight ( )

◆ SmallerMapWidth()

void SnakeBird::SnakeBird::SmallerMapWidth ( )

◆ StoreGoal()

void SnakeBird::SnakeBird::StoreGoal ( SnakeBirdState s)
inline

Stores the goal for use by single-state HCost.

Definition at line 333 of file SnakeBird.h.

◆ UndoAction()

void SnakeBird::SnakeBird::UndoAction ( SnakeBirdState s,
SnakeBirdAction  a 
) const
inline

Definition at line 321 of file SnakeBird.h.

Member Data Documentation

◆ editing

bool SnakeBird::SnakeBird::editing
private

Definition at line 437 of file SnakeBird.h.

◆ exitLoc

int SnakeBird::SnakeBird::exitLoc
private

Definition at line 435 of file SnakeBird.h.

◆ fruit

std::vector<int> SnakeBird::SnakeBird::fruit
private

Definition at line 430 of file SnakeBird.h.

◆ height

int SnakeBird::SnakeBird::height
private

Definition at line 425 of file SnakeBird.h.

◆ objectFullyConnected

std::array<bool, 4> SnakeBird::SnakeBird::objectFullyConnected
private

Definition at line 433 of file SnakeBird.h.

◆ objects

std::array<std::vector<int>, 4> SnakeBird::SnakeBird::objects
private

Definition at line 432 of file SnakeBird.h.

◆ portal1Loc

int SnakeBird::SnakeBird::portal1Loc
private

Definition at line 434 of file SnakeBird.h.

◆ portal2Loc

int SnakeBird::SnakeBird::portal2Loc
private

Definition at line 434 of file SnakeBird.h.

◆ render

std::array<SnakeBirdWorldObject, 512> SnakeBird::SnakeBird::render
mutableprivate

Definition at line 428 of file SnakeBird.h.

◆ startState

SnakeBirdState SnakeBird::SnakeBird::startState
private

Definition at line 436 of file SnakeBird.h.

◆ width

int SnakeBird::SnakeBird::width
private

Definition at line 425 of file SnakeBird.h.

◆ world

std::array<SnakeBirdWorldObject, 512> SnakeBird::SnakeBird::world
private

Definition at line 427 of file SnakeBird.h.


The documentation for this class was generated from the following files: