DU CODE Snake Competition
 
Loading...
Searching...
No Matches
Pos Class Reference

Pos represents a position on the Grid; the origin is bottom left.

Public Member Functions

 Pos (int x, int y)
 
bool operator== (const Pos &other) const
 
Pos with_dir (const Direction dir) const
 Helper method to give the position if it went in a certain direction.
 

Public Attributes

int x
 
int y
 

Member Function Documentation

◆ with_dir()

Pos Pos::with_dir ( const Direction dir) const

Returns a position if it moved in the given direction. Note, Pos::with_dir does NOT mutate the position this is called on.

For example:

Pos my_pos(3, 4);
Direction up = Direction::UP;
// Will print "Pos(3, 5)"
std::cout << my_pos.with_dir(up) << std::endl;
Direction
Represents a direction and is returned by your bot in MyBot::think.
Definition direction.h:9

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