Compare commits

...
@@ -95,7 +95,7 @@ struct ImmediateAndLookaheadScore {
bool isDefender, bool isDefender,
int remainingLookahead, int remainingLookahead,
int maxRepeatCount, int maxRepeatCount,
const shared_ptr<ShardokEngine> &innerEngine, const ShardokEngine innerEngine,
ScoreValue currentUtility, ScoreValue currentUtility,
const AIStrategy &attackerStrategy, const AIStrategy &attackerStrategy,
const SettingsGetter &settingsGetter, const SettingsGetter &settingsGetter,
@@ -964,7 +964,7 @@ auto BasicLookaheadCalculator(
const bool isDefender, const bool isDefender,
const int remainingLookahead, const int remainingLookahead,
const int maxRepeatCount, const int maxRepeatCount,
const shared_ptr<ShardokEngine> &innerEngine, const ShardokEngine innerEngine,
const ScoreValue currentUtility, const ScoreValue currentUtility,
const AIStrategy &attackerStrategy, const AIStrategy &attackerStrategy,
const SettingsGetter &settingsGetter, const SettingsGetter &settingsGetter,
@@ -975,7 +975,7 @@ auto BasicLookaheadCalculator(
-> std::future<eagle0::common::TaskResult<ScoreValue>> { -> std::future<eagle0::common::TaskResult<ScoreValue>> {
const auto nextUtility = currentUtility; const auto nextUtility = currentUtility;
if (const CommandListSPtr nextCommands = innerEngine->GetAvailableCommandsForAIPlayer(pid); if (const CommandListSPtr nextCommands = innerEngine.GetAvailableCommandsForAIPlayer(pid);
nextCommands && !nextCommands->empty()) { nextCommands && !nextCommands->empty()) {
// Get the future from BestCommandIndex without calling .get() // Get the future from BestCommandIndex without calling .get()
auto bestCommandFuture = BestCommandIndex( auto bestCommandFuture = BestCommandIndex(
@@ -983,7 +983,7 @@ auto BasicLookaheadCalculator(
isDefender, isDefender,
remainingLookahead - 1, remainingLookahead - 1,
maxRepeatCount, maxRepeatCount,
*innerEngine, innerEngine,
attackerStrategy, attackerStrategy,
nextUtility, nextUtility,
settingsGetter, settingsGetter,
@@ -1003,7 +1003,7 @@ auto BasicLookaheadCalculator(
bestCommandFuture.get(); bestCommandFuture.get();
if (auto &nextCommand = if (auto &nextCommand =
innerEngine->GetAvailableCommandsForAIPlayer(pid)->at(index); innerEngine.GetAvailableCommandsForAIPlayer(pid)->at(index);
nextCommand->GetCommandType() != nextCommand->GetCommandType() !=
net::eagle0::shardok::common::END_TURN_COMMAND) { net::eagle0::shardok::common::END_TURN_COMMAND) {
return eagle0::common::TaskResult<ScoreValue>::Success(immediateScore); return eagle0::common::TaskResult<ScoreValue>::Success(immediateScore);
@@ -1045,12 +1045,12 @@ auto CalcOne(
return returnValue; return returnValue;
} }
auto innerEngine = std::make_shared<ShardokEngine>(guessedEngine, false); auto innerEngine = ShardokEngine(guessedEngine, false);
innerEngine->PostCommand(pid, commandIndex, randomGenerator); innerEngine.PostCommand(pid, commandIndex, randomGenerator);
auto innerUtility = AIScoreCalculator::GuessedStateScore( auto innerUtility = AIScoreCalculator::GuessedStateScore(
isDefender, isDefender,
innerEngine->GetCurrentGameState(), innerEngine.GetCurrentGameState(),
attackerStrategy, attackerStrategy,
allCastleCoords, allCastleCoords,
settingsGetter, settingsGetter,