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.

docs(changelog): call the top ai level hard, as the game does

Olcay Seygan573abfc07c8b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 65c1cb48b..41612bc7a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -50,7 +50,7 @@ found and fixed — EA's own, not port damage.**
- The new command bar stopped eating half the frame. The clock and the frame counter in the top right corner sat inside the bar's own page, so every tick of them had the whole bar laid out again from scratch, 15ms a time and thirty times a second. The corner box is a page of its own now, the scoreboard counts again twice a second instead of every frame, and a click on the battlefield no longer lays the bar out twice. In the same four-player battle, almost half the frames used to miss 60 a second; now fewer than one in four hundred do, and the game draws more than twice as many frames. When the bar does have to be laid out again, on a hover, a click on it or the scoreboard's twice-a-second count, it takes 2ms where it took 14: the page engine was building an object for every word of the bar's style sheet and every space of its indenting, and reading the same style sheet from scratch each time. All ten pages were laid out both ways and every box and every word came out in the same place, size and colour.
- A screen full of fire and smoke is cheaper to draw. Thirty Inferno Cannons shelling twenty Crusaders used to send the graphics card 459 separate batches of see-through effects a frame, mostly the same texture again and again, and the game looked up the same seven card settings from scratch for every one of them. Matching effects go out together now, and settings that have not changed are not looked up again: 177 batches, and the same battle went from 11.6ms a frame to 8.6ms. It is at 6.7ms now, since the game stopped preparing everything it draws a second time for a copy of the picture nobody sees. Nothing on screen changes, the effects are drawn in exactly the order they were.
- The same battle with the particle limit turned up costs 7.6ms a frame where it cost 9.1ms, and the old renderer went from 9.3ms to 6.3ms. Both were keeping a count of every kind of draw the game makes, and both did it by writing out and reading back a description of each one, on every draw, for a report no player ever opens. They glance at one draw in sixteen now. The new renderer also stopped re-sending the graphics card settings it had just sent.
-- The new renderer stopped redoing work between two pieces of ground that look the same. The map's terrain goes out as hundreds of tiles a frame under the same camera and the same settings, and for every tile the game worked the camera's arithmetic out again, rebuilt its description of the surface and of each texture's filtering, and compared the lot with the tile before. It now notices nothing was changed and goes straight to drawing. The fog of war is sent to the card only where it moved since the last frame, instead of all of it every frame. Two brutal computer players on Twilight Flame at 1920x1080 went from 2.46ms a frame to 2.24ms, and every picture is the one it was.
+- The new renderer stopped redoing work between two pieces of ground that look the same. The map's terrain goes out as hundreds of tiles a frame under the same camera and the same settings, and for every tile the game worked the camera's arithmetic out again, rebuilt its description of the surface and of each texture's filtering, and compared the lot with the tile before. It now notices nothing was changed and goes straight to drawing. The fog of war is sent to the card only where it moved since the last frame, instead of all of it every frame. Two Hard computer players on Twilight Flame at 1920x1080 went from 2.46ms a frame to 2.24ms, and every picture is the one it was.
- The command bar and the observer's panel stopped reading their own pages from scratch every frame. The bar's page alone is 38 KB, and the game copied it, lowercased it and hunted through it for the blanks four times a frame before it wrote in a single number. Each page is read once now, and a frame only fills in the numbers. The same two computer players on Twilight Flame went from 2.03ms a frame to 1.84ms watched as an observer, and from 2.75ms to 2.50ms from a player's seat. Every page still comes out letter for letter as it did: two matches filled 270,000 of them both ways and found no difference.
- Ground painted with a third texture, the dirt over grass and the rock over sand, cost a trip to the memory manager for every corner of every such patch on screen, every frame, only to light that corner. Nearly a tenth of the game's time went to taking and releasing the memory manager's lock for it. Lighting a corner asks for nothing now: the same Twilight Flame match went from 1.88ms a frame to 1.71ms as an observer and from 2.56ms to 2.26ms from a player's seat, and eight views over five maps came out the same as before.
- The command bar stopped throwing its own layout away every frame. The few hundred positions and sizes it hands its page were written into a fresh list each frame, copied twice for the frames in front of the buttons, and thrown out, and every price and build time on a button was looked up by copying the text of every figure the bar was already showing. The list is written over in place now, nothing is copied, and the graphics card settings that did not change between two draws are not looked up again. The same Twilight Flame match from a player's seat went from 2.29ms a frame to 1.96ms, and as an observer from 1.64ms to 1.58ms. The picture is the same one.
@@ -127,7 +127,7 @@ found and fixed — EA's own, not port damage.**
- USA's Chinooks stop collecting over the command center. When the pile beside a supply centre ran out, its Chinooks flew home and hovered, and the computer went on buying new ones for its other centres while those sat idle. It only looked for an idle gatherer when a pile stood right next to the centre, a fraction of how far a Chinook looks. An idle gatherer is now sent to any of its supply centres with a pile inside that gatherer's own range, and nothing new is bought while one stands idle beside a pile that has no room for it.
- It keeps its lights on, and keeps them out of reach. Its plan carries a fixed number of power plants and nothing ever adds one, so a raid that took two of them left the base underpowered - radar dark, base defences off, superweapon clock stopped - until a rebuild timer came round and put the new plant back on the spot the raid already knew the way to. It now buys a plant when the margin gets thin rather than when the meter reads zero, and puts it on the far side of the base from whoever it is fighting.
- Spare cash also buys a gun on the side the trouble comes from. Production and income go up around the middle of the base, the power goes behind it, and base defences go out in front, so money that keeps arriving thickens the base in the order a base wants to be thick in. Front means towards the nearest enemy, which is not the same as the one it has decided to attack - that one can be across the map, and a wall built facing it has its back to the neighbour. The walls grow with the army. One gun every minute and a half, never more than ten, used to be the rule; now the computer may stand one gun for every four fighting units it has, so a big army comes home to a fortress and a beaten one rebuilds its tanks before its bunkers. Letting it buy guns on every pass instead was tried first: 241 guns over twelve four-player matches, and they ate the army, down to 60 kills a match from 73. Tied to the army, 71 guns, and the army is the biggest of any version tried, 78 kills a match.
-- Hard builds its superweapon as soon as it can pay for one and has the guns to stand it on, and then another. Its scripts held the first one back behind a clock that ran for twelve and a half minutes, seven and a half if you had built your own tech building first, and then allowed exactly one: a player who took on seven Hard computers at once saw a single nuke all match. There is no clock now. The tech building that unlocks it goes up first, and the superweapon follows once the money is in the bank and four of its guns stand finished, the rule every player keeps (see the lobby section). More follow as the base grows, one for every four guns, so a computer holding twenty guns can stand five superweapons. Before that rule it put its first particle cannon up at 4.3 minutes on Twilight Flame and its first nuke at 4.9, without a gun to its name. Over 24 matches between two Brutal computers on the same map, the first nuke now goes up at 6.2 minutes as a rule, anywhere from 4.4 to 9.8, and the first Particle Cannon at 7.4. The Scud Storm comes last at 7.6 but never later than 8.7, and every GLA side had one inside ten minutes, where 4 of the 32 China and USA sides were still waiting for theirs. The lobby's superweapon limit and Pro Rules still apply to the computer exactly as they do to you.
+- Hard builds its superweapon as soon as it can pay for one and has the guns to stand it on, and then another. Its scripts held the first one back behind a clock that ran for twelve and a half minutes, seven and a half if you had built your own tech building first, and then allowed exactly one: a player who took on seven Hard computers at once saw a single nuke all match. There is no clock now. The tech building that unlocks it goes up first, and the superweapon follows once the money is in the bank and four of its guns stand finished, the rule every player keeps (see the lobby section). More follow as the base grows, one for every four guns, so a computer holding twenty guns can stand five superweapons. Before that rule it put its first particle cannon up at 4.3 minutes on Twilight Flame and its first nuke at 4.9, without a gun to its name. Over 24 matches between two Hard computers on the same map, the first nuke now goes up at 6.2 minutes as a rule, anywhere from 4.4 to 9.8, and the first Particle Cannon at 7.4. The Scud Storm comes last at 7.6 but never later than 8.7, and every GLA side had one inside ten minutes, where 4 of the 32 China and USA sides were still waiting for theirs. The lobby's superweapon limit and Pro Rules still apply to the computer exactly as they do to you.
- Hard trains more builders when it has work for them. It only ever made a new dozer after losing all of them, so it played every match on the two it had, and every building it bought queued behind those two. On Twilight Flame a third of the China Tank computers never got round to a war factory, never sent an attack, and ended up sitting in a ring of bunkers on a pile of cash. Now, with money in the bank and every dozer busy, it trains another, up to four. Over six four-player matches on that map, every computer built its war factories, the attack waves went from 39 to 82, and each one spent half as much again.
- Hard no longer rebuilds its factories inside your base. A busy computer puts its next war factory beside its newest expansion, and it remembered that expansion forever: after you destroyed the supply centre there, even one it had built right next to your base, it kept putting the factory back up on the same spot. It now only builds beside an expansion it still holds, and only one nearer its own base than yours.
- Hard keeps its lights on. It asked for a new power plant before running out, and the request then sat in a queue behind everything else its plan wanted: one China waited 95 seconds for a plant with 26,000 in the bank, every builder busy, and went dark halfway. A plant now jumps that queue once the margin is thin, a busy builder is taken off whatever it is doing to put it up, and while the base is dark the computer buys nothing else. Over eight four-player matches the time its bases spent without power fell by a third, from 42 minutes to 28 across all of them.
@@ -596,7 +596,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- Circular range checks are circles now, not the square drawn around them.
- A tunnel network heals at one rate, however many entrances it has.
-- GLA units take the tunnels on their own. Give a move order across the map, and if the way through your network is any shorter than the walk, the whole selection goes down the tunnel nearest it and comes up at the one nearest where you sent it, then walks the rest. An attack move does the same and comes up still attack-moving, and fresh units heading for a rally point across the map take the tunnels too, fighting on the way if they would have walked there fighting. The tunnels used to have to be almost a third shorter before anybody took them, so fresh units with a tunnel beside their barracks and one beside the rally point mostly walked anyway. Passing through does not count as resting: only units you put inside yourself are healed. The group decides together: fifteen Rebels with six places already taken all go through, where a first version sent ten underground and walked the other five. The green order line shows it: one line to the tunnel they go down and one from the tunnel they come up at to where you sent them. Twelve Rebels crossing a small map with a tunnel at each end got there in 21 seconds instead of 50, four Scorpions in 9 instead of 21. A tunnel that has just been hit is skipped, so nobody surfaces into the fire. So is one still going up or being sold: a tunnel you had only just placed used to count straight away, and units sent across the map queued up at a building site. A tunnel rising again out of a GLA hole counts as going up until it is finished, and units underground when the tunnel they went down is destroyed no longer come up at one. The computer does it too: a GLA team losing a fight near one of its tunnels falls back underground and comes up at home, which happened 10 to 25 times a match in four Brutal GLA mirrors on Twilight Flame, and an attack wave takes the tunnels when they come up nearer your base than its road does. And the computer now digs them on purpose: a tunnel at home, one at the expansion it holds, and one three quarters of the way down the road its next wave will take, as long as nothing it has seen there can shoot. It does not wait for a fat bank to do it: a tunnel costs 800 and pays back on the first wave. In four Brutal GLA mirrors on Twilight Flame, 10 of 49 attack waves went underground, where none had before, and beaten teams fell back through a tunnel 250 times. Units you put in a tunnel yourself stay put, and a network they have filled is left alone: the order walks. With one place free, everybody still goes through it one after the other, since a unit passing through leaves the moment it arrives. Replays recorded before this change play out differently.
+- GLA units take the tunnels on their own. Give a move order across the map, and if the way through your network is any shorter than the walk, the whole selection goes down the tunnel nearest it and comes up at the one nearest where you sent it, then walks the rest. An attack move does the same and comes up still attack-moving, and fresh units heading for a rally point across the map take the tunnels too, fighting on the way if they would have walked there fighting. The tunnels used to have to be almost a third shorter before anybody took them, so fresh units with a tunnel beside their barracks and one beside the rally point mostly walked anyway. Passing through does not count as resting: only units you put inside yourself are healed. The group decides together: fifteen Rebels with six places already taken all go through, where a first version sent ten underground and walked the other five. The green order line shows it: one line to the tunnel they go down and one from the tunnel they come up at to where you sent them. Twelve Rebels crossing a small map with a tunnel at each end got there in 21 seconds instead of 50, four Scorpions in 9 instead of 21. A tunnel that has just been hit is skipped, so nobody surfaces into the fire. So is one still going up or being sold: a tunnel you had only just placed used to count straight away, and units sent across the map queued up at a building site. A tunnel rising again out of a GLA hole counts as going up until it is finished, and units underground when the tunnel they went down is destroyed no longer come up at one. The computer does it too: a GLA team losing a fight near one of its tunnels falls back underground and comes up at home, which happened 10 to 25 times a match in four Hard GLA mirrors on Twilight Flame, and an attack wave takes the tunnels when they come up nearer your base than its road does. And the computer now digs them on purpose: a tunnel at home, one at the expansion it holds, and one three quarters of the way down the road its next wave will take, as long as nothing it has seen there can shoot. It does not wait for a fat bank to do it: a tunnel costs 800 and pays back on the first wave. In four Hard GLA mirrors on Twilight Flame, 10 of 49 attack waves went underground, where none had before, and beaten teams fell back through a tunnel 250 times. Units you put in a tunnel yourself stay put, and a network they have filled is left alone: the order walks. With one place free, everybody still goes through it one after the other, since a unit passing through leaves the moment it arrives. Replays recorded before this change play out differently.
- Units a move order takes through the tunnels come out still selected. Going underground took each one off your selection and nothing put it back, so a group sent across the map surfaced as nobody's and had to be picked up again by hand. A trip you order by clicking a tunnel still leaves the selection the way it always has, and picking something else while they are underground means they stay out of it.
- Builders take the tunnels to work. A GLA Worker sent to build, repair or finish a structure goes through the network when that is shorter than the walk, and carries on with the job at the far end. The same holds for the builder of any side that has tunnels. Replays recorded before this change play out differently.
@@ -751,7 +751,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
living player's account on the minute, on top of whatever they are mining, which is the knob a
mod or a map needs to run a game that is not about holding the supply piles. Zero, and therefore
absent, unless somebody asks for it: on a stock install nothing changes. Measured on one seed with
- four brutal computers at 7,777 a minute, three of the four spent between 3,400 and 6,200 more in
+ four Hard computers at 7,777 a minute, three of the four spent between 3,400 and 6,200 more in
the first three minutes and put the difference on the map.
- The minimap says where the money and the capturable buildings are, with the dollar and the star from the lobby map preview. Oil derricks, hospitals and repair pads never showed on it at all, and supply piles vanished with the rest of the map under the fog, so the two things worth walking a rifleman across the map for were the two things the minimap would not tell you about. They are marked on ground you have walked over, one mark per place rather than one per pile, and the mark stays through the fog once you have been there, because a supply pile does not move. A pile that runs dry drops off it. Country you have never scouted keeps its marks to itself: for a while the minimap gave you every dollar sign on the map from the first second, which is a scouting report nobody paid for.
@@ -1490,7 +1490,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
decides whether a unit is getting anywhere, and the sideways and backwards escape it tries when it
is not, both measured against a point that was always the map's origin. And when that escape asked
for a new route, the request was wiped out in the same frame, so the route never came. Over twenty
- brutal battles on Twilight Flame, units spent 8% less time wedged and 4% less time blocked, with 14%
+ Hard battles on Twilight Flame, units spent 8% less time wedged and 4% less time blocked, with 14%
more new routes actually planned. One of those twenty went the other way: a unit sat stuck for most
of the match, and why is not known yet.
- An Angry Mob arrives with everyone it set off with. The mob is ten people following one invisible