Adventure AI

Hi,
r2532 brings the first working adventure AI for VCMI, named VCAI. I should add several remarks:

  • AI plays poor, it’s not able to challenge even an average human player. There two reasons: a) AI is stupid and clumsy; b) battles. In battles both sides are lead by the same AI. Attacking side needs to be overwhelmingly stronger or will suffer severe casualties.
  • The main worth of AI is it’s working. Many bugs in engine have been discovered and fixed. It can serve as an example or base for further development (it’s most certainly needed).
  • AI should be stable. Please report if it is not. (crashes/freezes) GUI however still needs some adjustments (mainly blocking controls during enemy turn).
  • Saving/Loading is not appropriately supported, I’m going to do sth with that :slight_smile:
  • AI may get slow on bigger maps, especially on debug config (naive usage of STL). Also on my todo list for later.
  • I’ve allowed myself to use some parts of C++11. Lambdas play nice with algorithms. :slight_smile: It should work with modern compilers (MSVC 2010, GCC4.5+). If this is an issue for you, let me know.
  • I’ve created a few new command-line options for my convenience but I guess they can be useful for other developers. It’s possible to save a starting configuration (map, options) in pregame by typing „sinfo fname”. Then VCMI can be started with option „-i --start=fname” and it’ll automatically start the game. Saved me pretty much time on clicking through pregame menus. I’m surprised I didn’t implement that earlier.
  • „–onlyAI” command line option allows to run AI-on-AI game (without GUI). Also, typing „onlyai” in pregame triggers that mode.
  • New implementation is superior in every way to GeniusAI. Genius will be therefore removed from sources soon.

Code looks really great, well-thought and architectured. It will be easy to build more complex AI systems on this one.

This sounds really great. Thumbs up. I can’t wait to play against AI. :slight_smile:

VCMI finally got AI. Great!

C++11 is definitely nice addition. :slight_smile:
With some tweaks VCAI compiles fine with gcc-4.6 (will upload soon, not tested with gcc-4.5 yet). However Debian stable still uses gcc-4.4 which definitely won’t work.

A bit offtopic but if we’re sticking with gcc-4.5 as minimum what about using some other c++11 features like auto or lambdas in rest of VCMI code? Is it OK to replace c++03 auto_ptr with c++11 unique_ptr? (I’m getting a lot of warnings from auto_ptr right now)

@Warmonger, beegee, Ivan
Thank you! :slight_smile:

I think it would be nice to allow a subset of C++11 available both in VC10/GCC4.5 (including lambdas, auto, nullptr, rv-refs, decltype). I’m a bit concerned about availability of GCC 4.5, as you pointed out recent Debian has 4.4 and I guess tons of older systems are in usage. I don’t know how much trouble it is to obtain GCC 4.5 on such system. (Can it be more troublesome than Visual Studio installer? I doubt :stuck_out_tongue: ). [On the other hand apparently all VCMI devs have modern compilers :slight_smile: ]

Luckily Linux doesn’t have large problem with old systems so it’ll be OK to support only recent releases.
I’ve asked Mac OS user - he had gcc-4.2 installed by default but said that "4.5 can be installed easily via XCode"
For Debian this link looks to have what we need: debian.org/doc/manuals/apt-h … lt-version
All other major distros I know about already ship 4.5 or 4.6

You may know about this but sometimes AI behaves weird:
Map Carpe Diem: Green player as AI - sometimes (around 2nd-3rd turn) AI just walks past non-guarded resource piles.
Map Arrogance, Blue player as AI: bugs.vcmi.eu/file_download.php?f … 0&type=bug
AI is completely locked inside starting area - he does not attacks mines even on 2nd week.

BTW - currently stack experience for neutrals increases insanely fast. AI just don’t have any chances against such power :slight_smile:

Right, I’ve had a complete game on random map against AI and log shows it just has lost most of battles. It just doesn’t take it into calculation.

Great :slight_smile: Will be development build soon?

Yes, if everything goes right. :slight_smile:

An cheating AI

quote comes from my post on bug 925 on mantis bug tracker. I post it here to discuss my point separate from bug itself.