Skip to content

Commit

Permalink
perf: some adjustments. ⚡
Browse files Browse the repository at this point in the history
  • Loading branch information
Joker2770 committed Jul 8, 2023
1 parent 435cecc commit 15043be
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/RenjuJudge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int RenjuJudge::countA4(const board_type &board, int last_move, const pair<int,
if (1 == board[last_move / n][last_move % n])
vColor.push_back(1);
else if (-1 == board[last_move / n][last_move % n])
vColor.push_back(-1);
vColor.push_back(2);
else
return 0;

Expand All @@ -75,7 +75,7 @@ int RenjuJudge::countA4(const board_type &board, int last_move, const pair<int,
if (1 == board[p_drt_idx.first][p_drt_idx.second])
vColor.push_back(1);
else if (-1 == board[p_drt_idx.first][p_drt_idx.second])
vColor.push_back(-1);
vColor.push_back(2);
else
vColor.push_back(0);

Expand All @@ -93,7 +93,7 @@ int RenjuJudge::countA4(const board_type &board, int last_move, const pair<int,
if (1 == board[p_drt_idx.first][p_drt_idx.second])
vColor.push_back(1);
else if (-1 == board[p_drt_idx.first][p_drt_idx.second])
vColor.push_back(-1);
vColor.push_back(2);
else
vColor.push_back(0);

Expand All @@ -116,7 +116,11 @@ int RenjuJudge::countA4(const board_type &board, int last_move, const pair<int,
{
for (size_t i = 0; i < 5; ++i)
{
if (((A4_SHAPES[i][0]) == (vColor[j])) && ((A4_SHAPES[i][1]) == (vColor[j + 1])) && ((A4_SHAPES[i][2]) == (vColor[j + 2])) && ((A4_SHAPES[i][3]) == (vColor[j + 3])) && ((A4_SHAPES[i][4]) == (vColor[j + 4])))
if (((A4_SHAPES[i][0]) == (vColor[j])) &&
((A4_SHAPES[i][1]) == (vColor[j + 1])) &&
((A4_SHAPES[i][2]) == (vColor[j + 2])) &&
((A4_SHAPES[i][3]) == (vColor[j + 3])) &&
((A4_SHAPES[i][4]) == (vColor[j + 4])))
{
if ((i == 1 || i == 3)) //'1011101' at left3 to right3, '10111101' at left4 and right4, ‘101111101’ at mid, '111010111' at mid, '11110111', '11101111'
{
Expand Down Expand Up @@ -183,7 +187,7 @@ int RenjuJudge::countA3(const board_type &board, int last_move, const pair<int,
if (1 == board[last_move / n][last_move % n])
vColor.push_back(1);
else if (-1 == board[last_move / n][last_move % n])
vColor.push_back(-1);
vColor.push_back(2);
else
return 0;

Expand All @@ -192,7 +196,7 @@ int RenjuJudge::countA3(const board_type &board, int last_move, const pair<int,
if (1 == board[p_drt_idx.first][p_drt_idx.second])
vColor.push_back(1);
else if (-1 == board[p_drt_idx.first][p_drt_idx.second])
vColor.push_back(-1);
vColor.push_back(2);
else
vColor.push_back(0);

Expand All @@ -210,7 +214,7 @@ int RenjuJudge::countA3(const board_type &board, int last_move, const pair<int,
if (1 == board[p_drt_idx.first][p_drt_idx.second])
vColor.push_back(1);
else if (-1 == board[p_drt_idx.first][p_drt_idx.second])
vColor.push_back(-1);
vColor.push_back(2);
else
vColor.push_back(0);

Expand All @@ -234,7 +238,12 @@ int RenjuJudge::countA3(const board_type &board, int last_move, const pair<int,
{
// cout << "A3_element: " << A3_SHAPES[i][0] << A3_SHAPES[i][1] << A3_SHAPES[i][2] << A3_SHAPES[i][3] << A3_SHAPES[i][4] << A3_SHAPES[i][5];
// cout << "vColor_element: " << vColor[j] << vColor[j + 1] << vColor[j + 2] << vColor[j + 3] << vColor[j + 4] << vColor[j + 5];
if (((A3_SHAPES[i][0]) == (vColor[j])) && ((A3_SHAPES[i][1]) == (vColor[j + 1])) && ((A3_SHAPES[i][2]) == (vColor[j + 2])) && ((A3_SHAPES[i][3]) == (vColor[j + 3])) && ((A3_SHAPES[i][4]) == (vColor[j + 4])) && ((A3_SHAPES[i][5]) == (vColor[j + 5])))
if (((A3_SHAPES[i][0]) == (vColor[j])) &&
((A3_SHAPES[i][1]) == (vColor[j + 1])) &&
((A3_SHAPES[i][2]) == (vColor[j + 2])) &&
((A3_SHAPES[i][3]) == (vColor[j + 3])) &&
((A3_SHAPES[i][4]) == (vColor[j + 4])) &&
((A3_SHAPES[i][5]) == (vColor[j + 5])))
{
// Never could be a double-three(alive) in one line. ('101101' is not alive)

Expand Down

0 comments on commit 15043be

Please sign in to comment.