Skip to content

Commit 54ded11

Browse files
committed
printBoard() shows the active sub-board
1 parent 8aeabff commit 54ded11

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

Todo.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
TODO List
22

33
- Code formatting
4-
- Use exceptions for error handling
54
- Improve Matrix class functionality/cleanliness
65
- Ultimate Tic Tac Toe
76
- Random Player (chooses moves randomly)
@@ -10,6 +9,7 @@ TODO List
109
- Organize codebase (.cpp and .h folders, build folder, more complex makefile, etc.)
1110
- Optimize (inline some small functions, reduce parameter copying, etc.)
1211
- Prettify/color-code command line output
12+
- Use exceptions for error handling
1313
- Perfect Player (via minimax)
1414
- Smarter weight crossover
1515
- Coevolution

UltimateTTT.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ vector<unsigned int> UltimateTTT<T1, T2>::bestMoves(
152152
template <class T1, class T2>
153153
void UltimateTTT<T1, T2>::printBoard() const{
154154
for(int i = 0; i < 25; ++i){
155-
if(i == 0 || i == 24){
156-
cout << endl;
157-
continue;
158-
}
159155
for(int j = 0; j < 47; ++j){
160156
char cur = ' ';
161157

@@ -164,12 +160,24 @@ void UltimateTTT<T1, T2>::printBoard() const{
164160

165161
int subBoard = x / 3 + 3 * (int)(y / 3);
166162
int subPostion = x % 3 + 3 * (y % 3);
167-
bool metaOccupied = getBoardAtPos(-1, subBoard) != States::empty;
168163

169164
bool insideMetaBox_x = (j / 4) % 4 == 1 || (j / 4) % 4 == 2;
170165
bool insideMetaBox_y = (i / 2) % 4 == 1 || (i / 2) % 4 == 2;
171-
172-
if(i % 2 == 1 && j % 4 == 1){
166+
bool metaOccupied = true; //default
167+
168+
if(i != 0 && i != 24){
169+
metaOccupied = getBoardAtPos(-1, subBoard) != States::empty;
170+
}
171+
172+
if(i % 8 == 0 && (j / 16) == (activeBoard % 3) && j % 16 != 15
173+
&& ((i / 8) == (activeBoard / 3) ||
174+
(i / 8) == ((activeBoard / 3) + 1)) ){
175+
cur = '#';
176+
} else if((j % 16 == 0 || j % 16 == 14)
177+
&& (i / 8) == (activeBoard / 3)
178+
&& (j / 16) == (activeBoard % 3)){
179+
cur = '#';
180+
} else if(i % 2 == 1 && j % 4 == 1){
173181
if(metaOccupied && dontRevisitSquares
174182
&& insideMetaBox_x && insideMetaBox_y){
175183
cur = ' ';

0 commit comments

Comments
 (0)