Skip to content

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.

fix(gameengine): drop the chassis-damped aim gain from the crowd steering

Olcay Seygan05b0cf32433b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 81a172c10..67c9da9f2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -616,7 +616,7 @@ found and fixed — EA's own, not port damage.**
- The one tank in thirty that stops for good now gets itself out. A unit that has asked to move and covered no ground for two seconds is not in traffic, it is wedged: between two allies it never quite touches, in the corner of a cliff, behind the one vehicle in the column that is never going to move again. Nothing counted it as blocked, because there was no collision to count, so nothing came to its rescue and it sat there for the rest of the battle. It now measures its own progress against the speed it asked for, and the answer has two rungs. A third of a second of getting nowhere and it stops being polite: no giving way, no moving over, no braking, no spreading out, all of which were costing it the speed it needs to push through. Two seconds and it backs out, to the side and behind, and tries the road again from there. Failing that it turns round. If it is walled in on all four sides it keeps trying and asks again a second later.
- Moving over for someone and joining a road are the same manoeuvre from two sides, and the crowd now does both. A unit coming in at an angle used to be invisible until it was in front of you, at which point everybody braked; the units already on the road now see it crossing their line up to a second and a half ahead and shift a lane over instead, which is what turns a queue into a zipper. The test is a real closest approach rather than a cone, and the courtesy is only extended to traffic that would have made you brake anyway - anything looser and a column spends the whole march shuffling sideways for vehicles driving vaguely alongside it.
- Three ways of building that were measured and thrown away, one of them expensive. Slowing down by how far away the traffic in front is, rather than by whether it is being caught, costs 3518 unit-frames of standing still a battle against 1236. Slowing down behind a unit that is not moving at all costs 16593, and it is the worst kind of bug: braking short of a parked ally means the collision never happens, so nothing counts the unit as blocked and none of the machinery that would have sent it round fires. It dies politely, three feet behind a tank that is never going to move. And standing the rules down for short trips, on the theory that a four-square shuffle inside a fight is not a march, is three times worse than leaving them on: short trips are exactly where units are packed tightest.
-- Light vehicles could not hold a straight line: the head of a scout shook the whole way down a road an Overlord drove dead straight. The point a unit steers at sat two cells and a body ahead, taken from whichever sample of the route it happened to be beside, and both halves of that were wrong for a fast chassis. Samples are a cell apart, so the point jumped ten feet forward each time the unit crossed one and the heading jumped with it; it is taken between samples now, off the unit's own unrounded distance along the route, and slides forward a foot at a time. The other half is that thirty feet of warning is forty frames of road for an Overlord and ten for a scout, so the light stuff was steering at something under its nose where a foot of error is a full lock. Moving the point further out for fast units cured the shake and cost four times the units left stuck - a point fifty feet up the road is measured against the ground fifty feet up the road, and nobody asks about the narrow bit in between - so the chassis difference is dealt with in the wheel instead. The rate a unit turns towards its heading is now cut by how much of that thirty feet it eats in half a second: unchanged for anything heavy, about halved for a scout. It is a lag rather than a different place to drive at, which is the part the other version got wrong.
+- Light vehicles could not hold a straight line: the head of a scout shook the whole way down a road an Overlord drove dead straight. The point a unit steers at sat two cells and a body ahead, taken from whichever sample of the route it happened to be beside, and both halves of that were wrong for a fast chassis. Samples are a cell apart, so the point jumped ten feet forward each time the unit crossed one and the heading jumped with it; it is taken between samples now, off the unit's own unrounded distance along the route, and slides forward a foot at a time. The other half is that thirty feet of warning is forty frames of road for an Overlord and ten for a scout, so the light stuff was steering at something under its nose where a foot of error is a full lock. Two ways of fixing that second half were tried and both cost more than they were worth. Moving the point further out for fast vehicles cured the shake and left four times as many units stuck: a point fifty feet up the road is measured against the ground fifty feet up the road, and nobody asks about the narrow bit in between. Slowing the wheel for them instead - turning towards the new heading at a rate cut by how much road the chassis eats in half a second - was better mannered and still cost nearly four times the stuck units. Lag on the wheel and a point too far ahead fail the same way: both answer where the unit was a moment ago. The sliding point cures the shake on its own, so that is all that is in.
- Vehicles walked off the side of bridges and queued up beside the entrance to them instead of driving on. A unit driving in a crowd holds a line a set distance off the middle of the road, and the road's width is measured by asking the ground either side whether a tank fits on it. On a bridge that question was being asked of the riverbank underneath. So the road read as sixty feet wide over a deck barely wide enough for two tanks, and a line held a body width off centre walked a column into the water - and on the approach, the same line put the leading tank against the abutment rather than the entrance, with everybody behind it stopped on the bank. The width is now measured on the deck the route actually runs over, and both the bridge and forty feet of road each side of it have no width at all: every unit drives the middle of the road across a bridge, which is what the crossing is for.
- Infantry can walk through infantry again. Two soldiers crossing have never blocked each other in this game - only two going the same way do - and the crowd rules had quietly taken that back: a squad crossing another squad read as a wall, and every man in it braked, gave way and shuffled sideways for a crowd he was supposed to walk straight into. The crowd now uses the game's own rule for that, so a column following a column is still traffic and two squads crossing pass through one another.
- None of the crowd was being measured, and the numbers written here for it were another rule's. A unit steers as part of a crowd only if it was handed a line across the road, a line is handed out only by the order a player gives to a selection, and a computer opponent never gives that order: it moves its teams one vehicle at a time. So every self-play batch run to argue about the crowd was driving the two rules that live in the collision code and none of the steering. The harness now has a switch that hands every army on the map one group order every twenty seconds, to alternating corners. The match it produces is nonsense and its result says nothing, but it multiplies the time units spend standing still by fourteen, from around 300 unit-frames a match to 4,200, which is the proof it is finally creating the traffic the crowd was written for.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
index 5e6ecf620..74e866a44 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
@@ -1559,8 +1559,6 @@ static const Int CROWD_STUCK_GIVEUP = 60; ///< two seconds of it: back out of
static const Int CROWD_ESCAPE_FRAMES = 66; ///< and spend this long doing it before giving the route another go
static const Int CROWD_ESCAPE_COOL = 90; ///< no second attempt before this, or a wedged pair rock forever
static const Int CROWD_MERGE_FRAMES = 45; ///< a second and a half: how far ahead a merge is worth noticing
-static const Real CROWD_LOOK_FRAMES = 16.0f; ///< half a second: the travel the aim filter is damped against
-static const Real CROWD_AIM_SLOWEST = 0.08f; ///< however fast the chassis, the aim still follows this much of the error
//-------------------------------------------------------------------------------------------------
/* Returns TRUE if the physics collide should apply the force. Normally not.
@@ -2946,25 +2944,13 @@ void AIUpdateInterface::crowdSteer( Coord3D& goalPos, Real& speed )
|| (blocker != NULL && blockerGap < myR)
|| fabs( err ) > 1.0f;
- /* One gain is the wrong gain for two chassis. The steering point sits a fixed distance in
- front - two cells and a body, about thirty feet - which a heavy tank at 25 covers in forty
- frames and a scout at 90 in ten. Pure pursuit goes unstable when the unit eats its own
- lookahead faster than the wheel settles: the light thing overshoots, the error changes sign,
- it oversteers back, and that is the head shaking players see on fast vehicles and never on
- heavy ones. So the cruising gain is damped by how much of the aim distance the chassis
- covers in half a second. It is a lag, not a different point to drive at: nothing aims
- anywhere it was not already aiming, which is what the horizon experiment got wrong. */
- Real gain = urgent ? CROWD_AIM_URGENT : CROWD_AIM_CRUISE;
- if (!urgent)
- {
- const Real travel = speed * CROWD_LOOK_FRAMES;
- if (travel > aimDist)
- {
- gain *= aimDist / travel;
- if (gain < CROWD_AIM_SLOWEST) gain = CROWD_AIM_SLOWEST;
- }
- }
- m_crowdAim = normalizeAngle( m_crowdAim + err * gain );
+ /* One gain for every chassis, which is not obviously right and is what measured best. Damping
+ the cruising gain for fast vehicles - the same fraction of the aim distance they eat in half
+ a second - was tried against the sliding steering point below and cost 5172 blocked
+ unit-frames a match and 7.5 units left stuck, against 4918 and 2.0 without it. Lag on the
+ wheel and a point further up the road fail the same way in the end: both answer where the
+ unit was a moment ago. The sliding point cured the shake on its own. */
+ m_crowdAim = normalizeAngle( m_crowdAim + err * (urgent ? CROWD_AIM_URGENT : CROWD_AIM_CRUISE) );
if (!urgent && fabs( normalizeAngle( m_crowdAim - self->getOrientation() ) ) < CROWD_AIM_DEAD)
m_crowdAim = self->getOrientation(); // two degrees is not worth a steering input