HOG2
|
#include <SnakeBird.h>
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< HeuristicTreeNode > | lookups |
std::vector< Heuristic * > | heuristics |
uint64_t | histogram [256] |
Protected Attributes inherited from SearchEnvironment< SnakeBirdState, SnakeBirdAction > | |
bool | bValidSearchGoal |
SnakeBirdState | searchGoal |
rgbColor | color |
GLfloat | transparency |
Definition at line 280 of file SnakeBird.h.
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.
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().
void SnakeBird::SnakeBird::AddSnakeBody | ( | int | x, |
int | y, | ||
int | whichSnake | ||
) |
Definition at line 561 of file SnakeBird.cpp.
References GetX(), GetY(), height, SnakeBird::kDown, SnakeBird::kLeft, SnakeBird::kNoDirection, SnakeBird::kRight, SnakeBird::kUp, and width.
void SnakeBird::SnakeBird::AddSnakeHead | ( | int | x, |
int | y, | ||
int | whichSnake | ||
) |
Definition at line 529 of file SnakeBird.cpp.
void SnakeBird::SnakeBird::ApplyAction | ( | SnakeBirdState & | s, |
SnakeBirdAction | a | ||
) | const |
Apply a single action, modifying to the next state.
Definition at line 1950 of file SnakeBird.cpp.
References SnakeBird::SnakeBirdAnimationStep::anim, SnakeBird::SnakeBirdAction::bird, SnakeBird::SnakeBirdAction::direction, SnakeBird::SnakeBirdState::GetNumSnakes(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), height, SnakeBird::kDead, SnakeBird::kDoneAnimation, SnakeBird::kDown, SnakeBird::kExit, SnakeBird::kFall, SnakeBird::kFellInGoal, SnakeBird::SnakeBirdState::KFruitEaten(), SnakeBird::kInGoal, SnakeBird::kInitialTeleport, SnakeBird::kLeft, SnakeBird::kMovement, SnakeBird::kRight, SnakeBird::kTeleport, SnakeBird::kTeleportSuccess, SnakeBird::kTeleportToExit, SnakeBird::kUp, SnakeBird::kWentInGoal, SnakeBird::SnakeBirdAction::pushed, SnakeBird::SnakeBirdState::SetSnakeHeadLoc(), and SnakeBird::SnakeBirdAnimationStep::teleportCount.
bool SnakeBird::SnakeBird::ApplyPartialAction | ( | SnakeBirdState & | s, |
SnakeBirdAction | act, | ||
SnakeBirdAnimationStep & | step | ||
) | const |
Do next step of animation.
Call until true is returned (when action is fully applied).
Definition at line 1814 of file SnakeBird.cpp.
References SnakeBird::SnakeBirdAnimationStep::a, SnakeBird::SnakeBirdAnimationStep::anim, SnakeBird::SnakeBirdAnimationStep::animationDuration, SnakeBird::SnakeBirdAction::bird, SnakeBird::SnakeBirdAction::direction, SnakeBird::SnakeBirdState::GetNumSnakes(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), SnakeBird::SnakeBirdState::GetSnakeLength(), height, SnakeBird::kDead, SnakeBird::kDoneAnimation, SnakeBird::kDown, SnakeBird::kExit, SnakeBird::kFall, SnakeBird::kFellInGoal, SnakeBird::SnakeBirdState::KFruitEaten(), SnakeBird::kInGoal, SnakeBird::kInitialTeleport, SnakeBird::kLeft, SnakeBird::kMovement, SnakeBird::kNeedsInitialization, SnakeBird::kPauseWhenDead, SnakeBird::kRight, SnakeBird::kTeleport, SnakeBird::kTeleportSuccess, SnakeBird::kTeleportToExit, SnakeBird::kUp, SnakeBird::kWentInGoal, SnakeBird::SnakeBirdAction::pushed, SnakeBird::SnakeBirdState::SetSnakeHeadLoc(), and SnakeBird::SnakeBirdAnimationStep::teleportCount.
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.
void SnakeBird::SnakeBird::BiggerMapHeight | ( | ) |
Definition at line 49 of file SnakeBird.cpp.
References height, SnakeBird::kEmpty, and width.
void SnakeBird::SnakeBird::BiggerMapWidth | ( | ) |
Definition at line 207 of file SnakeBird.cpp.
|
private |
Can the snake push the given object in the given direction?
s | The current state of the game |
snake | The snake pushing |
obj | The object being pushed |
dir | The direction it is pushed |
a | The final action, which will contain the objects being used |
Definition at line 1549 of file SnakeBird.cpp.
References SnakeBird::SnakeBirdState::GetObjectLocation(), SnakeBird::SnakeBirdState::GetSnakeBodyEnd(), SnakeBird::SnakeBirdState::GetSnakeDir(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), GetX(), GetY(), height, SnakeBird::kBlock1, SnakeBird::kBlock2, SnakeBird::kBlock3, SnakeBird::kBlock4, SnakeBird::kBlockMask, SnakeBird::kDead, SnakeBird::kDown, SnakeBird::kFruit, SnakeBird::kGround, SnakeBird::kGroundMask, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kSnake1, SnakeBird::kSnake2, SnakeBird::kSnake3, SnakeBird::kSnake4, SnakeBird::kSnakeMask, SnakeBird::kUp, SnakeBird::SnakeBirdAction::pushed, and width.
|
inlinevirtual |
Clears the goal from memory.
Reimplemented from SearchEnvironment< SnakeBirdState, SnakeBirdAction >.
Definition at line 337 of file SnakeBird.h.
|
private |
Definition at line 1001 of file SnakeBird.cpp.
|
private |
Definition at line 1015 of file SnakeBird.cpp.
References SnakeBird::codeSize.
bool SnakeBird::SnakeBird::DecodeLevel | ( | const std::string & | encoding | ) |
Convert a map to an ASCII string.
Definition at line 1143 of file SnakeBird.cpp.
References SnakeBird::codeSize, height, SnakeBird::kBlock1, SnakeBird::kBlock2, SnakeBird::kBlock3, SnakeBird::kBlock4, SnakeBird::kDown, SnakeBird::kEmpty, SnakeBird::kExit, SnakeBird::kFruit, SnakeBird::kGround, SnakeBird::kLeft, SnakeBird::kPortal1, SnakeBird::kPortal2, SnakeBird::kRight, SnakeBird::kSpikes, SnakeBird::kUp, and width.
|
private |
Definition at line 2535 of file SnakeBird.cpp.
|
private |
Definition at line 1744 of file SnakeBird.cpp.
References SnakeBird::SnakeBirdState::GetNumSnakes(), SnakeBird::SnakeBirdState::GetObjectLocation(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), GetY(), height, SnakeBird::kBlock1, SnakeBird::kBlock2, SnakeBird::kBlock3, SnakeBird::kBlock4, SnakeBird::kDead, SnakeBird::kDoneAnimation, SnakeBird::kDown, SnakeBird::kExit, SnakeBird::kFellInGoal, SnakeBird::SnakeBirdState::KFruitEaten(), SnakeBird::kInGoal, SnakeBird::kSnake1, SnakeBird::kSnake2, SnakeBird::kSnake3, SnakeBird::kSnake4, SnakeBird::kTeleport, SnakeBird::SnakeBirdAction::pushed, SnakeBird::SnakeBirdState::SetObjectLocation(), and SnakeBird::SnakeBirdState::SetSnakeHeadLoc().
|
private |
Definition at line 1660 of file SnakeBird.cpp.
References SnakeBird::SnakeBirdAction::bird, SnakeBird::SnakeBirdState::GetFruitPresent(), SnakeBird::SnakeBirdState::GetNumSnakes(), SnakeBird::SnakeBirdState::GetObjectLocation(), SnakeBird::SnakeBirdState::GetSnakeBodyEnd(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), GetX(), GetY(), SnakeBird::SnakeBirdState::InsertSnakeDir(), SnakeBird::SnakeBirdState::InsertSnakeHeadDir(), SnakeBird::kDead, SnakeBird::kExit, SnakeBird::kFruit, SnakeBird::SnakeBirdState::KFruitEaten(), SnakeBird::kInitialTeleport, SnakeBird::kWentInGoal, SnakeBird::SnakeBirdAction::pushed, SnakeBird::SnakeBirdState::SetObjectLocation(), SnakeBird::SnakeBirdState::SetSnakeBodyEnd(), SnakeBird::SnakeBirdState::SetSnakeHeadLoc(), and SnakeBird::SnakeBirdState::ToggleFruitPresent().
|
virtual |
Reimplemented from SearchEnvironment< SnakeBirdState, SnakeBirdAction >.
Definition at line 2550 of file SnakeBird.cpp.
References Colors::brown, Colors::cyan, Colors::darkblue, Colors::darkgray, Colors::darkgreen, Colors::darkred, Graphics::Display::FillRect(), Graphics::Display::FillSquare(), Graphics::Display::FillTriangle(), GetX(), GetY(), Colors::gray, height, SnakeBird::kEmpty, SnakeBird::kGround, SnakeBird::kSpikes, Colors::lightblue, rgbColor::mix(), width, Graphics::point::x, and Graphics::point::y.
void SnakeBird::SnakeBird::Draw | ( | Graphics::Display & | display, |
const SnakeBirdState & | s | ||
) | const |
Definition at line 2922 of file SnakeBird.cpp.
void SnakeBird::SnakeBird::Draw | ( | Graphics::Display & | display, |
const SnakeBirdState & | old, | ||
const SnakeBirdState & | s, | ||
int | active, | ||
double | percentComplete, | ||
double | globalTime | ||
) | const |
Definition at line 3144 of file SnakeBird.cpp.
References Colors::blue, fequal(), Graphics::Display::FillCircle(), Graphics::Display::FillNGon(), Graphics::Display::FillRect(), Graphics::Display::FrameSquare(), SnakeBird::SnakeBirdState::GetBodyBits(), SnakeBird::SnakeBirdState::GetFruitPresent(), SnakeBird::SnakeBirdState::GetNumSnakes(), SnakeBird::SnakeBirdState::GetObjectLocation(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), SnakeBird::SnakeBirdState::GetSnakeLength(), GetX(), GetY(), Colors::green, SnakeBird::kDead, SnakeBird::SnakeBirdState::KFruitEaten(), SnakeBird::kInGoal, Colors::orange, Colors::purple, Colors::red, Graphics::point::x, Graphics::point::y, and Colors::yellow.
void SnakeBird::SnakeBird::Draw | ( | Graphics::Display & | display, |
const SnakeBirdState & | s, | ||
int | active | ||
) | const |
Definition at line 2927 of file SnakeBird.cpp.
void SnakeBird::SnakeBird::Draw | ( | Graphics::Display & | display, |
const SnakeBirdState & | s, | ||
int | active, | ||
double | globalTime | ||
) | const |
Definition at line 3288 of file SnakeBird.cpp.
void SnakeBird::SnakeBird::Draw | ( | Graphics::Display & | display, |
double | time | ||
) | const |
Definition at line 2861 of file SnakeBird.cpp.
References Colors::blue, Colors::darkblue, Colors::darkred, Graphics::Display::FillCircle(), Graphics::Display::FillNGon(), GetX(), GetY(), Colors::green, height, Colors::purple, Colors::red, and width.
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.
void SnakeBird::SnakeBird::DrawLabel | ( | Graphics::Display & | display, |
int | x, | ||
int | y, | ||
const char * | str | ||
) |
Definition at line 3385 of file SnakeBird.cpp.
References Graphics::Display::DrawText(), Colors::GetColor(), Graphics::textAlignLeft, and Graphics::textBaselineMiddle.
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.
|
private |
Definition at line 3054 of file SnakeBird.cpp.
References Colors::blue, SnakeBird::SnakeBirdState::GetSnakeDir(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), SnakeBird::SnakeBirdState::GetSnakeLength(), GetX(), GetY(), Colors::green, SnakeBird::kDown, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kSpikes, SnakeBird::kUp, Colors::red, and Colors::yellow.
void SnakeBird::SnakeBird::DrawObject | ( | Graphics::Display & | display, |
int | x, | ||
int | y, | ||
SnakeBirdWorldObject | o, | ||
double | time = 0 |
||
) | const |
Definition at line 2671 of file SnakeBird.cpp.
References Colors::black, Colors::blue, Graphics::rect::bottom, Colors::brown, Colors::cyan, Colors::darkgray, Colors::darkred, Colors::green, height, SnakeBird::kBlock1, SnakeBird::kBlock2, SnakeBird::kBlock3, SnakeBird::kBlock4, SnakeBird::kEmpty, SnakeBird::kExit, SnakeBird::kFruit, SnakeBird::kGround, SnakeBird::kNothing, SnakeBird::kPortal1, SnakeBird::kPortal2, SnakeBird::kSnake1, SnakeBird::kSnake2, SnakeBird::kSpikes, Graphics::rect::left, Colors::lightblue, rgbColor::mix(), Colors::orange, Colors::purple, Colors::red, Graphics::rect::right, Graphics::rect::top, Colors::white, Graphics::point::x, Graphics::point::y, and Colors::yellow.
void SnakeBird::SnakeBird::DrawObjects | ( | Graphics::Display & | display, |
double | time = 0 |
||
) | const |
Definition at line 2596 of file SnakeBird.cpp.
References Colors::blue, Colors::brown, Colors::darkgray, Graphics::Display::FillCircle(), Graphics::Display::FillNGon(), Graphics::Display::FillSquare(), GetX(), GetY(), Colors::gray, Colors::green, height, SnakeBird::kEmpty, SnakeBird::kExit, SnakeBird::kFruit, SnakeBird::kGround, SnakeBird::kPortal1, SnakeBird::kPortal2, SnakeBird::kSpikes, Colors::orange, Colors::purple, Colors::red, width, Graphics::point::x, Graphics::point::y, and Colors::yellow.
void SnakeBird::SnakeBird::DrawSmallLabel | ( | Graphics::Display & | display, |
int | x, | ||
int | y, | ||
const char * | str | ||
) |
Definition at line 3390 of file SnakeBird.cpp.
References Graphics::Display::DrawText(), Colors::GetColor(), Graphics::textAlignCenter, and Graphics::textBaselineMiddle.
|
private |
Definition at line 2932 of file SnakeBird.cpp.
References Colors::blue, SnakeBird::SnakeBirdState::GetSnakeDir(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), SnakeBird::SnakeBirdState::GetSnakeLength(), GetX(), GetY(), Colors::green, SnakeBird::kDown, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kUp, Colors::red, and Colors::yellow.
|
private |
Definition at line 3293 of file SnakeBird.cpp.
References Colors::black, Graphics::rect::bottom, Graphics::Display::FillCircle(), Graphics::Display::FillNGon(), Graphics::Display::FillRect(), Graphics::Display::FillSquare(), SnakeBird::kDown, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kUp, Graphics::rect::left, rgbColor::mix(), Colors::orange, Graphics::rect::right, Graphics::rect::top, Colors::white, Graphics::point::x, and Graphics::point::y.
|
private |
Definition at line 2987 of file SnakeBird.cpp.
References Colors::blue, SnakeBird::SnakeBirdState::GetSnakeBodyEnd(), SnakeBird::SnakeBirdState::GetSnakeDir(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), GetX(), GetY(), Colors::green, SnakeBird::kDown, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kUp, Colors::red, and Colors::yellow.
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.
void SnakeBird::SnakeBird::EndEditing | ( | ) |
Stop editing the map & apply optimizations to internal data structures.
Definition at line 476 of file SnakeBird.cpp.
|
inline |
Definition at line 348 of file SnakeBird.h.
|
inline |
Definition at line 347 of file SnakeBird.h.
|
inline |
Definition at line 355 of file SnakeBird.h.
References SnakeBird::SnakeBirdAction::bird, and SnakeBird::SnakeBirdAction::direction.
void SnakeBird::SnakeBird::GetActions | ( | const SnakeBirdState & | nodeID, |
std::vector< SnakeBirdAction > & | actions | ||
) | const |
Return (by reference) the legal actions in a state.
Definition at line 1440 of file SnakeBird.cpp.
References SnakeBird::SnakeBirdAction::bird, SnakeBird::SnakeBirdAction::direction, SnakeBird::SnakeBirdState::GetNumSnakes(), SnakeBird::SnakeBirdState::GetSnakeDir(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), GetX(), GetY(), height, SnakeBird::kBlockMask, SnakeBird::kCanEnterMask, SnakeBird::kDown, SnakeBird::kGroundMask, SnakeBird::kInGoal, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kSnake1, SnakeBird::kSnake2, SnakeBird::kSnake3, SnakeBird::kSnake4, SnakeBird::kSnakeMask, SnakeBird::kUp, SnakeBird::SnakeBirdAction::pushed, and width.
snakeDir SnakeBird::SnakeBird::GetAddingDirection | ( | int | x, |
int | y, | ||
int | endX, | ||
int | endY | ||
) |
Definition at line 540 of file SnakeBird.cpp.
References SnakeBird::kDown, SnakeBird::kLeft, SnakeBird::kNoDirection, SnakeBird::kRight, and SnakeBird::kUp.
|
private |
Definition at line 2909 of file SnakeBird.cpp.
References Graphics::point::x, and Graphics::point::y.
|
private |
Definition at line 2487 of file SnakeBird.cpp.
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.
|
inline |
Definition at line 309 of file SnakeBird.h.
References height.
int SnakeBird::SnakeBird::GetIndex | ( | int | x, |
int | y | ||
) | const |
Definition at line 2520 of file SnakeBird.cpp.
References height.
|
inline |
Definition at line 324 of file SnakeBird.h.
|
inline |
Definition at line 314 of file SnakeBird.h.
int SnakeBird::SnakeBird::GetNumPortals | ( | ) |
Definition at line 2473 of file SnakeBird.cpp.
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.
float SnakeBird::SnakeBird::GetRadius | ( | ) | const |
Definition at line 2917 of file SnakeBird.cpp.
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.
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.
|
inline |
Definition at line 356 of file SnakeBird.h.
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.
|
inline |
Definition at line 308 of file SnakeBird.h.
References width.
int SnakeBird::SnakeBird::GetX | ( | int | index | ) | const |
Definition at line 2525 of file SnakeBird.cpp.
References height.
int SnakeBird::SnakeBird::GetY | ( | int | index | ) | const |
Definition at line 2530 of file SnakeBird.cpp.
References height.
|
inline |
Definition at line 368 of file SnakeBird.h.
|
inline |
Definition at line 369 of file SnakeBird.h.
|
inline |
Definition at line 367 of file SnakeBird.h.
|
inlinevirtual |
Goal Test if the goal is stored.
Definition at line 352 of file SnakeBird.h.
References SnakeBird::kInGoal.
|
inline |
|
private |
Definition at line 2066 of file SnakeBird.cpp.
References SnakeBird::SnakeBirdAnimationStep::anim, SnakeBird::SnakeBirdAction::bird, SnakeBird::SnakeBirdState::GetObjectLocation(), SnakeBird::SnakeBirdState::GetSnakeDir(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), SnakeBird::SnakeBirdState::GetSnakeLength(), GetX(), GetY(), height, SnakeBird::kBlock1, SnakeBird::kBlock2, SnakeBird::kBlock3, SnakeBird::kBlock4, SnakeBird::kBlockMask, SnakeBird::kDead, SnakeBird::kDown, SnakeBird::kFruit, SnakeBird::SnakeBirdState::KFruitEaten(), SnakeBird::kGroundMask, SnakeBird::kInitialTeleport, SnakeBird::kLeft, SnakeBird::kNoTeleport, SnakeBird::kRight, SnakeBird::kSnake1, SnakeBird::kSnake2, SnakeBird::kSnake3, SnakeBird::kSnake4, SnakeBird::kSnakeMask, SnakeBird::kTeleportSuccess, SnakeBird::kTeleportToExit, SnakeBird::kUp, SnakeBird::SnakeBirdAction::pushed, SnakeBird::SnakeBirdState::SetObjectLocation(), SnakeBird::SnakeBirdState::SetSnakeHeadLoc(), and width.
|
inline |
Heuristic value between two arbitrary nodes.
Definition at line 345 of file SnakeBird.h.
|
inline |
Definition at line 330 of file SnakeBird.h.
|
inline |
Returns true if the goal is stored and false otherwise.
Definition at line 341 of file SnakeBird.h.
|
private |
Definition at line 1346 of file SnakeBird.cpp.
References SnakeBird::SnakeBirdState::GetSnakeBodyEnd(), SnakeBird::SnakeBirdState::GetSnakeDir(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), height, SnakeBird::kDead, SnakeBird::kDown, SnakeBird::kInGoal, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kSpikes, SnakeBird::kUp, and width.
bool SnakeBird::SnakeBird::Legal | ( | SnakeBirdState & | s, |
SnakeBirdAction | a | ||
) |
Return whether an action is legal.
Definition at line 1336 of file SnakeBird.cpp.
|
inline |
Definition at line 313 of file SnakeBird.h.
bool SnakeBird::SnakeBird::Load | ( | const char * | filename | ) |
Load a map from a filename.
Definition at line 858 of file SnakeBird.cpp.
References height, SnakeBird::kBlock1, SnakeBird::kBlock2, SnakeBird::kBlock3, SnakeBird::kBlock4, SnakeBird::kDown, SnakeBird::kEmpty, SnakeBird::kExit, SnakeBird::kFruit, kGround, SnakeBird::kLeft, SnakeBird::kPortal1, SnakeBird::kPortal2, SnakeBird::kRight, SnakeBird::kSpikes, SnakeBird::kUp, SnakeBird::LoadSnake(), and width.
|
inline |
Definition at line 362 of file SnakeBird.h.
|
inline |
Definition at line 363 of file SnakeBird.h.
|
inline |
Definition at line 366 of file SnakeBird.h.
|
inline |
Draw the transition at some percentage 0...1 between two states.
Definition at line 365 of file SnakeBird.h.
void SnakeBird::SnakeBird::RemoveBlock | ( | int | x, |
int | y | ||
) |
void SnakeBird::SnakeBird::RemoveSnake | ( | int | x, |
int | y, | ||
int | o, | ||
int | whichSnake | ||
) |
Definition at line 606 of file SnakeBird.cpp.
References GetX(), GetY(), SnakeBird::kDown, SnakeBird::kLeft, SnakeBird::kRight, and SnakeBird::kUp.
|
private |
Definition at line 1373 of file SnakeBird.cpp.
References SnakeBird::SnakeBirdState::GetFruitPresent(), SnakeBird::SnakeBirdState::GetNumSnakes(), SnakeBird::SnakeBirdState::GetObjectLocation(), SnakeBird::SnakeBirdState::GetSnakeBodyEnd(), SnakeBird::SnakeBirdState::GetSnakeDir(), SnakeBird::SnakeBirdState::GetSnakeHeadLoc(), GetX(), GetY(), height, SnakeBird::kBlock1, SnakeBird::kBlock2, SnakeBird::kBlock3, SnakeBird::kBlock4, SnakeBird::kDead, SnakeBird::kDown, SnakeBird::kEmpty, SnakeBird::kFruit, SnakeBird::kInGoal, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kSnake1, SnakeBird::kSnake2, SnakeBird::kSnake3, SnakeBird::kSnake4, SnakeBird::kSpikes, SnakeBird::kUp, and width.
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.
bool SnakeBird::SnakeBird::Save | ( | const char * | filename | ) |
Currently not supported.
Definition at line 996 of file SnakeBird.cpp.
|
private |
Definition at line 2287 of file SnakeBird.cpp.
void SnakeBird::SnakeBird::SetGroundType | ( | int | x, |
int | y, | ||
SnakeBirdWorldObject | o | ||
) |
Change the ground type to a new type.
Must enable editing to have an impact.
Definition at line 2343 of file SnakeBird.cpp.
References GetX(), GetY(), height, SnakeBird::kBlock1, SnakeBird::kBlock2, SnakeBird::kBlock3, SnakeBird::kBlock4, SnakeBird::kBlockMask, SnakeBird::kEmpty, SnakeBird::kExit, SnakeBird::kFruit, SnakeBird::kPortal, SnakeBird::kPortal1, SnakeBird::kPortal2, and min().
void SnakeBird::SnakeBird::SetStart | ( | const SnakeBirdState & | start | ) |
Set the initial state of the game.
Definition at line 509 of file SnakeBird.cpp.
void SnakeBird::SnakeBird::SmallerMapHeight | ( | ) |
Definition at line 214 of file SnakeBird.cpp.
References GetX(), GetY(), height, SnakeBird::kDown, SnakeBird::kEmpty, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kUp, and width.
void SnakeBird::SnakeBird::SmallerMapWidth | ( | ) |
Definition at line 411 of file SnakeBird.cpp.
References GetX(), GetY(), SnakeBird::kDown, SnakeBird::kLeft, SnakeBird::kRight, SnakeBird::kUp, and width.
|
inline |
Stores the goal for use by single-state HCost.
Definition at line 333 of file SnakeBird.h.
|
inline |
Definition at line 321 of file SnakeBird.h.
|
private |
Definition at line 437 of file SnakeBird.h.
|
private |
Definition at line 435 of file SnakeBird.h.
|
private |
Definition at line 430 of file SnakeBird.h.
|
private |
Definition at line 425 of file SnakeBird.h.
|
private |
Definition at line 433 of file SnakeBird.h.
|
private |
Definition at line 432 of file SnakeBird.h.
|
private |
Definition at line 434 of file SnakeBird.h.
|
private |
Definition at line 434 of file SnakeBird.h.
|
mutableprivate |
Definition at line 428 of file SnakeBird.h.
|
private |
Definition at line 436 of file SnakeBird.h.
|
private |
Definition at line 425 of file SnakeBird.h.
|
private |
Definition at line 427 of file SnakeBird.h.