#ifndef SOLITAIRE_H
#define SOLITAIRE_H

#include "backtracker.h"
#include <math.h>

using namespace Backtrack;
namespace Backtrack
{

	class Solitaire //: public Backtracker<Solitaire>
	{
	public:
		virtual ~Solitaire() {}
		Solitaire (QString config);
		Solitaire ();

		typedef enum {Hole=0, Pin=1, Forbidden=2} FieldT;

		void setField(int x,int y, FieldT f);
		FieldT field(int i) const;
		FieldT field(int x,int y) const;

		virtual QString toString(int mode=0) const;

		bool operator == (const Solitaire& other) const;
		bool operator < (const Solitaire& other) const;

		QString diff(const Solitaire& other) const;

		quint64 hash(void) const {return Hash;}
		static quint64 fromString(QString);

		QList<Solitaire> variants(void) const;
	private:
		bool checkRange(int x, int y) const;
		Solitaire apply(int xsrc, int ysrc, int xdest, int ydest) const;
		quint64 Hash;

		static quint64 Mask;
		static const quint64 One;
		static quint64 Solution;
		static short Size;

	};

	quint64 qHash(const Solitaire &key);

}


#endif // SOLITAIRE_H
