#ifndef BOARD_H_INC
#define BOARD_H_INC
#include "common.h"
#define BOARD_SIZE 9 // horizontal/vertical size of the board
#define BOARD_SQRT_SIZE 3 // sqrt size of board
#define NUM_PATHS (BOARD_SIZE*3) // number of paths in the board (for scanning)
#define BOARD_ITEM_OPTION_BIT 15 // bit where 'OPTION on/off' is stored
#define BOARD_ITEM_OPTION_BIT_MASK (1<<BOARD_ITEM_OPTION_BIT) // mask of the 'OPTION on/off' bit
#define BOARD_ITEM_FIXED_MASK 0x000f // mask of the 'FIXED' number
#define BOARD_ITEM_OPTIONS_MASK 0x1ff0 // mask of the 'OPTIONS' numbers
#define BOARD_ITEM_OPTIONS_START_BIT 4 // bit where 'OPTIONS' numbers start
#define IS_NONE(x) ((x) == 0)
#define IS_OPTION(x) ((x) & BOARD_ITEM_OPTION_BIT_MASK) // does this item contain 'OPTIONS'
#define GET_FIXED(x) ((x) & BOARD_ITEM_FIXED_MASK) // get the value of the 'FIXED' number in this item (1..9,0)
#define HAS_FIXED(x) GET_FIXED(x)
#define NO_FIXED(x) (GET_FIXED(x) == 0)
#define GET_OPTIONS(x) (((x) & BOARD_ITEM_OPTIONS_MASK) >> BOARD_ITEM_OPTIONS_START_BIT) // option 1 returned at bit 0
#define GET_OPTION(x,o) ((GET_OPTIONS(x) >> ((o)-1)) & 1)
enum BoardStatusType
{
BS_INCOMPLETE = 0,
BS_ERROR = 1,
BS_COMPLETE = 2
};enum SolutionType
{
SOLUTOIN_NONE = 0,
SOLUTOIN_SINGLE = 1,
SOLUTOIN_MULTPLE = 2,
};struct Point
{
uint32 u, v;
};typedef Point Path[BOARD_SIZE];
class CBoard
{
public:
CBoard(void);
~CBoard(void); void PreCalcPaths (); void ClearBoard (); BoardStatusType GetBoardStatus (); void SetItem (int u, int v, int val, bool isOption = false, bool onOff = false); uint16 GetItem (int u, int v); void FillPencilMarks (); int ApplyRule1 (); int ApplyRule2 (); SolutionType Solve (bool determineIfMultiple = false); SolutionType IsSolveable (); void Generate (uint16 seed, int difficulty);
private: uint16 m_board[BOARD_SIZE][BOARD_SIZE]; Path m_paths[NUM_PATHS];
};
#endif // BOARD_H_INC