This land is…clean

image

Debugging AI is tough. Is the AI stupid because of a bug? Is it stupid because the AI developer was stupid? (in my case, that’s usually why). Or is it stupid simply because the player is doing something that the AI didn’t know how to handle.

So thanks to the forums, one thing that popped up was that the AI sovereigns were being unusually stupid by not cleaning up the goodie huts near them. Why weren’t they? There’s a fairly good algorithm for scouting the FOW and then going after goodie huts once it knows of them.

But it wasn’t.

Why?

image

The answer was that I was using a function called pUnit->GetPosition() which returned x,y coordinates. I thought (wrongly) that it returned the coordinates in tile form (i.e. what tile on the board it was in) but it wasn’t. It was returning the pixel position. So when I passed this into my various functions, it came up telling me that I was in enemy territory and to run away. Hence, the sovereign would run to a city and stick around there.

While not a crippling issue by any means, it is one of those things that would give a human player a significant advantage over the computer players, especially early game.

49,255 views 22 replies
Reply #1 Top

Once they find items, like books, will they use them, or has that already been fixed?

Reply #2 Top

Brad - thank you. It is posts like this which reaffirm that our time playtesting the game is valuable and heard. Love the dialogue and open communication! :grin:

Reply #3 Top

So this will be in the next beta?  That will help.

 

I'd almost say the books thing should be hardcoded, or it should be a no-brainer call for the AI (AI should know all possible outcomes, and decide from that)

Reply #4 Top

Its always satisfying to quash a bug that's been sitting around unnoticed for a long time, diminishing the experience in subtle ways. Something seems wrong but you don't know what.

I do find it odd that the unit class would track pixel position. I guess it could be used for mouse picking within a radius, but where would the pixel be centered? Units are represented by many pixels after all. The head? The crotch? Curious. 

Reply #5 Top

Long life to the king! Or sovereign?

Reply #6 Top

Long live Brad the King!  Thanks Brad!  Scratch one stupid AI trick off the list.

Reply #7 Top

Just keep posting your AI reports and such. I rarely respond but I almost always read them. I wouldn't have found it without you.

Reply #8 Top

I also am curious about the answer to Lord Xias question.  I have often encountered a an enemy leader with a collection of unread books and undrunk potions.

Reply #9 Top

Quoting stevelamperti, reply 8
I also am curious about the answer to Lord Xias question.  I have often encountered a an enemy leader with a collection of unread books and undrunk potions.
End of stevelamperti's quote

I'd rather they learn how to take their stat upgrades when leveling before they learn to read books.  They are missing way more points from leveling than from reading.

Reply #10 Top

Yea, I've reported that before too, they don't improve their stats when they level too, along with not using stat boosting items they find or get new equipment.  They are pretty pathetic, lol.

Reply #11 Top

Noticed that the Civ4 SDK also had pointers everywhere. Do you pros do it because it's cheaper (but less safe) to pass a reference, or is this a bad habit from C?

Also grats on bug kill. 

Reply #12 Top

Frogboy, in CoreDifficultyLevels.xml there is a tag that determines the health of the AI sovereign called <AISovereignHPRatios>1.0</AISovereignHPRatios>

I have never seen a sovereign have more than his basic health on higher difficulties. Almost always this results in a situation where the enemy sovereign is the weakest target, because all the units had their health boosted through <AIHPRatio>1.00</AIHPRatio>

Reply #13 Top

Nice

Reply #14 Top

Quoting Aeon221, reply 11
Noticed that the Civ4 SDK also had pointers everywhere. Do you pros do it because it's cheaper (but less safe) to pass a reference, or is this a bad habit from C?

Also grats on bug kill. 
End of Aeon221's quote

References and pointers are not the same. References are safer, but have certain limitations.

The reason for pointers is when you dynamically allocate memory (at run time) that needs to stick around you get a pointer to it.

And yes, pointers are references are faster as you only need to copy the size of the address, rather than the object (which tends to be bigger), and changes you make will be applied to the original rather than a copy.

Of course, what seems to be a pointer may not be; it could be a 'smart pointer' (an object that acts like a pointer but is able to help insure it gets released) or it it is managed code (I doubt it, but it is posibile) then it might be a handle (which is tracked by the garbage collector).

Reply #15 Top

Referring to the term reference in reference to a pointer's referencing of the memory address, whose contents can be read by dereferencing the pointer, without referring to the specific language element called reference.

In other words, appropriately used loose language inflicted on us by others, don't sue me over it.

I'm aware that pointers are faster in some circumstances, that's why I asked if speed was the desired attribute without reference to safety, or if the preference was the result of a background in C. Might be a lot of things other than a straight pointer. It'd be interesting to hear information rather than speculation though.

 

(ps: reference)

((pps: reference reference reference))

Reply #16 Top

Maybe they should use handles? XD

Reply #17 Top

Glsd to hear the problem has been found.

It's doing these "little things" that'll make this an awesome game one day.

Reply #18 Top

Brad, while I appreciate you squashing this bug, by far the bigger problem in my opinion is that of suicidal sovereigns.  Enemy sovs who turn up in my territory unprotected are basically handing me the game.  This is a game-breaker.  I know this has been reported before; are you getting anywhere with it?

Reply #19 Top

The Sovereigns not picking up or processing quests is only the beginning..  Why cant i loot a vanquished Sovereign? Why can't I use the quest materials as trade goods, or trade for such goods? Why doesn't the opposition Sovereigns use everything they pick up?

 

The glaring holes in AI function is appalling, not to mention they are still dumb as a box of hammers for combat tactics and diplomacy.

Reply #20 Top

Quoting Huw, reply 18
Brad, while I appreciate you squashing this bug, by far the bigger problem in my opinion is that of suicidal sovereigns.  Enemy sovs who turn up in my territory unprotected are basically handing me the game.  This is a game-breaker.  I know this has been reported before; are you getting anywhere with it?
End of Huw's quote

Here's a summary of recent developments. The suicide thing didn't pop up until the goodie huts were fixed in 1.19b - the sovs were on house arrest in 1.19 and 1.19a.

  1. 1.19 - XML tags were broken thus some factions were population locking at 5 and not growing. Here's an analysis: https://forums.elementalgame.com/404791. Brad and crew fixed the tags for 1.19a. Sovs and spouses were staying in their cities so they weren't committing suicide. Note post #22 of this thread where the fix was announced https://forums.elementalgame.com/404770.
  2. 1.19a - Glaringly obvious the sovs and spouses weren't grabbing goodie huts (among other things such as gearing). Three separate analysis here: 1. https://forums.elementalgame.com/404867 2. https://forums.elementalgame.com/404914 3. https://forums.elementalgame.com/404927. Brad and crew fixed the goodie huts for 1.19b announced in this thread's OP.
  3. 1.19b - Now the sovs are grabbing goodie huts but have violated house arrest, hit up their crack cocaine dealer, and are streaking across a busy freeway blindfolded. Analysis here: https://forums.elementalgame.com/405148. None of the sovs died in my 60 season analysis but I saw plenty get smacked around by mobs and sent back home to detox. When I started a real game, Umber died on turn 7, yes turn 7, to the faction monsters and ruffians. In addition the broken xml tag gremlins made another appearance. Now awaiting announcement for AI improvements in 1.19c.

For some reason the AI refuses to gear sovs, spouses, and champions based on available gildar and tech levels. My first guess: Brad hasn't had time to code it. Worst case, gearing the sovs, spouses, and champions may cause severe balance issues across difficulty levels. I honestly don't know. Based on all my playing and recent testing the AI factions do not appear to be acting differently per difficulty level - just the amount of resources they have to use is different. I've been playing my own games on ridiculous and then helping my daughter with her novice game so that's the context around my arguments.

Regardless I'd like this game to kick ass so I'll keep throwing AI observations and suggestions out there.

Reply #21 Top

Quoting Frogboy, reply 7
Just keep posting your AI reports and such. I rarely respond but I almost always read them. I wouldn't have found it without you.
End of Frogboy's quote

Thanks for working on improving the AI !

One suggestion I made long ago was allowing an editor or tool where the community could develop their own AI personalities.  Perhaps this would make it possible for each AI opponent to have one of many different random personalities/behavior.  If all the AI opponents share the same strategy design the human players will identify the patterns and exploit weaknesses, however if each AI opponent has random personalities/behavior the human player will have a much more difficult time knowing what to expect.  The second benefit would be the AI opponents would continue to improve with time as long as the community remained active. 

Reply #22 Top

Froggy ate another 'bad' bug.  Yeah!    Keep up the great work, and I, too, am happy with the opne communication frgooy has with players....