Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Why end turn take so long?

Reapa

Doom Preacher
Joined
Jul 10, 2009
Messages
2,340
Location
Germany
Run the game with a profiler and look at the disassembly and then you'll find out what's going on.
if i knew what you were talking about i wouldn't be stumbling around in darkness and trying to make sense of what i bump into.
 
Last edited:

whysoserious

Arbiter
Joined
Jun 29, 2012
Messages
108
My perception is that newer games do tend to have less intelligent AI than older games, and that they do tend to take inordinate amounts of time to compute their moves. I base this mainly on the Civ series and the HoMM series.

In the early Civ games (1, 2, and Alpha Centauri), turns took mere seconds. In Civs 3 and 4 turns could take minutes to compute, at least in the later stages of the game. I've heard two possible explanations for this discrepancy on forums, one for each game, but to me they don't seem very plausible. The explanation for Civ 3 is that the game is inefficiently designed so that it has to tabulate every trade route on the map, including redundant ones, so that it has to check thousands of routes every time it processes a turn. The problem with this explanation is that computers should excel at the simple arithmetic of determining trade routes, and that checking even thousands of them every turn shouldn't take a noticeably long time. The explanation for Civ 4 is that the game wastes resources rendering the moves of models obscured by fog of war, irregardless of the fact that those models wouldn't be displayed to the player. This explanation does seem plausible, as rendering so many models would take a lot of time, but I'm doubtful that such a flagrant blunder would be included in such a big budget game. Possibly these rumors are mere myths.

HoMM 2 & 3 compared to HoMM 5 is the same story as with the Civ series: AI in the earlier games took much quicker turns. Perplexingly, AI in the earlier games is also noticeably a lot better than AI in HoMM 5. I know of no clear explanation for this. The only thing that seems evident is that the AI in HoMM 5 is shabbily designed.

I think that generally developers and especially publishers discount the value of AI in strategy games. AI is of fundamental importance to any single player game in the genre, but it is routinely ignored in favor of graphics and novelty features. This is probably sound reasoning from a business standpoint, but it entails turgid gameplay.
 

Reapa

Doom Preacher
Joined
Jul 10, 2009
Messages
2,340
Location
Germany
My perception is that newer games do tend to have less intelligent AI than older games, and that they do tend to take inordinate amounts of time to compute their moves. I base this mainly on the Civ series and the HoMM series.

In the early Civ games (1, 2, and Alpha Centauri), turns took mere seconds. In Civs 3 and 4 turns could take minutes to compute, at least in the later stages of the game. I've heard two possible explanations for this discrepancy on forums, one for each game, but to me they don't seem very plausible. The explanation for Civ 3 is that the game is inefficiently designed so that it has to tabulate every trade route on the map, including redundant ones, so that it has to check thousands of routes every time it processes a turn. The problem with this explanation is that computers should excel at the simple arithmetic of determining trade routes, and that checking even thousands of them every turn shouldn't take a noticeably long time. The explanation for Civ 4 is that the game wastes resources rendering the moves of models obscured by fog of war, irregardless of the fact that those models wouldn't be displayed to the player. This explanation does seem plausible, as rendering so many models would take a lot of time, but I'm doubtful that such a flagrant blunder would be included in such a big budget game. Possibly these rumors are mere myths.

HoMM 2 & 3 compared to HoMM 5 is the same story as with the Civ series: AI in the earlier games took much quicker turns. Perplexingly, AI in the earlier games is also noticeably a lot better than AI in HoMM 5. I know of no clear explanation for this. The only thing that seems evident is that the AI in HoMM 5 is shabbily designed.

I think that generally developers and especially publishers discount the value of AI in strategy games. AI is of fundamental importance to any single player game in the genre, but it is routinely ignored in favor of graphics and novelty features. This is probably sound reasoning from a business standpoint, but it entails turgid gameplay.
i remember civ 4 taking some time for turns in late game but that is to be expected since resource availability and map overview combined with little to no fog of war increase the possibilities and number of things one can do in a turn exponentially. i will have to play the newest civ to see if there's any difference when it comes to early game or wait for someone to comment on that.
i can't imagine civ not having a lot of thought put into its A.I. unlike HOMM. it is interesting however that people generally seem to think older games had faster more capable A.I. while also having more features. i think the complexity of the games has increased for civ with newer releases but HOMM 3 and MoM are yet unparalleled. it's like the companies producing these clones can't copy paste and then add a bit of stuff of their own. it reminds me of 1984 dictionaries that would get smaller and smaller with each new version on purpose. graphics must be pretty expensive if they don't allow for enough budget to copy paste. in such a case it's not surprising at all that A.I. development gets an even shorter stick.
 

Reapa

Doom Preacher
Joined
Jul 10, 2009
Messages
2,340
Location
Germany
A profiler runs a program and tells you how much cpu time was spent on running different parts of that program. Normally you'd run it only during AI turns and then you'd get info on a bunch of calls(functions) and how much % of the cpu they used. Since usually you wouldn't have the source code you'd analyze the assembly (machine code in human readable form) and figure out which part does what. Windows functions should be known and you will see all kinds of system calls too. Then after many hours you would know how much % was spent on sending data to the videocard and AI stuff or maybe doing stupid shit like rendering with the cpu.
sounds like overkill since i pretty much already reduced the problem with MOTBW to bad/cheap programming especially in the case of only being able to use 2 cores in combination with demanding graphics and/or stupid loops. based on such conclusions, the solution to the puzzle at hand could be a philosophical/financial one instead of technical. if after more games have been analyzed patterns should emerge suggesting technical limitations, a closer look at the games' processes could prove useful.
 

Jigawatt

Arcane
Joined
Aug 13, 2009
Messages
3,409
Location
in a desert, walking along in the sand
The sad fact is that experienced and competent developers know that modern game studios are sweatshops, so you won't find many there. And optimising AI isn't a problem you can really StackOverflow your way out of. If you've never heard of some fancy algorithm that solves your problem in n log n you'll probably end up implementing some crappy n^2 version. One particular thing you've mentioned is CPU utilization - these days most developers think of memory as free (everyone has 8GB right?) without realising that failing to keep their working memory in the CPU cache (so, they need to think about locality, layout, and keep it all < 8MB) every round trip made to main memory stalls the CPU for *thousands* of cycles.

Then you've got game specific issues: CivIV for example uses python to drive the AI. It makes it nice and fast to iterate on the rules during development, but at run time is slowed down by a number of factors
- Even if only interpreted once at game start, JIT code is rarely as optimised as compiled
- The python runtime/VM is memory overhead making that cache ever smaller
- No control over finer details of memory layout etc.
- Garbage collector could run at any time, eating up precious milliseconds

And then of course as whysoserious pointed out, publishers have limited incentive to increase AI in terms of either competence or performance. No reviewer is ever going to call you out on it (unless the AI's too good, then it's 'unfair'!), and as seen by CivV if you're aiming for big sales numbers AI is hardly going to be what gets you there (try big friendly buttons and dumbed down mechanics instead)
 

Reapa

Doom Preacher
Joined
Jul 10, 2009
Messages
2,340
Location
Germany
The sad fact is that experienced and competent developers know that modern game studios are sweatshops, so you won't find many there. And optimising AI isn't a problem you can really StackOverflow your way out of. If you've never heard of some fancy algorithm that solves your problem in n log n you'll probably end up implementing some crappy n^2 version. One particular thing you've mentioned is CPU utilization - these days most developers think of memory as free (everyone has 8GB right?) without realising that failing to keep their working memory in the CPU cache (so, they need to think about locality, layout, and keep it all < 8MB) every round trip made to main memory stalls the CPU for *thousands* of cycles.

Then you've got game specific issues: CivIV for example uses python to drive the AI. It makes it nice and fast to iterate on the rules during development, but at run time is slowed down by a number of factors
- Even if only interpreted once at game start, JIT code is rarely as optimised as compiled
- The python runtime/VM is memory overhead making that cache ever smaller
- No control over finer details of memory layout etc.
- Garbage collector could run at any time, eating up precious milliseconds

so this stalling of the cpu for 1000s of cycles would be noticeable as cpu usage peaks or would the cpu just kind of wait idly for as long as those 1000s of cycles would take to complete?

And then of course as whysoserious pointed out, publishers have limited incentive to increase AI in terms of either competence or performance. No reviewer is ever going to call you out on it (unless the AI's too good, then it's 'unfair'!), and as seen by CivV if you're aiming for big sales numbers AI is hardly going to be what gets you there (try big friendly buttons and dumbed down mechanics instead)

i'm pretty sure heroes 6 did not sell well partly due to blatantly cheating A.I. at least on the world map. it was all over the forums. along with the whole lack of proper town screens and the online login requirements for items of course. now heroes 7 was hit with bad publicity over bad A.I. on the tactical field where big creatures could not properly pathfind around obstacles. AND enemy turns taking too long. not sure if i ever read about it but there was obviously some negative feedback there if they released a patch increasing the speed of enemy turns.
based on that it's hard to conclude underestimating A.I. importance in strategy games will get you sales if you just add big buttons. also as far as i'm aware civ 5 never got the same love as civ 4.

https://en.wikipedia.org/wiki/Civilization_V
Some reviews were less positive, with the most common criticisms being directed at the game's artificial intelligence. 1UP.com says that the game features an "A.I. that can't play the game," and noted that the game has "some nice innovations that will make it hard to go back to Civilization IV. But in other ways, it's a disappointment that needs a lot more work."[74] Eurogamer gave the game an 8/10 despite their criticism that "the AI in Civ V is still curiously terrible,"[75] while GameShark gave the game a B+ while stating that "the computer opponents are ill equipped for the military side of things."[76] Other complaints include criticism of the game's speed, which is approximately 5 hours at "normal" game pace.

got a new addition to the list: Endless Legend early game takes 4-5 seconds for end turn with 6 enemies. no 100% cpu peaks. steam says it requires a quad core so it should be able to make use of one to full capacity but maybe i'm just old fashioned in thinking the processor should process stuff instead of idleing around. processor usage does go from 25%/30% to 45%/50% on end turn but something seems to keep it from getting maxed out. it might be the task manager showing me an average usage for such small periods of time instead of accurate samples since it refreshes at about once in 2 seconds. i'm gonna play it a while and see if the turns get longer during mid game / late game and what they do with the cpu.
 
Last edited:

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,562
Location
Tampon Bay
I think it is mostly because of too many calculations that are not really needed, which is again a lack of fine tuning.
When you have algorithms that have O(n^2) complexity, and you double the number of elements the number of iterations goes through the roof.
In the old days the programmers already knew they did not have enough processing power, so they would tune their calculations to the absolute minimum required for an acceptable result.
But with almost unlimited resources programmers will not be conservative any more. They will make sure that their calculations always do as much or more than is required, this usually turns into "more" or "much more" and of course stacks up.
A simple example would be raster images. A computer screen can be limited to show 200 dpi but people could store images with 10,000, "just in case". If you keep in mind that often complexity does not grow linear but exponential, you see where this quickly must lead. A faster computer becomes actually slower until someone hits the brakes.
 

*-*/\--/\~

Cipher
Joined
Jul 10, 2014
Messages
912
Because optimizing that uses resources... and developers prefer to use those on the flashy, visible stuff like new locations and items and whatnot so the fanboys don't scream at them for lack of updates.
 

thesheeep

Arcane
Patron
Joined
Mar 16, 2007
Messages
9,956
Location
Tampere, Finland
Codex 2012 Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming! Serpent in the Staglands Dead State Divinity: Original Sin Torment: Tides of Numenera Codex USB, 2014 Shadorwun: Hong Kong Divinity: Original Sin 2 BattleTech Bubbles In Memoria A Beautifully Desolate Campaign Pillars of Eternity 2: Deadfire Pathfinder: Kingmaker Steve gets a Kidney but I don't even get a tag. Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
It gets easier and easier to make games today, with all those "user-friendly" engines.
The downside of that user-friendlyness is of course that the result of that (aka the actual code produced by Unity-/Blueprint-scripts internally, etc.) is very badly optimized.
Additionally, easy to use tools do not teach the programmer to mind that much what he is doing performance-wise.
I see that as a prime reason for why many games today have such a bad performance compared to older titles.

You really have to understand many low-level coding topics to be able to optimize well. But you don't need any of that knowledge to create a game.
So when you learn to code, do you want to learn about low level optimizations and performance critical code design, or do you want to make a game?
Exactly.

tl;dr: There are more programmers today, but not really more good programmers.
 

Destroid

Arcane
Joined
May 9, 2007
Messages
16,628
Location
Australia
It gets easier and easier to make games today, with all those "user-friendly" engines.
The downside of that user-friendlyness is of course that the result of that (aka the actual code produced by Unity-/Blueprint-scripts internally, etc.) is very badly optimized.
Additionally, easy to use tools do not teach the programmer to mind that much what he is doing performance-wise.
I see that as a prime reason for why many games today have such a bad performance compared to older titles.

You really have to understand many low-level coding topics to be able to optimize well. But you don't need any of that knowledge to create a game.
So when you learn to code, do you want to learn about low level optimizations and performance critical code design, or do you want to make a game?
Exactly.

tl;dr: There are more programmers today, but not really more good programmers.

Most of the games we are discussing are made by professionals in medium sized companies, not by indies and amateurs.
 

Nevill

Arcane
Joined
Jun 6, 2009
Messages
11,211
Shadorwun: Hong Kong
In the old days the programmers already knew they did not have enough processing power, so they would tune their calculations to the absolute minimum required for an acceptable result.
This. There are very few people left who can optimize/economize anymore because it is seen as 'unnecessary'. This is also the reason why you see modern applications require Gigabytes of RAM to run very much the same operations that required 1000 times less mere 15 years ago.

OP, you might want to read about HoMMV AI project, as it is developed by a person who does know his stuff.
http://www.bonddisc.com/ref/h5/ai.htm

Most of the games we are discussing are made by professionals in medium sized companies
You'd be surprized what passes for a professional nowadays. :negative:
 
Last edited:

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,562
Location
Tampon Bay
This is also the reason why you see modern applications require Gigabytes of RAM to run very much the same operations that required 1000 times less mere 15 years ago.

Perhaps not exactly "the same" results. But ever slighter improvements for more and more effort. The problem is people will accept huge increases in calculations for just a slight increase in quality, because they have no understanding how much is right.
More is not better, once adequate results can be achieved at much lower cost. One should never max out algorithms with exponential complexity - but thats what I am afraid a lot of people do. 1 extra percent of quality costs 99 times performance, so you should not aim for 99.9% but need to stop much earlier. An easy way to understand is to play around with Photoshop filters and resolutions (large images). Increase in resolution results in 2^n cost (data and performance wise), so you quickly reach a point where huge extra cost does not yield anything that is worth it.
 

thesheeep

Arcane
Patron
Joined
Mar 16, 2007
Messages
9,956
Location
Tampere, Finland
Codex 2012 Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming! Serpent in the Staglands Dead State Divinity: Original Sin Torment: Tides of Numenera Codex USB, 2014 Shadorwun: Hong Kong Divinity: Original Sin 2 BattleTech Bubbles In Memoria A Beautifully Desolate Campaign Pillars of Eternity 2: Deadfire Pathfinder: Kingmaker Steve gets a Kidney but I don't even get a tag. Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
Most of the games we are discussing are made by professionals in medium sized companies, not by indies and amateurs.
Uhm...
You'd be surprized what passes for a professional nowadays. :negative:
This.

If you really think that "the bigger the company, the better the people" or "the more money they are paid, the better the people", then you will weep in agony once you realize there is no correlation here.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,562
Location
Tampon Bay
Another problem is that many people dont ever measure performance, and therefore dont find critical bottlenecks. Gaming engines are build with all kinds of middleware (middleware is an antagonist of performance). Nowadays a calculation in assembly language takes mere microseconds, but the same calculation in a script could take tenths of a second. That's why some people never realize that their programs can run 100s or 1000s of times faster if they get rid of bottlenecks (scripts, COM Interop etc). Every programmer should use precision timers in his programs and see what individual operations costs. It can be very interesting because the results are often not what you expect, i.e. actual calculations take only very little whereas other stuff takes the lions share.
 

Alienman

Retro-Fascist
Patron
Joined
Sep 10, 2014
Messages
17,178
Location
Mars
Codex 2016 - The Age of Grimoire Make the Codex Great Again! Grab the Codex by the pussy Codex Year of the Donut Shadorwun: Hong Kong Divinity: Original Sin 2 Steve gets a Kidney but I don't even get a tag.
Nice thread. I have always wondered what is causing those endless loops in turn-based games. Like JA2, Silent Storm, X-com and so on. Randomly you will get a turn that just refuses to end. Seems to be mostly pathfinding issues, but I have always wondered what determines a fuck up and something the AI can navigate out of.

Not a turn based game, but Men of War: Assault Squad has a map that always (it seems so anyway) locks up. Half way through the map the game will suffer from incredible fps-drops, and you have to use your paratroopers to dislodge the attacking enemy vehicle. One of the vehicles always seem to get stuck on a street lamp and the AI just completely grinds the game to an halt trying to figure out how to move from that lamp. The instant the vehicle is freed the fps returns to normal. It almost feel like a sexual release when that happens :)
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,562
Location
Tampon Bay
The pathfinding in JA2 sometimes seems to be hung up. I dont think it happens in vanilla, afaik 1.13 redid the pathfinding and that may have introduced some problems with worst cases. For example a heuristic.
I dont think it locks up completely, just takes very long. You probably must accept that sometimes the computer in these games needs the extra time to finish its calculations.
If you get stack overflow errors the pathfinding is probably crashing.
 

Chris Koźmik

Silver Lemur Games
Developer
Joined
Nov 26, 2012
Messages
414
Is it just me or did games like Heroes of Might and Magic 3, Master of Magic, Eador: Genesis process enemy turns faster than the new ones like Heroes 7, Sorcerer King, Eador: Master of a broken World?
Are you sure these old games processed turns faster *at their release date* than modern games? I recall HoM&M3 being somewhwat slow at the machines back then (but I don't remember clearly :)).
 
Unwanted

a Goat

Unwanted
Dumbfuck Edgy Vatnik
Joined
Jun 15, 2014
Messages
6,941
Location
Albania
Not a turn based game, but Men of War: Assault Squad has a map that always (it seems so anyway) locks up. Half way through the map the game will suffer from incredible fps-drops
For me all MoW games have massive FPS drops after like half of an hour. Regardless of settings. Don't know why.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,562
Location
Tampon Bay
Are you sure these old games processed turns faster *at their release date* than modern games? I recall HoM&M3 being somewhwat slow at the machines back then (but I don't remember clearly :)).

DOS games were generally running in a single task and in assembly language, so nothing going on that could cause bottlenecks.

Loading times were more of a problem, especially in games like Wing Commander.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,562
Location
Tampon Bay
Old computers were like a small village where a program went up and said good day to the BIOS and three or four drivers. Today they are a huge megacity with constant traffic jams and corpses on the road.
 

Chris Koźmik

Silver Lemur Games
Developer
Joined
Nov 26, 2012
Messages
414
I will try to reply from the point of view of a developer. In my game I have a fast turn processing but my main reason for having these is that I'm a solo developer so I also need to test the game and design it so faster turns save *my* time. In order to make thest fast turns I had to make significant optimizations (which was somewhat expensive). I also don't see these fast turns as a valid selling point, it does not make much sense from marketing point of view. My game won't get any favourable reviews because of these. In addition, considering how much troublesome this optimiation was (I had to make the internal workings of the game more complex and sophisticated) and how small of impact it has on the fun of the game I think in my next game I won't do it again (I somewhat regret doing this fast turns processing).

Additional thing is the internet. Players nowadays are *OBSESSED* by the AI, you will get negative reviews if you have it poor also it's one of the major complains of the players. So, you need to address it this way or another. And AI is really bogging down the CPU very fast no matter waht kind of game you make. The players back then (HoM&M3) were less mature, they were kids, now the players are adults (35 years is the average player's age IIRC) back then they simply wanted a fun game. Nowadays you want a game which won't get too many negative reviewes on Steam. Long turns won't give you negative reviews. Poor AI will give negative reviews for sure. You can trade long turns for better AI. So, the choice is obvious, one should make long turns :)
 

Reapa

Doom Preacher
Joined
Jul 10, 2009
Messages
2,340
Location
Germany
I will try to reply from the point of view of a developer. In my game I have a fast turn processing but my main reason for having these is that I'm a solo developer so I also need to test the game and design it so faster turns save *my* time. In order to make thest fast turns I had to make significant optimizations (which was somewhat expensive). I also don't see these fast turns as a valid selling point, it does not make much sense from marketing point of view. My game won't get any favourable reviews because of these. In addition, considering how much troublesome this optimiation was (I had to make the internal workings of the game more complex and sophisticated) and how small of impact it has on the fun of the game I think in my next game I won't do it again (I somewhat regret doing this fast turns processing).

Additional thing is the internet. Players nowadays are *OBSESSED* by the AI, you will get negative reviews if you have it poor also it's one of the major complains of the players. So, you need to address it this way or another. And AI is really bogging down the CPU very fast no matter waht kind of game you make. The players back then (HoM&M3) were less mature, they were kids, now the players are adults (35 years is the average player's age IIRC) back then they simply wanted a fun game. Nowadays you want a game which won't get too many negative reviewes on Steam. Long turns won't give you negative reviews. Poor AI will give negative reviews for sure. You can trade long turns for better AI. So, the choice is obvious, one should make long turns :)
as if any recent A.I. was any good to justify the long turns...
and also: this is not about the actual A.I. taking too long but other stuff making it take too long. like unoptimized shit and loops and processor intensive graphics when they're supposed to be handled by the gra-card.
 
Last edited:

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom