Faster placement (#4491)

* shorter time budget during setup phase

* revert build file changes
This commit is contained in:
2025-10-22 22:23:57 -07:00
committed by GitHub
parent ad8e34ec3d
commit bce577758f
3 changed files with 35 additions and 0 deletions
@@ -28,6 +28,23 @@ auto CalculateTimeBudget(
const auto settingsGetter = settings->GetGetter();
const auto castleCoords = AllCastleCoords(state->hex_map());
// Check if we're in setup phase
const bool isSetupPhase = state->status()->state() ==
net::eagle0::shardok::storage::fb::GameStatus_::State_SET_UP;
// During setup, use the setup-specific time budget
if (isSetupPhase) {
const auto budget = std::chrono::duration<double>(
settingsGetter.Backing().lookahead_time_budget_setup());
const auto remainingBudget = std::chrono::duration_cast<std::chrono::milliseconds>(budget);
const size_t minDepth = settingsGetter.Backing().min_lookahead_turns();
return AITimeBudget{
.remainingBudget = remainingBudget,
.minDepthRequired = minDepth,
.isCloseToEnemy = false}; // Not relevant during setup
}
// Determine proximity (≤4 hex distance) - applies to both attackers and defenders
bool isClose = false;
const auto *units = state->units();
@@ -215,5 +215,6 @@ holyWaveVigorCost 10 double
minLookaheadTurns 1 int8
lookaheadTimeBudgetCloseInSeconds 3 double
lookaheadTimeBudgetFarInSeconds 1.5 double
lookaheadTimeBudgetSetup 0.5 double
aiMinimumFleeOddsThreshold 30 int16
aiDesperateFleeThreshold 10 int16
1 lightningWisdomFactor 1 double
215 minLookaheadTurns 1 int8
216 lookaheadTimeBudgetCloseInSeconds 3 double
217 lookaheadTimeBudgetFarInSeconds 1.5 double
218 lookaheadTimeBudgetSetup 0.5 double
219 aiMinimumFleeOddsThreshold 30 int16
220 aiDesperateFleeThreshold 10 int16
@@ -48,11 +48,28 @@ protected:
AddPlayerInfo(fbb, 1, false, 1000),
AddPlayerInfo(fbb, 2, true, 1000)});
// Create a game status with GAME_RUNNING state
auto endGameCondition = net::eagle0::shardok::storage::fb::EndGameCondition();
endGameCondition.mutate_victory_type(
net::eagle0::shardok::storage::fb::VictoryType_UNKNOWN_VICTORY_TYPE);
endGameCondition.mutate_draw_details(
net::eagle0::shardok::storage::fb::DrawType_UNKNOWN_DRAW_TYPE);
endGameCondition.mutate_victory_details(
net::eagle0::shardok::storage::fb::VictoryCondition_UNKNOWN_VICTORY_CONDITION);
auto winningIdsVec = std::vector<PlayerId>{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
auto winningIdsOff = fbb.CreateVector(winningIdsVec);
auto statusB = net::eagle0::shardok::storage::fb::GameStatusBuilder(fbb);
statusB.add_state(net::eagle0::shardok::storage::fb::GameStatus_::State_GAME_RUNNING);
statusB.add_end_game_condition(&endGameCondition);
statusB.add_winning_shardok_ids(winningIdsOff);
auto statusOff = statusB.Finish();
net::eagle0::shardok::storage::fb::GameStateBuilder gsb(fbb);
gsb.add_units(unitsOffset);
gsb.add_hex_map(hexMapOffset);
gsb.add_player_infos(playerInfoOffset);
gsb.add_current_round(5);
gsb.add_status(statusOff);
fbb.Finish(gsb.Finish());
return GameStateW(fbb);