MantisBT - VCMI
View Issue Details
0001914VCMIAI - Adventure Mappublic2014-10-07 21:112015-04-11 18:07
Povelitel 
linuxrocks123 
highminoralways
closedopen 
0.96b 
0.97 
0001914: AI do not buy troops
1. You can teach him to buy not only the heroes but also the troops?

He builds them, but do not buy.
Luna took the city on this day Conflux (elementon). See for yourself.

I think over time it will start to do it. But this did not happen.
Although the term is a big 221.

2. Are there any means to check how many home computers has gold?

(3. If it's set to register a few million of money, he buys troops. I wonder why he does not do it himself).
No tags attached.
rar Saves.rar (1,594,767) 2014-10-07 21:11
https://bugs.vcmi.eu/file_download.php?file_id=1929&type=bug
? __AI testing.h3m (14,204) 2014-10-13 13:16
https://bugs.vcmi.eu/file_download.php?file_id=1941&type=bug
zip vcmi_logs.zip (59,862) 2014-10-14 14:55
https://bugs.vcmi.eu/file_download.php?file_id=1942&type=bug
Issue History
2014-10-07 21:11PovelitelNew Issue
2014-10-07 21:11PovelitelStatusnew => assigned
2014-10-07 21:11PovelitelAssigned To => Warmonger
2014-10-07 21:11PovelitelFile Added: Saves.rar
2014-10-11 03:49linuxrocks123Note Added: 0005007
2014-10-11 05:36WarmongerNote Added: 0005008
2014-10-11 06:28PovelitelNote Added: 0005009
2014-10-11 06:30PovelitelNote Edited: 0005009bug_revision_view_page.php?bugnote_id=5009#r2645
2014-10-11 10:47WarmongerNote Added: 0005010
2014-10-11 10:52linuxrocks123Note Added: 0005011
2014-10-11 12:57PovelitelNote Added: 0005012
2014-10-13 01:44linuxrocks123Note Added: 0005017
2014-10-13 07:46PovelitelNote Added: 0005018
2014-10-13 13:15KantorNote Added: 0005019
2014-10-13 13:16KantorFile Added: __AI testing.h3m
2014-10-14 07:07linuxrocks123Note Added: 0005020
2014-10-14 07:19linuxrocks123Note Edited: 0005020bug_revision_view_page.php?bugnote_id=5020#r2649
2014-10-14 07:20linuxrocks123Note Edited: 0005020bug_revision_view_page.php?bugnote_id=5020#r2650
2014-10-14 14:55KantorFile Added: vcmi_logs.zip
2014-10-14 14:56KantorNote Added: 0005021
2014-10-14 14:57KantorNote Edited: 0005021bug_revision_view_page.php?bugnote_id=5021#r2652
2014-10-15 03:46linuxrocks123Note Added: 0005022
2014-10-15 09:09PovelitelNote Added: 0005023
2014-10-15 10:49KantorNote Added: 0005024
2014-10-15 10:50KantorNote Edited: 0005024bug_revision_view_page.php?bugnote_id=5024#r2654
2014-10-15 11:12KantorNote Edited: 0005024bug_revision_view_page.php?bugnote_id=5024#r2655
2014-10-15 12:25WarmongerNote Added: 0005025
2014-10-15 12:46PovelitelNote Added: 0005026
2014-10-15 13:50linuxrocks123Note Added: 0005027
2014-11-20 12:06PovelitelAssigned ToWarmonger => linuxrocks123
2014-11-20 12:06PovelitelStatusassigned => resolved
2014-11-20 12:06PovelitelFixed in Version => 0.97
2015-04-11 18:07PovelitelStatusresolved => closed

Notes
(0005007)
linuxrocks123   
2014-10-11 03:49   
Hey Warmonger: I'm working on this bug, too. I'll post a patch if I fix it.
(0005008)
Warmonger   
2014-10-11 05:36   
Calling this ticket a "bug" i s a big misunderstanding on how AI works and how it is supposed to work. If it's a bug, what would be possible fix?
(0005009)
Povelitel   
2014-10-11 06:28   
(edited on: 2014-10-11 06:30)
If this is not the fault of what is it? All the players were with the initial forces and buy more of the city. The Luna was the last move to the city, but it is also not led him to buy troops.
Maybe there is some sort of a relationship between the presence of free money and priorities to build. Maybe he is saving some money as a percentage before skimp? And do not feel in danger. Not take into account that the city can pick up?

Besides, it is easy to verify in practice. Skip passages and open the map cheat.

(0005010)
Warmonger   
2014-10-11 10:47   
You didn't answer my question. Can you tell exactly what would be possible fix?
(0005011)
linuxrocks123   
2014-10-11 10:52   
I'm still working on this issue (it's very poor behavior on the AI's part not to buy troops if you're about to take his town, but I agree this would fall under "enhancement request" rather than "bug" per se), and I think this has a lot to do with it:

const int GOLD_RESERVE = 10000; //when buying creatures we want to keep at least this much gold (10000 so at least we'll be able to reach capitol)

That is line 28 of VCAI.cpp. This line combined with the AI's tendency to buy new heroes way too often leads to poor play. I'm testing out my changes and trying to fix a few other issues while I'm at it (like the AI tries to take crypts with no army and of course dies), then I'll post a preliminary patch for your review.

By the way, this is some of the cleanest code I've ever worked on. Respect.
(0005012)
Povelitel   
2014-10-11 12:57   
Warmonger, if you ask me, I do not know what to answer. How to solve this problem. I'm not a programmer - I'm an observer.
But I can say that when you can kill enemies in fact starting troops is not normal. When his troops built, there is a good growth, and it ignores the threat of losing the city - is not normal.
Personally, my decision is the most simple and primitive, - give a million of money from the start. But it works.
Hopefully something linuxrocks123 will come up with may be.
(0005017)
linuxrocks123   
2014-10-13 01:44   
Hey Warmonger,

I forked the GitHub repo for my AI changes and they're at https://github.com/linuxrocks123/vcmi.git [^]

I would like you to review my changes when you get a minute. I made a lot of them and I think the AI plays much better now!

Have a nice day!
(0005018)
Povelitel   
2014-10-13 07:46   
If you have solved this problem. I am very happy.
You can look at http://bugs.vcmi.eu/view.php?id=1902 [^]
Forgive me for the audacity.
(0005019)
Kantor   
2014-10-13 13:15   
Hi linuxrocks123, at the beginning I would like to say how glad I am to see You fixing some AI mechanics, especially such as this one, which looks quite complicated. I tested VCMI by compiling it's source from your branch (do I call it right?), but unfortunately there are some major glitches that causes VCMI crashes. I'll include a map, but I'm pretty sure this'll happen to all kind of maps, so in your free time you can take a look at it ;)
(0005020)
linuxrocks123   
2014-10-14 07:07   
(edited on: 2014-10-14 07:20)
Kantor, I believe I ran into that bug and fixed it in commit 3 to my branch. I downloaded your map and did nothing but end my turn and it worked alright. Is there something else I have to do to trigger the issue?

EDIT: I had a question earlier about why the fog of war wasn't working right in one of my AI calculations. Found the answer, line 3532 of CGameState.cpp. Doxygen is awesome :D

And, yeah, it's a branch.

(0005021)
Kantor   
2014-10-14 14:56   
(edited on: 2014-10-14 14:57)
Hi, are You sure? I must point that it's a very randomly occurring bug, so sometimes You'll have to pass few days, sometimes even at ending of first turn it could happen...
This also happens when You type vcmieagles cheat to view whole map and end turn. It is really random bug, including saves would be pointless I think, so I include logs instead.

(0005022)
linuxrocks123   
2014-10-15 03:46   
Kantor,

Which version of my tree are you using? Have you updated your tree to include this commit:

https://github.com/linuxrocks123/vcmi/commit/45b0bba3366341d447abd8573f28ac1367000d9e [^]

If not, please update to the latest version of my branch and see if it still occurs. If yes, I'd like to ask that you try to find a way to consistently reproduce it if possible. I just played an entire game against the AI and didn't run into any crashes, so, without a way to reproduce the issue, it will be very hard for me to fix it.

Btw, I'm thinking now, with my latest changes, if I created a random map tilted in the AI's favor, it might beat me. How much I would need to tilt it, I don't know. The game I played was the Arrogance map on hard, and I won handily, but I didn't notice it doing anything obviously "wrong", and I "know" that map and the AI doesn't, so I had an unfair advantage. I'll try that map on impossible next.

The battle AI does some dumb things, but other people are working on that. The current battle AI is called "StupidAI" in the source code, and they're working on replacing it with "BattleAI" but I think it's not stable or something because it's disabled by default.

Hey Warmonger, how do I enable BattleAI, and would that be a good idea? Also, Google tells me there used to be a prohibition against working on BattleAI because it was someone's thesis, is that still in effect?

Cheers!
(0005023)
Povelitel   
2014-10-15 09:09   
Give me assembly under windows somebody and I'll find you crash. guaranteed
(0005024)
Kantor   
2014-10-15 10:49   
(edited on: 2014-10-15 11:12)
linuxrocks123,
I see your point, but all I can do is to check logs only due to really randomness of it's occurring. I noticed in both cases (because I compared logs previously included here with the fresh ones made today) crash happens after "Leaving virtual void VCAI::tileRevealed(const std::unordered_set<int3, ShashInt3>&)" for client, and for server after "Leaving CGameHandler::moveHero(ObjectInstanceID, int3, ui8, PlayerColor)::__lambda14". I doubt it can help, but it's a only clue I have for now.
Oh, I forgot to answer Your question, yes, I'm using latest commit in your branch.

Povelitel,
You asked about VCMI package, right? Here is one: http://www.filedropper.com/vcmi096b [^]

(0005025)
Warmonger   
2014-10-15 12:25   
linuxrocks123, how about you use our forum for topics not related to this issue?
(0005026)
Povelitel   
2014-10-15 12:46   
Kantor, go to the forum please, I wrote you a private message, so I do not flood here. (Your build does not work for me).
(0005027)
linuxrocks123   
2014-10-15 13:50   
Okay, Warmonger. Sorry.

Kantor, Povelitel, and Warmonger: I created a thread on the forum for discussions of my tree. We can continue this discussion there: http://forum.vcmi.eu/viewtopic.php?p=13283#13283 [^]

Kantor, I looked at your build, and I don't use Windows (I'm on Linux), so it may be that I can't reproduce your issue because the bug is platform-specific (I hate those...). Please run the client program in a debugger and post a stack trace when it crashes. I didn't change the server much, so the problem shouldn't be there. Post your responses to the thread I created; I'll be checking there for updates.