// Author: Juan Carlos De Abreu (jcabreur@gmail.com)

#ifndef AI_H__
#define AI_H__

#include "global.h"
#include "memory"
#include "queue"
#include "math/vector.h"
#include "map"

BEGIN_TEG_NAMESPACE();

namespace ai {

#define TABLERO_NRO_ROWS 396
#define TABLERO_NRO_COLS 512

class Tablero {
 public:
  Tablero();
  ~Tablero();

  enum { EMPTY = 1, WALL = 2, MARK = 4, THIEF = 8, WORKER = 16, CHILD = 32};

  void floodFill();
  void restore();
  void loadMap(const char* filename);
  void growBorder();
  void saveMap();

	inline int get(int x, int y){
		if(x>=0 && x<TABLERO_NRO_COLS && y>=0 && y<TABLERO_NRO_ROWS)
			return state[y][x];
	}

	inline void set(int x, int y, int val){
		if(x>=0 && x<TABLERO_NRO_COLS && y>=0 && y<TABLERO_NRO_ROWS)
			state[y][x] = val;
	}

 //private:
  int numberOfRows, numberOfColumms;
  int state[TABLERO_NRO_ROWS][TABLERO_NRO_COLS];
private:
  DISALLOW_COPY_AND_ASSIGN(Tablero);
};


math::Vec2<int> GetPosition(std::map< std::pair<int, int>, std::pair<int, int> > prev, std::pair<int, int> pos);

std::vector< math::Vec2<int> > GetPath(std::map< std::pair<int, int>, std::pair<int, int> > prev, std::pair<int, int> pos);

};


END_TEG_NAMESPACE();

#endif  // AI_H__
