Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameengine): tune the ladder against itself, and record what it says
Olcay Seygan27ec0d0c73cc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 18498a257..89c839c5a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -26,7 +26,7 @@ found and fixed — EA's own, not port damage.**- One AI decision read leftover memory, so identical matches played out differently.- Difficulty and AI money change build pace again; every order was pinned at three seconds.- The computer no longer shoots at what it cannot see. Its units, and its base defences, used to auto-target through the fog of war - a hard exemption written into the code for computer players only. Stealth works against it now, and so does anything it has not scouted.-- It scouts. There was no such thing as scouting in the computer opponent - it never needed to look, because it could already see everything. One cheap unit now tours the enemy start positions and keeps going round for the rest of the match, replaced out of spare change when it dies. Every difficulty scouts; an opponent that never looks reads as broken, not as easy.+- It scouts. There was no such thing as scouting in the computer opponent - it never needed to look, because it could already see everything. One cheap unit now tours the enemy start positions and keeps going round for the rest of the match, replaced out of spare change when it dies. Every difficulty scouts; an opponent that never looks reads as broken, not as easy. And it tours on purpose rather than in a circle: it goes to whichever base it has gone longest without seeing, nearest first, and it does not walk across the map to look again at something it looked at a minute ago - it stays and watches instead. Two scouts never trail each other round the same lap.- Nor does it read your base off the map. Where your base is, what it is worth, which supply dock to expand to and where to aim a superweapon all came off a walk of your object list, in the shroud, from the first second of the match. The computer now only counts what it can see, plus the buildings it has already found - buildings do not walk away. Before it has scouted you, all it knows is where you started, which is on the map preview anyway.## Generals powers the computer actually meant to buydiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.hindex adb693c21..b8b9f31ad 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h@@ -261,6 +261,20 @@ Real aiRetreatRatio( Real myHealth, Real myPower, Real enemyHealth, Real enemyPoBool aiShouldMass( Real waitingThreat, Real enemyVisibleThreat, Real massFraction,Bool timeExpired, Bool baseUnderAttack );+/** How badly one place wants looking at, per step walked there. A3's scouting is never a search -+ * the start positions are public, the lobby shows them - so the question is not "where is he" but+ * "whose picture is worth the walk", and the answer is the stalest one per unit of distance:+ *+ * score = frames since we last looked there / distance to walk there+ *+ * lastSeenFrame 0 means never looked, which makes the age the whole match so far and puts those+ * ahead of everything already seen - nearest first among them, since the distance still divides.+ *+ * A picture younger than freshFrames scores 0: the trip buys nothing, and not making it is the+ * whole point. So 0 means "do not go", not "go last".+ */+Real aiScoutScore( UnsignedInt now, UnsignedInt lastSeenFrame, Real distance, UnsignedInt freshFrames );+/** How attractive an enemy player is to go after, as a cost - lower is better, and it is a squared* distance with the other terms folded into it so the units stay comparable.*diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.hindex f48d0d5dd..7750ac04c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h@@ -34,6 +34,7 @@#include "Common/GameMemory.h"#include "Common/Snapshot.h"#include "GameLogic/AI.h" // AISkillLevel, AIRole and the difficulty profile the ladder reads+#include "Common/GameCommon.h" // MAX_PLAYER_COUNT, for the per-enemy scouting stampsenum { INVALID_SKILLSET_SELECTION = -1 };@@ -262,7 +263,7 @@ protected:Object *findScout(void); ///< a spare unit of ours that can do the touring, not already scoutingvoid queueScout(void); ///< ... or build the cheapest one that canBool scoutInQueue(void); ///< one is already on order- Bool nextScoutTarget(Int slot, Coord3D *pos); ///< the next enemy start position for this scout+ Bool nextScoutTarget(Int slot, const Coord3D *from, Coord3D *pos); ///< the stalest enemy start position worth the walkvirtual void doBaseBuilding(void);virtual void checkReadyTeams(void);@@ -341,6 +342,7 @@ protected:ObjectID m_scoutID[ MAX_AI_SCOUTS ]; ///< the units currently touring the map for usInt m_scoutTargetFor[ MAX_AI_SCOUTS ]; ///< which start position each one is walking toInt m_scoutTimer; ///< frames until the next scouting check+ UnsignedInt m_scoutSeenFrame[ MAX_PLAYER_COUNT ]; ///< when each enemy start position was last looked at; 0 == neverInt m_retreatTimer; ///< frames until the next look at how the fights are goingInt m_expandTimer; ///< frames until the next look for somewhere to expand todiff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cppindex 5a41da844..539117263 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp@@ -1197,15 +1197,23 @@ Int parseNoFPSLimit(char *args[], int num)instead of being paced against wall clock, audio is silenced, and the process quits by itselfthe moment the match is decided. A window and a D3D device are still created - W3D reaches intodrawables and the asset manager throughout, so a true null display is a much larger change than- skipping the one draw call is worth. Pair it with -autoskirmish and -observer for a soak run.+ skipping the one draw call is worth. That window is forced windowed and tiny: nothing is ever+ drawn into it, and a fullscreen device would take the desktop's display mode away from whoever+ is using the machine while the batch runs. -xres/-yres after -headless still win if a run+ wants a real back buffer. Pair it with -autoskirmish and -observer for a soak run.Audio goes off because at several hundred logic frames a second the game hands the mixer a fewthousand events a second that nobody will hear; -headless is for a machine, not a listener. */+enum { HEADLESS_RESOLUTION = 100 }; // big enough for a legal back buffer, small enough to ignore+Int parseHeadless(char *args[], int num){if (TheWritableGlobalData){TheWritableGlobalData->m_headless = TRUE;+ TheWritableGlobalData->m_windowed = TRUE;+ TheWritableGlobalData->m_xResolution = HEADLESS_RESOLUTION;+ TheWritableGlobalData->m_yResolution = HEADLESS_RESOLUTION;TheWritableGlobalData->m_audioOn = FALSE;TheWritableGlobalData->m_musicOn = FALSE;TheWritableGlobalData->m_soundsOn = FALSE;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cppindex bfcc1e72c..c832ef08b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp@@ -1011,15 +1011,31 @@ Real AI::getAdjustedVisionRangeForObject(const Object *object, Int factorsToCons** Read the columns down, not across: nothing here is money, build speed, vision or unit stats.*+ *+ * Two columns were settled by measurement rather than by design, and both are worth reading+ * before touching them again:+ *+ * - retreatTtkRatio started at the roadmap's 0.5-0.85. That is a force quitting a fight it is+ * very nearly winning, and it measured as one: turning retreat off entirely scored better+ * than 0.85 did. These are the "clearly losing" numbers, and at 0.5 retreat is worth about a+ * win in twenty over having none.+ *+ * - useInfluenceMapForAttackLane is FALSE everywhere, deliberately. It works - it aims at the+ * enemy's most valuable visible cell instead of the middle of his base - and over 20 matches+ * it cost two wins. Aiming at the money means walking past the army; the roadmap's actual+ * proposal is to enter where the *defence density* is lowest, which is the threat map rather+ * than the cash map, and that is the next thing to try. getMostValuableVisibleLocation and+ * influenceMapAttackGoal are kept for it.+ ** scoutS maxSc react decis cntr mass ttk indiv team infl focus save harv expand guard hoard */static const AIDifficultyProfile s_defaultSkillLadder[ AISKILL_COUNT ] ={/* Easy */ { 90.0f, 1, 15.0f, 10.0f, 0.00f, FALSE, 0.00f, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 0 },- /* Steady */ { 75.0f, 1, 10.0f, 8.0f, 0.00f, FALSE, 0.50f, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, 0 },- /* Medium */ { 60.0f, 1, 6.0f, 5.0f, 0.25f, FALSE, 0.60f, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, 10000 },- /* Hard */ { 45.0f, 2, 3.0f, 4.0f, 0.60f, FALSE, 0.70f, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, 8000 },- /* Brutal */ { 30.0f, 2, 1.0f, 2.0f, 0.85f, TRUE, 0.80f, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, 5000 },- /* Merciless */ { 25.0f, 2, 0.0f, 1.5f, 1.00f, TRUE, 0.85f, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 4000 }+ /* Steady */ { 75.0f, 1, 10.0f, 8.0f, 0.00f, FALSE, 0.30f, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, 0 },+ /* Medium */ { 60.0f, 1, 6.0f, 5.0f, 0.25f, FALSE, 0.35f, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, 10000 },+ /* Hard */ { 45.0f, 2, 3.0f, 4.0f, 0.60f, FALSE, 0.40f, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, 8000 },+ /* Brutal */ { 30.0f, 2, 1.0f, 2.0f, 0.85f, TRUE, 0.45f, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, 5000 },+ /* Merciless */ { 25.0f, 2, 0.0f, 1.5f, 1.00f, TRUE, 0.50f, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, 4000 }};//-------------------------------------------------------------------------------------------------@@ -1076,6 +1092,21 @@ Bool aiShouldMass( Real waitingThreat, Real enemyVisibleThreat, Real massFractioreturn waitingThreat < massFraction * enemyVisibleThreat;}+//-------------------------------------------------------------------------------------------------+Real aiScoutScore( UnsignedInt now, UnsignedInt lastSeenFrame, Real distance, UnsignedInt freshFrames )+{+ // 0 == never looked, and now - 0 is bigger than any real age, so those sort to the front by itself+ const UnsignedInt age = now - lastSeenFrame;++ if( lastSeenFrame != 0 && age < freshFrames )+ return 0.0f; // the picture is still good; the walk would buy nothing++ if( distance < 1.0f )+ distance = 1.0f; // already standing on it - the best place to look from, and no divide by zero++ return (Real)age / distance;+}+//-------------------------------------------------------------------------------------------------Real aiRoleMassFraction( AIRole role ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppindex 7768a7173..3a1ede7a1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp@@ -176,8 +176,10 @@ m_role(AIROLE_AGGRESSIVE){for (Int scoutSlot = 0; scoutSlot < MAX_AI_SCOUTS; ++scoutSlot) {m_scoutID[scoutSlot] = INVALID_ID;- // a different start position each, so two scouts do not walk the same lap together- m_scoutTargetFor[scoutSlot] = scoutSlot;+ m_scoutTargetFor[scoutSlot] = -1; // nothing looked at yet; the score picks the first target+ }+ for (Int startNdx = 0; startNdx < MAX_PLAYER_COUNT; ++startNdx) {+ m_scoutSeenFrame[startNdx] = 0; // 0 == never seen, which outranks every real age below}m_frameLastBuildingBuilt = TheGameLogic->getFrame();@@ -4090,29 +4092,88 @@ void AIPlayer::queueScout( void )//----------------------------------------------------------------------------------------------------------/**- * The next enemy start position to go and look at. Everyone knows where the start positions are;- * what is on them is what has to be found out. The list is walked round and round, so the same one- * unit that opens the map keeps it up to date for the rest of the match.+ * Where this scout goes next. Everyone already knows where the start positions are - the lobby+ * shows them, and playerStartPosition reads the same public fact - so this is never a search for the+ * enemy. What has to be found out is what is standing on them *now*, which makes the question "whose+ * picture is worth the walk", not "where is he".+ *+ * So the pick is a score, recomputed on every arrival, rather than a blind lap of the player list:+ *+ * score = frames since we last looked there / distance to walk there+ *+ * A position nobody has looked at yet has never been stamped, so its age is the whole match so far+ * and it beats everything that has been seen - and among those, the near one goes first. Recomputing+ * on arrival is what makes a scout drop a base the other scout has just refreshed and take the far+ * one nobody has been to all match.+ *+ * And a picture younger than this rung's scouting interval is not worth the walk at all: the scout+ * stays where it is - which keeps vision on what it can already see - and is asked again in a couple+ * of seconds. That is the trip this used to make for nothing, every lap, at 100% certainty.*/-Bool AIPlayer::nextScoutTarget( Int slot, Coord3D *pos )+Bool AIPlayer::nextScoutTarget( Int slot, const Coord3D *from, Coord3D *pos ){- if( slot < 0 || slot >= MAX_AI_SCOUTS )+ if( slot < 0 || slot >= MAX_AI_SCOUTS || from == NULL )return FALSE;+ const UnsignedInt now = TheGameLogic->getFrame();++ //+ // This is only ever called with an idle scout, so the last leg is over: whatever it was sent to+ // look at, it has now looked at. (A scout that went idle because its path failed stamps a look it+ // never took - that costs one target staying stale for a cycle, not a wrong decision.)+ //+ if( m_scoutTargetFor[ slot ] >= 0 && m_scoutTargetFor[ slot ] < MAX_PLAYER_COUNT )+ m_scoutSeenFrame[ m_scoutTargetFor[ slot ] ] = now;+const Int count = ThePlayerList->getPlayerCount();- for( Int tries = 0; tries < count; ++tries )- {- m_scoutTargetFor[ slot ] = (m_scoutTargetFor[ slot ] + 1) % count;+ const AIDifficultyProfile *profile = getSkillProfile();+ const UnsignedInt fresh = REAL_TO_INT_CEIL( profile->m_scoutIntervalSeconds * LOGICFRAMES_PER_SECOND );++ Int bestNdx = -1;+ Real bestScore = 0.0f;+ Coord3D bestPos;- Player *p = ThePlayerList->getNthPlayer( m_scoutTargetFor[ slot ] );+ for( Int i = 0; i < count && i < MAX_PLAYER_COUNT; ++i )+ {+ Player *p = ThePlayerList->getNthPlayer( i );if( p == NULL || p == m_player )continue;if( m_player->getRelationship( p->getDefaultTeam() ) != ENEMIES )continue;- if( playerStartPosition( m_scoutTargetFor[ slot ], pos ) )- return TRUE;++ Bool taken = FALSE;+ for( Int other = 0; other < MAX_AI_SCOUTS; ++other )+ if( other != slot && m_scoutID[ other ] != INVALID_ID && m_scoutTargetFor[ other ] == i )+ taken = TRUE;+ if( taken )+ continue; // the other scout is already on its way there++ Coord3D there;+ if( !playerStartPosition( i, &there ) )+ continue;++ Real dx = there.x - from->x;+ Real dy = there.y - from->y;+ Real dist = (Real)sqrt( dx*dx + dy*dy );++ Real score = aiScoutScore( now, m_scoutSeenFrame[ i ], dist, fresh );+ if( score <= 0.0f )+ continue; // looked at recently enough that the walk would buy nothing++ if( bestNdx < 0 || score > bestScore )+ {+ bestNdx = i;+ bestScore = score;+ bestPos = there;+ }}- return FALSE;++ if( bestNdx < 0 )+ return FALSE; // everything worth seeing has been seen recently enough++ m_scoutTargetFor[ slot ] = bestNdx;+ *pos = bestPos;+ return TRUE;}//----------------------------------------------------------------------------------------------------------@@ -4166,7 +4227,7 @@ void AIPlayer::doScouting( void )continue; // still on its wayCoord3D goal;- if( nextScoutTarget( slot, &goal ) )+ if( nextScoutTarget( slot, scout->getPosition(), &goal ) ){ai->aiMoveToPosition( &goal, CMD_FROM_AI );ordered = TRUE;@@ -4369,7 +4430,7 @@ void AIPlayer::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 3; // 2: the scout 3: skill rung and role+ XferVersion currentVersion = 4; // 2: the scout 3: skill rung and role 4: the scouting stampsXferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -4533,6 +4594,12 @@ void AIPlayer::xfer( Xfer *xfer )xfer->xferInt( &m_scoutTargetFor[ scoutSlot ] );}}+ // when each start position was last looked at, so a loaded game does not re-tour a map it knows+ if( version >= 4 )+ {+ for( Int startNdx = 0; startNdx < MAX_PLAYER_COUNT; ++startNdx )+ xfer->xferUnsignedInt( &m_scoutSeenFrame[ startNdx ] );+ }if( version >= 3 ){xfer->xferInt( &m_retreatTimer );diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cppindex f7073962e..fe58ec4da 100644--- a/GeneralsMD/Code/Main/WinMain.cpp+++ b/GeneralsMD/Code/Main/WinMain.cpp@@ -958,6 +958,11 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,ApplicationIsWindowed=true;ApplicationIsBorderless=true;}+ // same again: -headless draws nothing, so it has no business owning the display mode.+ // The device is created windowed (parseHeadless) and dx8wrapper then shrinks this+ // window to the headless resolution - it only has to be born windowed.+ if (stricmp(token,"-headless")==0)+ ApplicationIsWindowed=true;token = nextParam(NULL, "\" ");}diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex c4d33e96b..38debc957 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -5817,6 +5817,9 @@ TEST(the_difficulty_ladder_climbs_in_every_direction_it_should)CHECK( upper.m_retreatIndividualUnits >= lower.m_retreatIndividualUnits );CHECK( upper.m_retreatTeams >= lower.m_retreatTeams );CHECK( upper.m_useInfluenceMapForAttackLane >= lower.m_useInfluenceMapForAttackLane );+ // ... and it is off at every rung today: it measured as two wins in twenty worse than+ // aiming at the base. See the note on the table in AI.cpp before switching it back on.+ CHECK( !upper.m_useInfluenceMapForAttackLane );CHECK( upper.m_focusFire >= lower.m_focusFire );CHECK( upper.m_savesSciencePoints >= lower.m_savesSciencePoints );CHECK( upper.m_adaptiveHarvesters >= lower.m_adaptiveHarvesters );@@ -5921,18 +5924,67 @@ TEST(retreat_ratio_measures_the_exchange_not_the_health_bar)// already dead is not a fight to stay in eitherCHECK_NEAR( 0.0f, aiRetreatRatio( 0.0f, 10.0f, 10.0f, 10.0f ), 0.0001f );- // and the ladder's thresholds mean what they say: at Brutal's 0.8 a force that lasts three- // quarters as long as the one it is fighting breaks off, and one that lasts as long does not+ //+ // The ladder's thresholds mean what they say, and where they sit was measured rather than+ // guessed: at the roadmap's 0.8 a force quit a fight it was very nearly winning, and Merciless+ // lost 4-7 to Easy - which does not know how to retreat and simply kept shooting. They are+ // "clearly losing" numbers now. A force that lasts a third as long as the one it faces breaks+ // off at every rung that retreats at all; one at parity never does.+ //TAiData data;const Real brutal = data.m_skill[ AISKILL_BRUTAL ].m_retreatTtkRatio;- CHECK( aiRetreatRatio( 75.0f, 10.0f, 100.0f, 10.0f ) < brutal );+ CHECK( aiRetreatRatio( 30.0f, 10.0f, 100.0f, 10.0f ) < brutal );CHECK( aiRetreatRatio( 100.0f, 10.0f, 100.0f, 10.0f ) >= brutal );+ CHECK( aiRetreatRatio( 75.0f, 10.0f, 100.0f, 10.0f ) >= brutal ); // three quarters is not lost+ CHECK( brutal < 0.6f ); // anything above this is quitting fights it can win// the bottom rung has no threshold at all: it never quits, which is what makes it EasyCHECK_EQ( 0.0f, data.m_skill[ AISKILL_EASY ].m_retreatTtkRatio );}+/** A3's scouting is a tour, not a search: the start positions are public - the lobby shows them and+ playerStartPosition reads the same fact - so the AI never has to find the enemy, only find out+ what is standing there now. That turns the target pick into "whose picture is stalest per step+ walked", recomputed at every arrival, and it is what stopped the scout walking a blind lap of the+ player list past bases the other scout had just refreshed. */+TEST(scouting_goes_where_the_picture_is_stalest_per_step)+{+ const UnsignedInt NOW = 30000; // a bit over sixteen minutes in+ const UnsignedInt FRESH = 60 * 30; // a rung's scouting interval, in frames++ // a place nobody has been to carries the largest age there is, so at equal walks it goes first+ CHECK( aiScoutScore( NOW, 0, 1000.0f, FRESH ) > aiScoutScore( NOW, 1, 1000.0f, FRESH ) );+ CHECK( aiScoutScore( NOW, 0, 1000.0f, FRESH ) > aiScoutScore( NOW, NOW - FRESH, 1000.0f, FRESH ) );++ // ... and among places nobody has been to, the near one goes first+ CHECK( aiScoutScore( NOW, 0, 100.0f, FRESH ) > aiScoutScore( NOW, 0, 4000.0f, FRESH ) );++ // distance is a divisor, not a veto: a picture twenty times as old is worth twice the walk+ CHECK( aiScoutScore( NOW, NOW - 20000, 1000.0f, FRESH ) > aiScoutScore( NOW, NOW - 5000, 500.0f, FRESH ) );++ // and the trade goes the other way when the far one is only slightly staler - a scout that+ // crosses the map for a marginally older picture is a scout that is never anywhere useful+ CHECK( aiScoutScore( NOW, NOW - 4000, 4000.0f, FRESH ) < aiScoutScore( NOW, NOW - 3800, 100.0f, FRESH ) );++ //+ // The trip this used to make every lap for nothing: the round robin walked to the next start+ // position whether or not it had just been there, at 100% certainty about where it was. A+ // picture younger than the rung's interval now scores zero, which the caller reads as "stay".+ //+ CHECK_EQ( 0.0f, aiScoutScore( NOW, NOW - 10, 100.0f, FRESH ) );+ CHECK_EQ( 0.0f, aiScoutScore( NOW, NOW, 100.0f, FRESH ) );+ CHECK( aiScoutScore( NOW, NOW - FRESH, 100.0f, FRESH ) > 0.0f ); // exactly due is due++ // no rung is allowed to keep a scout parked for ever: every picture goes stale eventually+ CHECK( aiScoutScore( NOW, 1, 100.0f, FRESH ) > 0.0f );++ // standing on the thing does not divide by zero, and is still the best place to look from+ CHECK( aiScoutScore( NOW, 0, 0.0f, FRESH ) > 0.0f );+ CHECK_EQ( aiScoutScore( NOW, 0, 0.0f, FRESH ), aiScoutScore( NOW, 0, 1.0f, FRESH ) );+}++/** C2: whether a finished wave waits at the rally point or goes now. EA sent every team the momentit was ready, and a string of small waves is free veterancy for whoever is on the other end.Three things override the arithmetic, and each of them is a way of getting the AI stuck if it isdiff --git a/ai-batch.ps1 b/ai-batch.ps1index 9d93d2d55..2d2f3c083 100644--- a/ai-batch.ps1+++ b/ai-batch.ps1@@ -1,4 +1,4 @@-<#+<#.SYNOPSISRuns a batch of headless skirmishes and reports the win rate.@@ -27,6 +27,8 @@ param([int] $Players = 2,# easy | medium | brutal (anything else is read as brutal by the game)[string] $Difficulty = "brutal",+ # rung for the odd-numbered slots; empty means the same as -Difficulty, so a rung plays itself+ [string] $Difficulty2 = "",# a match that has not been decided by here is a result in itself: the AI cannot finish[int] $MaxFrames = 30000,# names this batch's logs, so two batches can be compared afterwards@@ -69,6 +71,8 @@ for ($i = 0; $i -lt $Runs; $i++) {"-maxframes", $MaxFrames,"-logPrefix", $prefix)+ # a second rung for the odd slots, so one rung can be played against another+ if ($Difficulty2) { $args += "-aidiff2"; $args += $Difficulty2 }Write-Host ("[{0,3}/{1}] seed {2} cells {3} ... " -f ($i + 1), $Runs, $i, $cells) -NoNewline$sw = [Diagnostics.Stopwatch]::StartNew()@@ -115,7 +119,7 @@ for ($i = 0; $i -lt $Runs; $i++) {# ---------------------------------------------------------------------------------------------Write-Host ""-Write-Host "=== $Tag : $Runs matches, $Players players, $Difficulty, cap $MaxFrames frames ==="+Write-Host "=== $Tag : $Runs matches, $Players players, $Difficulty$(if ($Difficulty2) { " vs " + $Difficulty2 }), cap $MaxFrames frames ==="$decided = @($rows | Where-Object { $_.Why -eq "decided" })Write-Host ("decided {0}/{1} frame-limited {2} failed {3}" -f@@ -147,7 +151,7 @@ $summary = foreach ($p in $slotIds) {AvgSpent = [math]::Round(($mine | Measure-Object Spent -Average).Average, 0)}}-$summary | Format-Table -AutoSize+if ($summary) { $summary | Format-Table -AutoSize | Out-String | Write-Host }# the per-match detail, for whoever wants to look at one game rather than the average$csv = Join-Path $RunDir "$Tag-batch.csv"