Professional Documents
Culture Documents
Hex Board
Hex Board
Hex Board
h"
#include <queue>
#include <utility>
if (board[x][y] != Blank)
return false;
if (player == Player::BLUE)
board[x][y] = Blue;
else if (player == Player::RED)
board[x][y] = Red;
return true;
}
board[x][y] = Blank;
return true;
}
while (!traces.empty())
{
auto top = traces.front();
checkBorders(top.first, top.second, flags, side);
traces.pop();
for (int n=0; n<6; n++)
{
int curX = top.first + dirs[n][0];
int curY = top.second + dirs[n][1];
if (inBoard(curX, curY) && board[curX][curY] == side
&& visited[curX][curY] == false)
{
visited[curX][curY] = true;
traces.push(make_pair(curX, curY));
}
}
}