Go to the documentation of this file.
61 {
return (
snakeHeads>>(3+whichSnake*14))&0x1FF;}
79 oldLen[whichSnake] = len;
80 oldBody[whichSnake] &= ((1<<len)-1);
119 uint64_t b = (dir<<start);
171 uint64_t mask = (
kOne<<(k))-1;
191 out << a.
bird <<
" ";
194 case kUp: out <<
"up";
break;
195 case kDown: out <<
"down";
break;
196 case kLeft: out <<
"left";
break;
197 case kRight: out <<
"right";
break;
284 void BiggerMapHeight();
285 void BiggerMapWidth();
286 void SmallerMapHeight();
287 void SmallerMapWidth();
288 bool Load(
const char *filename);
289 bool Save(
const char *filename);
290 std::string EncodeLevel()
const;
291 bool DecodeLevel(
const std::string &);
297 void AddSnake(
int x,
int y,
const std::vector<snakeDir> &body);
298 void AddSnakeHead(
int x,
int y,
int whichSnake);
299 snakeDir GetAddingDirection(
int x,
int y,
int endX,
int endY);
300 void AddSnakeBody(
int x,
int y,
int whichSnake);
302 void RemoveSnake(
int x,
int y,
int o,
int whichSnake);
304 void RemoveBlock(
int x,
int y);
311 void GetSuccessors(
const SnakeBirdState &nodeID, std::vector<SnakeBirdState> &neighbors)
const;
312 void GetActions(
const SnakeBirdState &nodeID, std::vector<SnakeBirdAction> &actions)
const;
334 { bValidSearchGoal =
true; searchGoal = s; }
338 { bValidSearchGoal =
false; }
342 {
return bValidSearchGoal; }
353 {
for (
int x = 0; x <
node.GetNumSnakes(); x++)
if (
node.GetSnakeHeadLoc(x) !=
kInGoal)
return false;
return true; }
359 return node.snakeHeads^(
node.snakeBodies)^
node.locBlockFruit;
369 void GLDrawPath(
const std::vector<SnakeBirdState> &x)
const {}
381 int active,
double percentComplete,
double globalTime)
const;
387 float GetRadius()
const;
390 std::string Code(
int)
const;
391 int DeCode(
const std::string &s,
size_t offset)
const;
407 int GetFruitOffset(
int index)
const;
409 int GetIndex(
int x,
int y)
const;
410 int GetX(
int index)
const;
411 int GetY(
int index)
const;
413 int Distance(
int index1,
int index2);
417 int snake,
bool isActive,
double percentComplete)
const;
419 int snake,
bool isActive,
double percentComplete)
const;
421 int snake,
bool isActive,
double percentComplete)
const;
427 std::array<SnakeBirdWorldObject, 512>
world;
428 mutable std::array<SnakeBirdWorldObject, 512>
render;
SnakeBirdState startState
int GetObjectLocation(int whichObstacle) const
uint64_t GetActionHash(SnakeBirdAction act) const
uint64_t GetBodyBits(int whichSnake) const
A color; r/g/b are between 0...1.
void SetNumSnakes(int count)
void GLDrawLine(const SnakeBirdState &x, const SnakeBirdState &y) const
double GCost(const SnakeBirdState &node1, const SnakeBirdState &node2) const
void StoreGoal(SnakeBirdState &s)
Stores the goal for use by single-state HCost.
void SetSnakeLength(int whichSnake, int len)
std::array< std::vector< int >, 4 > objects
void ClearGoal()
Clears the goal from memory.
void ToggleFruitPresent(int which)
const uint64_t snakeLenMask
void GLDrawPath(const std::vector< SnakeBirdState > &x) const
int GetSnakeLength(int whichSnake) const
const uint64_t snakeBodyMask
double HCost(const SnakeBirdState &node1, const SnakeBirdState &node2) const
Heuristic value between two arbitrary nodes.
const uint64_t snakeHeadMask
bool IsInPlay(int whichSnake) const
bool GoalTest(const SnakeBirdState &node, const SnakeBirdState &goal) const
void OpenGLDraw(const SnakeBirdState &) const
void SetObjectLocation(int whichObstacle, int loc)
void SetSnakeHeadLoc(int whichSnake, int loc)
void GLLabelState(const SnakeBirdState &, const char *) const
std::array< bool, 4 > objectFullyConnected
void SetSnakeBodyEnd(int whichSnake, int endOffset)
void MakeSnakeLonger(int whichSnake)
uint64_t GetStateHash(const SnakeBirdState &node) const
void MakeSnakeLonger(int whichSnake, snakeDir addDir)
snakeDir GetSnakeDir(int whichSnake, int segment) const
std::array< SnakeBirdWorldObject, 512 > world
bool operator==(const SnakeBirdState &s) const
const uint64_t locationMask
void SetSnakeDir(int whichSnake, int segment, snakeDir dir)
void InsertSnakeDir(int whichSnake, snakeDir dir)
bool IsDead(int whichSnake) const
void SetBodyBits(int whichSnake, uint64_t bodyBits)
static std::ostream & operator<<(std::ostream &out, const SnakeBirdAction &a)
bool KFruitEaten(int k) const
bool IsGoalStored() const
Returns true if the goal is stored and false otherwise.
void UndoAction(SnakeBirdState &s, SnakeBirdAction a) const
void OpenGLDraw(const SnakeBirdState &, const SnakeBirdState &, float) const
Draw the transition at some percentage 0...1 between two states.
const uint8_t kGroundMask
const uint8_t kNothingPushed
void InsertSnakeHeadDir(int whichSnake, snakeDir dir)
bool LivingState(const SnakeBirdState &s) const
bool operator==(const SnakeBirdAction &a) const
bool InvertAction(SnakeBirdAction &a) const
void OpenGLDraw(const SnakeBirdState &, const SnakeBirdAction &) const
bool GetFruitPresent(int which) const
double GCost(const SnakeBirdState &node, const SnakeBirdAction &act) const
const uint8_t kCanEnterMask
void GetNextState(const SnakeBirdState &s1, SnakeBirdAction a, SnakeBirdState &s2) const
std::size_t operator()(const SnakeBird::SnakeBirdState &k) const
int GetSnakeHeadLoc(int whichSnake) const
Nodes to be stored within a Graph.
int GetSnakeBodyEnd(int whichSnake) const
virtual bool GoalTest(const SnakeBirdState &node) const
Goal Test if the goal is stored.
std::array< SnakeBirdWorldObject, 512 > render