Ai turns

I also noticed it. Even if my hero is much weaker, AI heroes pay no attention to mine hero and don’t kill him on map. And enemy heroes don’t recapture mines and dwellings taken from AI by me.

@ Warmonger: I’ve got one suggestion about AI turns:
sometimes there is a situation when a hero is blocked on one cell, he can’t move anywhere (for example due to scenario he is blocked and we need to free him), but he still eats some time trying to evaluate what to do - about 15-20 seconds, not that much, but a simple if-else condition for such situations can help to reduce this time, nice profit, little changes in the code :wink:

For example, right now he did 11 evaluations, changed goal and finished his turn without doing anything.

Hmmm, well, in fact i have this problem, too. I’m trying the RoE campaign, first scenario. The first AI turn now runs for about 1 hour, and it is still not ready. That is indeed way too long.

My PC is a laptop, a samsung R70. It is not the strongest, but should be well powerfull enough. As far as i have read in the log from previous tries it is as Warmonger said: 2 heroes meeting causes some endless loop.

I too tried the vcmi test map. AI turn still took quite some time, but it was only minutes, not hours.

Map size cannot be the problem. The first RoE scenario has a quite small map.

Recalculation: I doubt if it is really necessary to recalculate goals on every tile. It should be enough to once per round calculate all goals within sight and then simply move there. This does not change any conditions. Any tile visited should not change any game state until the hero reaches his final point. Map/game conditions may change during the next turn, so it is necessary to reevaluate any goals then, but it should not be necessary to reevaluate them each turn

I’ll give it a try during night. We’ll see if it is an endless loop or if it just takes too long. If it’s still busy tomorrow than it is probably an endless loop.

BTW, is there a “cheat code” to reveal the map? Seeing what the AI does might help finding out what exactly takes that long.

Yes there is
wiki.vcmi.eu/index.php?title=Cheat_codes

Thanks for the reply. I’ll try it in a few minutes.

I’ve let it run through the whole night. No end. So it seems to be an endless loop.

Well, it is not that easy to read, but it seems to be some kind of enless loop indeed. So what i observed: The tan hero moved into its home town (Terraneus) and then got stuck there. Here are some parts of the log:

17:25:01 DEBUG ai [7fb8cf7fd700] - Moving hero Xyron to tile 33 35 1
17:25:01 TRACE network [7fb8cf7fd700] - Sending a request “8MoveHero”. It’ll have an ID=61.
17:25:01 TRACE network [7fb8cf7fd700] - Sending to server a pack of type 8MoveHero
17:25:01 TRACE global [7fb8cf7fd700] - We’ll wait till request 61 is answered.

17:25:01 TRACE network [7fb8cd7f9700] - received server message of type 13PlayerBlocked, data: {CPack: type ‘96’}
17:25:01 TRACE network [7fb8cd7f9700] - Made first apply on cl
17:25:01 TRACE network [7fb8cd7f9700] - Applied on gs
17:25:01 TRACE ai [7fb8cd7f9700] - Entering virtual void VCAI::playerBlocked(int, bool): reason ‘1’, start ‘1’.
17:25:01 TRACE ai [7fb8cd7f9700] - Leaving virtual void VCAI::playerBlocked(int, bool).

That moved Xyron to the entrance field of the town.

…]
17:25:02 TRACE ai [7fb8cd7f9700] - Entering virtual void VCAI::heroMoved(const TryMoveHero&).
17:25:02 TRACE ai [7fb8cd7f9700] - Leaving virtual void VCAI::heroMoved(const TryMoveHero&).
17:25:02 TRACE network [7fb8cd7f9700] - Made second apply on cl
17:25:02 TRACE network [7fb8cd7f9700] - Listening…
17:25:02 TRACE network [7fb8cd7f9700] - received server message of type 9HeroVisit, data: {CPack: type ‘1’}
17:25:02 TRACE network [7fb8cd7f9700] - Made first apply on cl
17:25:02 TRACE network [7fb8cd7f9700] - Applied on gs
17:25:02 TRACE ai [7fb8cd7f9700] - Entering virtual void VCAI::heroVisit(const CGHeroInstance*, const CGObjectInstance*, bool): start ‘1’; obj ‘Terraneus, Dungeon’.
17:25:02 TRACE ai [7fb8cd7f9700] - Completing goal: FIND OBJ 1454 (Xyron)
17:25:02 TRACE ai [7fb8cd7f9700] - Leaving virtual void VCAI::heroVisit(const CGHeroInstance*, const CGObjectInstance*, bool).
…]
17:25:02 TRACE ai [7fb8cd7f9700] - Entering virtual void VCAI::heroVisitsTown(const CGHeroInstance*, const CGTownInstance*).
17:25:02 TRACE ai [7fb8cd7f9700] - Leaving virtual void VCAI::heroVisitsTown(const CGHeroInstance*, const CGTownInstance*).

Here obviously the first goal is done.

…]
17:25:02 TRACE ai [7fb8cf7fd700] - Entering void VCAI::performObjectInteraction(const CGObjectInstance*, HeroPtr): Hero Xyron and object Terraneus, Dungeon at 35 35 1.
17:25:02 TRACE ai [7fb8cf7fd700] - Completing goal: FIND OBJ 1454 (Xyron)
17:25:02 TRACE ai [7fb8cf7fd700] - Leaving void VCAI::performObjectInteraction(const CGObjectInstance*, HeroPtr).
17:25:02 TRACE ai [7fb8cf7fd700] - Completing goal: VISIT TILE (33 35 1) (Xyron)
17:25:02 DEBUG ai [7fb8cf7fd700] - Hero Xyron moved from 33 36 1 to 33 35 1. Returning 1.
17:25:02 TRACE ai [7fb8cf7fd700] - Completing goal: VISIT TILE (33 35 1) (Xyron)
17:25:02 DEBUG ai [7fb8cf7fd700] - Hero Xyron visited tile (33 35 1)

O.k., now Xyron did some interaction in Terraneus. Done.
Now the interesting part:

17:25:02 DEBUG ai [7fb8cf7fd700] - Striving to goal of type WIN
17:25:02 DEBUG ai [7fb8cf7fd700] - Considering goal WIN
17:25:02 DEBUG ai [7fb8cf7fd700] - Considering goal FIND OBJ 1454
17:25:02 DEBUG ai [7fb8cf7fd700] - Considering goal VISIT TILE (33 35 1)

Again? Xyron is already at tile 33 35 1.

…]
17:25:02 TRACE ai [7fb8cd7f9700] - Entering virtual void VCAI::requestRealized(PackageApplied*).
17:25:02 TRACE ai [7fb8cd7f9700] - Leaving virtual void VCAI::requestRealized(PackageApplied*).
17:25:02 TRACE network [7fb8cd7f9700] - Made second apply on cl
17:25:02 TRACE network [7fb8cd7f9700] - Listening…
17:25:02 DEBUG ai [7fb8cf7fd700] - Trying to realize VISIT TILE (33 35 1) (Xyron) (value 2.679)

This seems to be the start of the endless loop

…]
17:25:02 TRACE ai [7fb8cd7f9700] - Entering virtual void VCAI::requestRealized(PackageApplied*).
17:25:02 TRACE ai [7fb8cd7f9700] - Leaving virtual void VCAI::requestRealized(PackageApplied*).
17:25:02 TRACE network [7fb8cd7f9700] - Made second apply on cl
17:25:02 TRACE network [7fb8cd7f9700] - Listening…
17:25:02 DEBUG ai [7fb8cf7fd700] - Moving hero Xyron to tile 33 35 1
…]
17:25:02 TRACE ai [7fb8cf7fd700] - Entering void VCAI::performObjectInteraction(const CGObjectInstance*, HeroPtr): Hero Xyron and object Terraneus, Dungeon at 35 35 1.
17:25:02 TRACE ai [7fb8cf7fd700] - Completing goal: FIND OBJ 1454 (Xyron)
17:25:02 TRACE ai [7fb8cf7fd700] - Leaving void VCAI::performObjectInteraction(const CGObjectInstance*, HeroPtr).
17:25:02 TRACE ai [7fb8cf7fd700] - Completing goal: VISIT TILE (33 35 1) (Xyron)
17:25:02 DEBUG ai [7fb8cf7fd700] - Hero Xyron moved from 33 35 1 to 33 35 1. Returning 1.
17:25:02 TRACE ai [7fb8cf7fd700] - Completing goal: VISIT TILE (33 35 1) (Xyron)
17:25:02 DEBUG ai [7fb8cf7fd700] - Hero Xyron visited tile (33 35 1)
17:25:02 DEBUG ai [7fb8cf7fd700] - Striving to goal of type WIN
17:25:02 DEBUG ai [7fb8cf7fd700] - Considering goal WIN
17:25:02 DEBUG ai [7fb8cf7fd700] - Considering goal FIND OBJ 1454
17:25:02 DEBUG ai [7fb8cf7fd700] - Considering goal VISIT TILE (33 35 1)
…]

And then again and again.

I do not know what kind of interaction Xyron is doing here, but either he is doing it over and over again or there are thousands of interactions to be done in this town. This never ends.

I hope this might help. BTW, at least here it is always (100%) this way. So you might find the exactly same behaviour if you try it yourself. The map is the first scenario in the “good” RoE campaign. My computer is a Samsung R70 laptop, and my OS is Ubuntu 14 (current latest version).

Regards (and good luck)
Siegfried

Thank you for detailed report. If you could put in the mantis ticket, it could be nice.

I have to first create an account. Will do tomorrow. Do you need some special information?

BTW, i’ll download the source. But it will be winter before i have any time to do some serious research :slight_smile: But at least i’m a software developer. Although this is unknown terrain for me. I’m normally doing machine control and sometimes embedded software.

Hey, I downloaded latest Android version from Google Play.

I’m using Asus Transformer Prime tf201 (Nvidia Tegra 3, 1GB RAM, 1GHz) and every application including games works on it fluently, even all newest, never experienced problems with memory, fluency, etc. It’s really rare to run VCMI and Chrome browser at the same time and experience any of apps reset.

I played Heroes III Gold Edition PL + WoG on VCMI and I found that AI turns still takes very long time. I won’t compare it to PC version, because it has no sense, but I’ll present some time lines:

  • when AI player doesn’t have heroes, map is revealed - AI turn takes about 6-10 seconds (this is nice score),
  • when AI have at least one heroe, map is unrevealed to player - AI turn takes 15 seconds and for each heroes it seems + 5-10 seconds more, but sometimes it’s even twice more for each so number of heroes won’t be the factor which cause additional “lagg”.

Tested on Dragon Valley and Dungeon Keeper maps. It seems when you have map revealed and you can see AI moves it takes 3 times more for each AI hero move, same heroes move looks a little strange, it’s not fluent, sometimes hero stops, then go, then stops, change direction, then finish move.

I remember from PC version how long on revealed map AI turns can take (biggest map, all players, map revealed = 30-40 seconds - especially more if AI uses fly spell or Angel’s Wings or town portal), so I imagine on Android I could wait for each turn about even 20 minutes…

Could you tell me how long takes anyone here on Android each AI turn? It’s really hard to play when you need to wait for even 3 AI players to move for 40 seconds each just in 8th turn.

P.S.1: I noticed map clipping when moving heroes, you can see entire map for split second each time heroe change direction.

P.S.2: I couldn’t register to forum because image of validation doesn’t show up, tried on every known browsers, but without positive results.

Android version is outdated, ask xyz to release new one.

bugs.vcmi.eu/view.php?id=1841

Thanks, I send him message. It seems that problem is resolved in VCMI versions for other platforms.

Yea, I realized that too late. :blush: