Move MainPlayer::recursion(const GameBoard &gameBoard, Tile tile, size_t depth, size_t maxDepth) const { // gameBoard.print(std::cerr); auto now = std::chrono::steady_clock::now(); std::chrono::time_point<std::chrono::system_clock> nowTime; nowTime = std::chrono::system_clock::now(); std::chrono::duration<double> elapsed_seconds = nowTime - startWorking; /*if (elapsed_seconds.count() > 2.7) { std::cerr << "TL\n"; }*/ if (depth > maxDepth || gameBoard.isGameOver() || elapsed_seconds.count() > 2.7) { Move stop({0, 0}, evaluateGameBoard(gameBoard, WHITE), evaluateGameBoard(gameBoard, BLACK)); return stop; } auto enemyTile = gameBoard.getEnemyTile(tile); auto gameSize = gameBoard.getGameSize(); std::bernoulli_distribution coin(0.5); // randomGenerator.seed(time(NULL)); Move current, max; bool first = true; for (size_t row = 0; row < gameSize; ++row) { for (size_t column = 0; column < gameSize; ++column) { Cell here(row, column); if (gameBoard.canPutTile(here, tile)) { GameBoard newGameBoard = gameBoard; newGameBoard.putTile(here, tile); // newGameBoard.print(std::cerr); current = recursion(newGameBoard, enemyTile, depth + 1, maxDepth); if (first || current.isBetterForThan(tile, max)) { max = current; max.cell = here; first = false; } } } } // У текущего игрока нет ходов. Пропуск хода. if (first) { return recursion(gameBoard, enemyTile, depth, maxDepth); } return max; }