diff --git a/generators/anselme.cpp b/generators/anselme.cpp index 9d0b6d7..f3c485b 100644 --- a/generators/anselme.cpp +++ b/generators/anselme.cpp @@ -1,25 +1,10 @@ #include #include #include +#include // g++ -shared anselme.cpp -o anselme.dll -I../src -// functions -int distance_manhattan(int x1,int y1, int x2, int y2) -{ - return abs(x1-x2) + abs(y1-y2); -} - -inline int custom_min(int a, int b) -{ - return a < b ? a : b; -} - -inline int custom_max(int a, int b) -{ - return a > b ? a : b; -} - extern "C" void generate(Map *mapPtr) { Map &map = *mapPtr; @@ -30,21 +15,18 @@ extern "C" void generate(Map *mapPtr) int r = (w/n < h ? w/n : h)/2; int *teamCoord = new int[n*2]; - for(i=0; i + +enum Dir { + NORTH, + EAST, + SOUTH, + WEST, + NO_DIR = -1 +}; + +struct Coord +{ + int x; + int y; + + Coord(const Coord &c) : + x(c.x), y(c.y) {} + Coord(int x, int y) : + x(x), y(y) {} + Coord(int val) : + x(val), y(val) {} + Coord(Dir d = NO_DIR) + { + switch(d) + { + case NORTH : x= 0; y=-1; break; + case SOUTH : x= 0; y= 1; break; + case WEST : x=-1; y= 0; break; + case EAST : x= 1; y= 0; break; + default : x= 0; y= 0; break; + } + } + Coord operator+(const Coord &c) const + { return Coord(x+c.x, y+c.y);} + Coord& operator+=(const Coord &c) + { x+=c.x; y+=c.y; return *this; } + Coord operator+(Dir d) const + { return *this + Coord(d); } + Coord& operator+=(Dir d) + { return *this += Coord(d); } + Coord operator-(const Coord &c) const + { return Coord(x-c.x, y-c.y); } + Coord& operator-=(const Coord &c) + { x-=c.x; y-=c.y; return *this; } + Coord operator*(const Coord &c) const + { return Coord(x*c.x, y*c.y); } + Coord& operator*=(const Coord &c) + { x*=c.x; y*=c.y; return *this; } + Coord operator/(const Coord &c) const + { return Coord(x/c.x, y/c.y); } + Coord& operator/=(const Coord &c) + { x/=c.x; y/=c.y; return *this; } + int dist() const // manhatthan distance + { return abs(x) + abs(y); } + int operator~() const + { return dist(); } + static dist(const Coord &c1, const Coord &c2) + { return ~(c1-c2); } + int dist(const Coord &c) const + { return dist(*this, c); } + int dist(int x, int y) const + { return dist(*this, Coord(x, y)); } +}; + +#endif // COORD_H diff --git a/src/map.cpp b/src/map.cpp index 836f3b2..12692cd 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -8,14 +8,16 @@ Map::Map(int nbTeams, int width, int height) : { if(m_height == 0) m_height = m_width/2; - map = new Pixel*[m_width]; - Pixel *ptr = new Pixel[m_width*m_height]; - for(int i=0; i +#include "coord.h" #define DUDE_MEMORY_SIZE 128 #define LIBRARY_SIZE 128 #define COM_SIZE 32 -enum Dir { - NORTH, - EAST, - SOUTH, - WEST, - NO_DIR = -1 -}; - -struct Coord -{ - int x; - int y; - - Coord(const Coord &c) : - x(c.x), y(c.y) {} - Coord(int x, int y) : - x(x), y(y) {} - Coord(Dir d = NO_DIR) - { - switch(d) - { - case NORTH : x= 0; y=-1; break; - case SOUTH : x= 0; y= 1; break; - case WEST : x=-1; y= 0; break; - case EAST : x= 1; y= 0; break; - default : x= 0; y= 0; break; - } - } - Coord operator+(const Coord &c) const - { return Coord(x+c.x, y+c.y);} - Coord& operator+=(const Coord &c) - { x+=c.x; y+=c.y; return *this; } - Coord operator+(Dir d) const - { return *this + Coord(d); } - Coord& operator+=(Dir d) - { return *this += Coord(d); } - Coord operator-(const Coord &c) const - { return Coord(x-c.x, y-c.y); } - Coord& operator-=(const Coord &c) - { x-=c.x; y-=c.y; return *this; } - Coord operator*(const Coord &c) const - { return Coord(x*c.x, y*c.y); } - Coord& operator*=(const Coord &c) - { x*=c.x; y*=c.y; return *this; } - Coord operator/(const Coord &c) const - { return Coord(x/c.x, y/c.y); } - Coord& operator/=(const Coord &c) - { x/=c.x; y/=c.y; return *this; } - int dist() const // manhatthan distance - { return abs(x) + abs(y); } - int operator~() const - { return dist(); } - static dist(const Coord &c1, const Coord &c2) - { return ~(c1-c2); } - int dist(const Coord &c) const - { return dist(*this, c); } -}; - struct Com { enum Flags { diff --git a/teams/plop.dll b/teams/plop.dll deleted file mode 100644 index d3f0b3a..0000000 Binary files a/teams/plop.dll and /dev/null differ diff --git a/teams/truc.dll b/teams/truc.dll deleted file mode 100644 index d3f0b3a..0000000 Binary files a/teams/truc.dll and /dev/null differ