system
Given the following post, respond as if you're commenting on Reddit:
human
How does the "AI" work in old RTS games?

Unsure if it is the right sub, let me know if there is a better sub for this question.

I am currently playing an old RTS game from 2004, there are three factions, all with different advantages and disadvantages. 

There are many different ways to play the game, defensive, offensive, with flight units or ground units, ranged or melee units, or all combined.

In the highest difficulty level it doesn't matter what you do, the AI always finds the best strategic answer and is almost impossible to defeat. I also checked in the replay if the AI cheats, i.e. gets more resources or has shorter construction times, this is not the case.

While chess is a game that can be calculated to a certain depth, RTS games are much, much more dynamic and especially in real time, so the algorithm must work very differently, I think as a layman.

So it must be scripted somehow, but you can't have a script for every scenario in an RTS game, much more, often a strategic deviation from the previous plan is required, which the AI also masters perfectly.

&#x200B;

So how the hell does that work?
gpt
most ais do cheat, but not in the way you are thinking.

for one, most rts ais don't respect "fog of war". they know exactly where you are and what you're doing. it's similar to how most fighting game ais actually determine what they are going to do based on your inputs.

they may not have shorter build times or get free resources, but most of them operate at superhuman levels of speed. it might take you half a second to hit a couple hotkeys to queue the production of a unit, or place a building. ais typically do this orders of magnitude more quickly. this advantage just snowballs over the course of a game.

with those two advantages, it's not that hard to develop an ai that's really difficult and seems like it's more advanced than it really is. hard-code a few decisions - if they make x, i make y; favor attacking when they are away from defenses; only attack when i know i have more units - and combine that with more efficient resource management and knowing exactly where you are at all times, and you have something that's hard to beat.

combine that with the sense that most rts game design is slightly advanced rock-paper-scissors, too. there's a lot of surface level complexity with tons of units and such, but most of the time game designers are going "i need to design a unit that tempers the strength of this other unit" and so they immediately know strengths and weaknesses to inform ai decisions.