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): -aidiff2 for real, and the ladder measured properly this time
Olcay Seygan6eddea9684f2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 89c839c5a..c93630b29 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -77,7 +77,8 @@ found and fixed — EA's own, not port damage.**- Easy, Steady, Medium, Hard, Brutal, Merciless. Medium to Brutal used to be a cliff; the steps in between are where a player actually needs them.- Every level plays by your rules. No level gets extra money, cheaper units, faster building, longer vision or tougher units - in either direction. What changes is what the computer is allowed to decide: how often it looks at the map, how long it takes to react, whether it counters what you field, whether it masses before attacking, whether it pulls damaged units out.-- Each step up switches on exactly one new thing, so you can say in a sentence what you get for climbing. Easy is slow and brave. Steady saves its damaged units. Medium expands on its own. Hard counters your build. Brutal masses and commits. Merciless is the ceiling - everything on, no hesitation.+- Each step up switches on exactly one new thing, so you can say in a sentence what you get for climbing.+- Measured, not asserted: Merciless beats Easy 15-0 over 32 headless matches with the seats swapped both ways, on twice the army and twice the spending. Easy is slow and brave. Steady saves its damaged units. Medium expands on its own. Hard counters your build. Brutal masses and commits. Merciless is the ceiling - everything on, no hesitation.- Making Easy easier means giving it worse decisions, never less money. That is the whole promise.- The computer also picks a personality each match and keeps it: one plays for the attack, the other for the base. Same resources, spent differently.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex 55f998e4c..40d6182f4 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -351,6 +351,7 @@ public:Int m_autoSkirmishAIState; ///< SlotState the AI slots of an auto-started skirmish get (-aidiff)Bool m_autoSkirmishObserver; ///< -observer: the local slot of an auto-started skirmish watches instead of playingBool m_headless; ///< -headless: never draw a frame, never pace the logic tick, quit when the match ends+ Int m_autoSkirmishAIStateOdd; ///< -aidiff2 <name>: rung for the odd-numbered slots (0 = same as -aidiff)Int m_maxGameFrames; ///< -maxframes <n>: quit after n logic frames however the match is going (0 = no limit)AsciiString m_netGameHosts; ///< -netgame <ip>[,<ip>...]: the slot list of a LAN game started from the command line (empty = off)Int m_netGameLocalSlot; ///< -netslot <n>: which of those addresses this copy of the game isdiff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cppindex 539117263..d7f78e296 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp@@ -1023,6 +1023,33 @@ Int parseAIDifficulty(char *args[], int num)return 2;}+/** -aidiff2 <name>: give the odd-numbered skirmish slots a different rung from -aidiff.+ *+ * Without this the batch runner can only play a rung against itself, which says nothing about+ * whether the ladder is a ladder. The whole no-cheat design (AI-ROADMAP.md D6) rests on higher+ * rungs actually beating lower ones through better decisions, and that is not a claim to make+ * without measuring it. */+Int parseAIDifficulty2(char *args[], int num)+{+ if (TheWritableGlobalData && num > 1)+ {+ AsciiString difficulty = args[1];+ if (difficulty.compareNoCase("easy") == 0)+ TheWritableGlobalData->m_autoSkirmishAIStateOdd = SLOT_EASY_AI;+ else if (difficulty.compareNoCase("steady") == 0)+ TheWritableGlobalData->m_autoSkirmishAIStateOdd = SLOT_STEADY_AI;+ else if (difficulty.compareNoCase("medium") == 0 || difficulty.compareNoCase("med") == 0)+ TheWritableGlobalData->m_autoSkirmishAIStateOdd = SLOT_MED_AI;+ else if (difficulty.compareNoCase("hard") == 0)+ TheWritableGlobalData->m_autoSkirmishAIStateOdd = SLOT_HARD_AI;+ else if (difficulty.compareNoCase("brutal") == 0)+ TheWritableGlobalData->m_autoSkirmishAIStateOdd = SLOT_BRUTAL_AI;+ else+ TheWritableGlobalData->m_autoSkirmishAIStateOdd = SLOT_MERCILESS_AI;+ }+ return 2;+}+Int parseObserver(char *args[], int num){if (TheWritableGlobalData)@@ -1470,6 +1497,7 @@ static CommandLineParam params[] ={ "-fps", parseFPSLimit },{ "-autoskirmish", parseAutoSkirmish },{ "-aidiff", parseAIDifficulty },+ { "-aidiff2", parseAIDifficulty2 },{ "-observer", parseObserver },{ "-headless", parseHeadless },{ "-maxframes", parseMaxGameFrames },diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex c2cdc03bd..0de79d6c1 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -326,7 +326,11 @@ static void startAutoSkirmish( void )}else{- slot.setState( (SlotState)TheGlobalData->m_autoSkirmishAIState );+ // -aidiff2 gives the odd slots a different rung, so a batch can play one against another+ Int state = TheGlobalData->m_autoSkirmishAIState;+ if ((i & 1) && TheGlobalData->m_autoSkirmishAIStateOdd != 0)+ state = TheGlobalData->m_autoSkirmishAIStateOdd;+ slot.setState( (SlotState)state );slot.setPlayerTemplate( PLAYERTEMPLATE_RANDOM );}slot.setColor( -1 ); // -1 is "random" to populateRandomSideAndColordiff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex 6b39691fb..78f764c4d 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -671,6 +671,7 @@ GlobalData::GlobalData()m_fixedSeed = -1; // disabledm_autoSkirmishPlayers = 0; // no skirmish from the command linem_autoSkirmishAIState = SLOT_BRUTAL_AI;+ m_autoSkirmishAIStateOdd = 0; // 0 = not set: every slot plays at -aidiffm_autoSkirmishObserver = FALSE;m_headless = FALSE;m_maxGameFrames = 0; // run until the match endsdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cppindex c832ef08b..4fe7f1549 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp@@ -1021,11 +1021,13 @@ Real AI::getAdjustedVisionRangeForObject(const Object *object, Int factorsToCons* 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.+ * enemy's most valuable visible cell instead of the middle of his base - and measured against+ * itself it does not pay: with one rung copied onto the other so the lane was the only+ * difference, and both seats played, it went 7-9 over 32 matches, and the side using it took+ * twice the losses for half the kills. Aiming at the money means walking past the army. The+ * roadmap's actual proposal is to come in where the *defence density* is lowest, which is the+ * threat map rather than the cash map; getMostValuableVisibleLocation and+ * influenceMapAttackGoal are kept for that attempt.** scoutS maxSc react decis cntr mass ttk indiv team infl focus save harv expand guard hoard */static const AIDifficultyProfile s_defaultSkillLadder[ AISKILL_COUNT ] =diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 38debc957..b74b7ca8b 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -5817,8 +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.+ // ... and it is off at every rung today: measured against itself with the lane as the only+ // difference and both seats played, it went 7-9 over 32 matches. 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 );