#ifndef __AIFORMATIONHPP__
#define __AIFORMATIONHPP__

/*
struct PATHELEMENT
{
	int x,y;
	bool operator< (const PATHELEMENT& p1) const;
	bool operator== (const PATHELEMENT& p1) const;
	PATHELEMENT (int nx,int ny) { x = nx; y = ny; }
	PATHELEMENT (void) { x = -1; y = -1; }
};
*/
#include "ai move.hpp"

#include <queue>
#include <stack>

struct FormationData
{
	AIMove *member;
	int dx,dy;
	bool operator< (const FormationData& p1)
	{
		if (dx < p1.dx)
			return true;
		if (dy < p1.dy)
			return true;
		return false;
	}
};

class AIFormation
{
private:
	CPoint curdes;
	bool newdes;
	std::queue<FormationData> m_CurrentMembers;
	std::stack<PATHELEMENT> m_CurPath;
	CPoint m_Location;

	bool CalcPath (int depth,bool followshort);		// depth = -1 means search until solution
	float GetOneCost (int sx,int sy,int dx,int dy);		// only to adjecent squares
	float PathCostGuess (int sx,int sy,int dx,int dy);

public:
	AIFormation (void);
	~AIFormation (void);

	bool AddAI (AI *newai);
	bool AddMove (AIMove *newmove);
	bool Think (double value); 
	void SetDestination (int x,int y);
	const CPoint& Location (void) { return m_Location; }
};


#endif