First off I'm going to state that I am a noob at c++. Anyways I was wondering how games manage to have large amounts of AI all running at the same time. For instance, starcraft, (rts games in general). How is it possible to have so many things happening once on screen with only 2 or 4 cpu cores/threads? Especially since it feels like it's practically instant? I was thinking it'd be like a global while loops for all the variables but I'm not sure?
They run different threads of execution. It's like running multiple processes at the same time.
with only 2 or 4 cpu cores/threads
A 4 GHz processor can execute one instruction in about 250 picoseconds. With 4 cores, you might quadruple that. Put another way, with 4 cores you can execute about 16,000,000,000 instructions in one second. That's a whole WHOLE lot of instructions so it's really no wonder that the game can do a lot of AI.
The real question is "why does everything else run so slowly?" Programs are plagued with inefficient code.