33 |
class Round; |
class Round; |
34 |
class Results; |
class Results; |
35 |
|
|
|
using namespace std; |
|
|
|
|
36 |
#define BOARD_MIN 1 |
#define BOARD_MIN 1 |
37 |
#define BOARD_MAX 15 |
#define BOARD_MAX 15 |
38 |
#define BOARD_DIM 15 |
#define BOARD_DIM 15 |
39 |
#define BOARD_REALDIM (BOARD_DIM + 2) |
#define BOARD_REALDIM (BOARD_DIM + 2) |
40 |
|
|
|
|
|
41 |
// Template matrix class for convenience. |
// Template matrix class for convenience. |
42 |
template <class T> |
template <class T> |
43 |
class Matrix: public vector<vector<T> > |
class Matrix: public std::vector<std::vector<T> > |
44 |
{ |
{ |
45 |
public: |
public: |
46 |
// Construct a matrix with an initial value |
// Construct a matrix with an initial value |
47 |
Matrix(int iSize1, int iSize2, const T &iValue) |
Matrix(int iSize1, int iSize2, const T &iValue) |
48 |
{ |
{ |
49 |
resize(iSize1, vector<T>(iSize2, iValue)); |
resize(iSize1, std::vector<T>(iSize2, iValue)); |
50 |
} |
} |
51 |
// Construct a square matrix with an initial value |
// Construct a square matrix with an initial value |
52 |
Matrix(int iSize, const T &iValue) |
Matrix(int iSize, const T &iValue) |
53 |
{ |
{ |
54 |
resize(iSize, vector<T>(iSize, iValue)); |
resize(iSize, std::vector<T>(iSize, iValue)); |
55 |
} |
} |
56 |
}; |
}; |
57 |
|
|
62 |
Board(); |
Board(); |
63 |
virtual ~Board() {} |
virtual ~Board() {} |
64 |
|
|
65 |
|
/************************* |
66 |
|
* int coordinates have to be BOARD_MIN <= int <= BOARD_MAX |
67 |
|
* |
68 |
|
* getBoardChar returns an upper case letter |
69 |
|
* for normal tiles and a lower case letter for jokers. |
70 |
|
* |
71 |
|
* getBoardCharAttr tells the attributes of the tile |
72 |
|
* 0 : normal played tile |
73 |
|
* 1 : joker tile |
74 |
|
* 2 : test tile for preview purpose |
75 |
|
* attributes can be combined with the or (|) operator |
76 |
|
*************************/ |
77 |
|
#define ATTR_NORMAL 0 |
78 |
|
#define ATTR_JOKER 1 |
79 |
|
#define ATTR_TEST 2 |
80 |
|
|
81 |
|
char getChar (int iRow, int iCol) const; |
82 |
|
int getCharAttr(int iRow, int iCol) const; |
83 |
|
|
84 |
Tile getTile(int iRow, int iCol) const; |
Tile getTile(int iRow, int iCol) const; |
85 |
bool isJoker(int iRow, int iCol) const; |
bool isJoker(int iRow, int iCol) const; |
86 |
bool isVacant(int iRow, int iCol) const; |
bool isVacant(int iRow, int iCol) const; |
87 |
/*int score(Round);*/ |
|
88 |
void addRound(const Dictionary &iDic, const Round &iRound); |
void addRound(const Dictionary &iDic, const Round &iRound); |
89 |
void removeRound(const Dictionary &iDic, const Round &iRound); |
void removeRound(const Dictionary &iDic, const Round &iRound); |
90 |
int checkRound(Round &iRound, bool iFirstTurn); |
int checkRound(Round &iRound, bool iFirstTurn); |
91 |
|
|
92 |
/************************* |
/************************* |
93 |
* |
* |
101 |
* |
* |
102 |
* board_search.c |
* board_search.c |
103 |
*************************/ |
*************************/ |
104 |
void search(const Dictionary &iDic, const Rack &iRack, Results &oResults); |
void search(const Dictionary iDic, const Rack &iRack, Results &oResults); |
105 |
void searchFirst(const Dictionary &iDic, const Rack &iRack, Results &oResults); |
void searchFirst(const Dictionary iDic, const Rack &iRack, Results &oResults); |
106 |
|
|
107 |
/************************* |
/************************* |
108 |
* |
* |