test(compare): trace deterministic monthly seed progression

This commit is contained in:
2026-08-03 18:57:01 +00:00
parent 3b2fd1082f
commit f16a6b6880
23 changed files with 1274 additions and 213 deletions
+4 -2
View File
@@ -64,7 +64,9 @@ class che_견문 extends Command\GeneralCommand{
$sightseeing = new SightseeingMessage();
[$type, $text] = $sightseeing->pickAction();
// The command RNG is derived from the global seed, year/month,
// general id, and action. Avoid PHP's process-global mt_rand here.
[$type, $text] = $sightseeing->pickAction($rng);
$exp = 0;
@@ -122,4 +124,4 @@ class che_견문 extends Command\GeneralCommand{
}
}
}
+31 -8
View File
@@ -2,7 +2,7 @@
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
DB, Util, JosaUtil, Json,
General,
ActionLogger,
LastTurn,
@@ -118,12 +118,35 @@ class che_기술연구 extends che_상업투자{
$score /= 4;
}
$genCount = Util::valueFit(
$db->queryFirstField('SELECT gennum FROM nation WHERE nation=%i', $general->getVar('nation')),
GameConst::$initialNationGenLimit
);
$nationUpdated = [
$genCount = Util::valueFit(
$db->queryFirstField('SELECT gennum FROM nation WHERE nation=%i', $general->getVar('nation')),
GameConst::$initialNationGenLimit
);
$traceGeneralIds = getenv('REF_AI_TRACE_GENERAL_IDS');
$traceNationIds = getenv('REF_AI_TRACE_NATION_IDS');
if (
PHP_SAPI === 'cli'
&& getenv('REF_DETERMINISTIC_INSTALL_ENABLED') === '1'
&& (
(is_string($traceGeneralIds)
&& in_array((string) $general->getID(), explode(',', $traceGeneralIds), true))
|| (is_string($traceNationIds)
&& in_array((string) $general->getVar('nation'), explode(',', $traceNationIds), true))
)
) {
fwrite(STDOUT, 'AI_ACTION_PATCH_TRACE ' . Json::encode([
'engine' => 'ref-tech',
'generalId' => $general->getID(),
'nationId' => $general->getVar('nation'),
'currentTech' => $this->nation['tech'],
'techScore' => $score,
'generalCount' => $genCount,
'delta' => $score / $genCount,
]) . "\n");
}
$nationUpdated = [
'tech' => $this->nation['tech'] + $score/$genCount
];
$db->update('nation', $nationUpdated, 'nation=%i', $general->getVar('nation'));
@@ -143,4 +166,4 @@ class che_기술연구 extends che_상업투자{
}
}
}
@@ -187,7 +187,8 @@ class che_랜덤임관 extends Command\GeneralCommand
LEFT JOIN `rank_data` AS rb ON g.`no` = rb.general_id AND rb.`type` = 'deathcrew_person'
LEFT JOIN `nation` AS n ON g.`nation` = n.`nation`
WHERE g.`npc` IN (0, 1, 2, 3, 6) AND g.nation != 0 AND n.scout=0 AND n.gennum < %i AND n.nation NOT IN %li
GROUP BY g.`nation`",
GROUP BY g.`nation`
ORDER BY g.`nation`",
$genLimit,
$notIn
);
@@ -199,7 +200,8 @@ class che_랜덤임관 extends Command\GeneralCommand
LEFT JOIN `rank_data` AS rb ON g.`no` = rb.general_id AND rb.`type` = 'deathcrew_person'
LEFT JOIN `nation` AS n ON g.`nation` = n.`nation`
WHERE g.`npc` IN (0, 1, 2, 3, 6) AND g.nation != 0 AND n.scout=0 AND n.gennum < %i
GROUP BY g.`nation`",
GROUP BY g.`nation`
ORDER BY g.`nation`",
$genLimit
);
}