test: trace scenario 2400 parity
This commit is contained in:
+52
-28
@@ -2916,22 +2916,40 @@ class GeneralAI
|
||||
}
|
||||
|
||||
|
||||
protected function do출병(): ?GeneralCommand
|
||||
{
|
||||
if (!$this->attackable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->dipState !== self::d전쟁) {
|
||||
return null;
|
||||
protected function do출병(): ?GeneralCommand
|
||||
{
|
||||
$traceEnabled = in_array((string)$this->general->getID(), array_filter(explode(',', (string)getenv('REF_AI_TRACE_GENERAL_IDS')), 'strlen'), true);
|
||||
$trace = static function (string $stage, array $values = []) use ($traceEnabled): void {
|
||||
if ($traceEnabled) {
|
||||
fwrite(STDOUT, 'AI_WAR_TRACE ' . Json::encode(['engine' => 'ref', 'stage' => $stage] + $values) . "\n");
|
||||
}
|
||||
};
|
||||
$trace('start', [
|
||||
'generalId' => $this->general->getID(), 'attackable' => $this->attackable,
|
||||
'dipState' => $this->dipState, 'nationRice' => $this->nation['rice'],
|
||||
'baseRice' => GameConst::$baserice, 'train' => $this->general->getVar('train'),
|
||||
'atmos' => $this->general->getVar('atmos'), 'crew' => $this->general->getVar('crew'),
|
||||
'fullLeadership' => $this->fullLeadership, 'minWarCrew' => $this->nationPolicy->minWarCrew,
|
||||
'cityID' => $this->city['city'], 'front' => $this->city['front'],
|
||||
'warTargetNation' => $this->warTargetNation,
|
||||
]);
|
||||
if (!$this->attackable) {
|
||||
$trace('not-attackable');
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->dipState !== self::d전쟁) {
|
||||
$trace('not-at-war');
|
||||
return null;
|
||||
}
|
||||
|
||||
$general = $this->getGeneralObj();
|
||||
$city = $this->city;
|
||||
$nation = $this->nation;
|
||||
|
||||
if (($nation['rice'] < GameConst::$baserice) && $general->getNPCType() >= 2 && $this->rng->nextBool(0.7)) {
|
||||
return null;
|
||||
if (($nation['rice'] < GameConst::$baserice) && $general->getNPCType() >= 2 && $this->rng->nextBool(0.7)) {
|
||||
$trace('low-nation-rice');
|
||||
return null;
|
||||
}
|
||||
|
||||
$cityID = $city['city'];
|
||||
@@ -2939,22 +2957,27 @@ class GeneralAI
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
if ($general->getVar('train') < min(100, $this->nationPolicy->properWarTrainAtmos)) {
|
||||
return null;
|
||||
}
|
||||
if ($general->getVar('atmos') < min(100, $this->nationPolicy->properWarTrainAtmos)) {
|
||||
return null;
|
||||
}
|
||||
if ($general->getVar('crew') < min(($this->fullLeadership - 2) * 100, $this->nationPolicy->minWarCrew)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($city['front'] === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($city['front'] === 1) {
|
||||
return null;
|
||||
if ($general->getVar('train') < min(100, $this->nationPolicy->properWarTrainAtmos)) {
|
||||
$trace('low-train');
|
||||
return null;
|
||||
}
|
||||
if ($general->getVar('atmos') < min(100, $this->nationPolicy->properWarTrainAtmos)) {
|
||||
$trace('low-atmos');
|
||||
return null;
|
||||
}
|
||||
if ($general->getVar('crew') < min(($this->fullLeadership - 2) * 100, $this->nationPolicy->minWarCrew)) {
|
||||
$trace('low-crew');
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($city['front'] === 0) {
|
||||
$trace('front-zero');
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($city['front'] === 1) {
|
||||
$trace('front-one');
|
||||
return null;
|
||||
}
|
||||
|
||||
$attackableNations = [];
|
||||
@@ -2969,11 +2992,12 @@ class GeneralAI
|
||||
}
|
||||
$nearCities = array_keys(CityConst::byID($cityID)->path);
|
||||
|
||||
$attackableCities = $db->queryFirstColumn(
|
||||
$attackableCities = $db->queryFirstColumn(
|
||||
'SELECT city, nation FROM city WHERE nation IN %li AND city IN %li',
|
||||
$attackableNations,
|
||||
$nearCities
|
||||
);
|
||||
);
|
||||
$trace('destinations', ['attackableNations' => $attackableNations, 'nearCities' => $nearCities, 'attackableCities' => $attackableCities]);
|
||||
|
||||
if (count($attackableCities) == 0) {
|
||||
throw new \RuntimeException('출병 불가' . $cityID . var_export($attackableNations, true) . var_export($nearCities, true));
|
||||
|
||||
Reference in New Issue
Block a user