Wildmana Development, Take 2

Skyre Noktis

Warlord
Joined
Apr 28, 2009
Messages
271
OK, now that I've got a computer that runs properly and time to work on modding, it's time to revive this topic.

So far, Wildmana has been a one-man project with Sephi doing basically everything. If we want to make Wildmana a collaborative effort, the first thing that needs to be done is to set up some sort of shared repository (e.g. svn, if that floats your boat) where changes can check in. This is really the only sensible way to coordinate a project with two or more developers, IMO; otherwise, we're going to quickly start going out of sync and there will be lots of painful, manual merges. Several other Civ 4 mods do something similar (I know Dune Wars and Better AI do, for example).

Onto development itself, the Legacy and Future of Wildmana topic lists some new features and enhancements that need implementing:

* better diplomatics: AI still lacks long term strategies. Most diplomatic decisions are based on randomness, not flavor or strategy.
* Naval Warfare: AI needs to understand what waterwalking means. If it builds fleets to settle or conquer distant shores, it should understand to send more than one ship
* Better lategame teching: Its still quite random what the AI techs lategame
* Hidden Nationality: The AI basically has no clue about it yet
* AI still lacks to understand a lot unique abilities of the many civilizations.
* AI warfare. AI needs more tactics than just Stack of Doom strategy. Assault stacks with high mobility units. Counter stacks with assasins. There is a lot of potential.
* Portals: Create Portals on the map which allow to travel between continents and teach the AI to use these.

The portals idea is particularly interesting to me. If we can get that to work, there's a good chance we could get multiple map planes to work. A lot depends on the limitations of the graphics engine, though - all of that stuff's in the EXE, frustratingly.

AI is complicated. Probably the best thing is to test out the existing AI as thoroughly as I can and try to identify its weaknesses. That was basically the path I followed with my own mod.

The meatier AI projects (like diplomacy or war strategy) could probably do with some brainstorming to work out the best way to tackle them. A lot of the war stuff boils down to teaching the AI about different types of stacks, when to build them and how to use them. Easier said than done, though.
 
I have created a Project at Sourceforge

https://sourceforge.net/projects/ffhbetterai/

For those, who don't know sourceforge, you can easily download the latest source there. If you want to modify the project files, you need a special software (for download links: http://subversion.tigris.org/ ), create an account at sourceforge (only valid email adress is needed) and PM me your account name or post here so I can give you write access.

I called the project ffhbetterai as the name probably fits better than wildmana.
 
AI is complicated. Probably the best thing is to test out the existing AI as thoroughly as I can and try to identify its weaknesses. That was basically the path I followed with my own mod.

The meatier AI projects (like diplomacy or war strategy) could probably do with some brainstorming to work out the best way to tackle them. A lot of the war stuff boils down to teaching the AI about different types of stacks, when to build them and how to use them. Easier said than done, though.

I think two areas where the AI needs most work currently is founding cities and Decision making when to start a war. Davidallen managed to simplyfy and rewrite CvPlayerAI::AI_foundingvalue for dunewars, so that might be some inspiration. In general I think the AI should value starting location for its first city, early exploration cities and later cities different. First city is all about fast growth "tundra doesn't matter if remnants and tree are in BFC", early cities are about more early happy or strategic resources. Since many civs like Lanun, Kuriotates, Mazatl want to place their cities different I think there is a lot of potential.
 
Sourceforge will do nicely. We should add the Python and XML to the svn repository as well, though.
 
Suggested improvements:

AI should stop building melee units. It won't be perfect, but it would be better then pre-patched FfH AI, and melee isn't what makes FfH unique anyway. Besides, it's not like default BTS AI uses them perfectly.
 
Sourceforge will do nicely. We should add the Python and XML to the svn repository as well, though.

I have added Python and XML to the repository now. Please review the folder structure and make changes if you think they are necessary.
 
I have added Python and XML to the repository now. Please review the folder structure and make changes if you think they are necessary.

BADASS. Now I can start uploading all the translations I've been working on. :D
 
On AI diplomacy:

A big part of when the AI chooses to go to war is related to its 'power' score in relation to another team's. The default Civ 4 way of determining a unit's power doesn't work very well in FfH at all. There are two problems, really:

1. Many of the 'iPower' ratings in the unit XML are wildly inaccurate and misleading, as they are all calculated with Attack Strength * Tier and they ignore everything else (not to mention that tier is irrelevant). For example, Pyre Zombies are considered weaker than Axemen because Pyre Zombies have only base strength 3. The fact that they have +1 death strength and their explosion ability are completely ignored.

2. Promotions in FfH2 are very, *very* important. A Combat V unit is twice the strength of a unit of the same type with no promotions. There's also the weapons system. An Axeman with iron weapons is 50% tougher than an Axeman with no weapons. These are significant.

For example, in a game I ran, the Grigori had a hero Axeman with 100XP, Combat V and several other promotions. A human player would see Grigori adventurers as a great reason to go to war early, but the AI just sits there because this adventurer counts no more than a regular Axeman with 0XP and their power graph is still completely average.

In my mod, I had a completely reworked power system that took into account all these things. Merging it with Wildmana would be a good start towards better diplomatic decisions, IMO.
 
I haven't modified the Powervalues of the Unitinfos yet. If you finetuned values, I think it would be great to add them. The AI should be taught that a Pyre zombie army is more scary than a group of axeman.

The AI gives Units of higher level a higher power value, a lvl 11 axeman for example is worth 4 level 1 axeman. What is your power system?
 
My original idea was to use unit level because this is a simple way to do things. In practice, it has a few problems, e.g.

- Weapon promotions have nothing to do with level, so are not taken into account (probably the killer for me)
- Civ-specific promotions, like Horselord or Sinister, are ignored
- Trait-specific promotions (notably Aggressive giving Combat I) are ignored
- Free promotions given by buildings are ignored (e.g. golems with fireballs)
- Negative promotions, like disease, are ignored

The system I had eventually evolved into having values for each promotion, either increasing the base strength by a fixed value or by a percentage. It's maybe a bit overkill, but it covers all bases.

I toyed with the idea of squaring the final value for each unit, just to make sure the AI understands the value that powerful individual units have. I can't remember if I actually did this in the end, though. It's just a minor tweak, anyway.
 
Um, so I guess either Sephi or Skyre need to add me to the project to upload things? Or maybe I fail at SVN, though I was pretty sure I had it set up right. :(
 
Tortoise is great because it can also generate your patches for you :)

Personally, I think that the best approach to testing the AI is to ensure that any changes you make are savegame compatible (either insert any variables you will need in the save stream without any functional changes, or utilize the flags to achieve this), and then compare a gamestart autosave (every game you ever play makes one) run on AIAutoPlay for the same number of turns before and after the changes. Remember to avoid the New Random Seed on Reload option.

Yes, it is nice to see overall trends across multiple games, and you cannot assume you have "fixed" the AI based on a single game. But the method here is far quicker for testing while you tweak things than running dozens of games and checking for a "feel" that it has improved.

Make sure also that you are comparing LOADED savegames to one another. The random seed changes when you load a game from what it was when you played straight through, it does not change each time you load however (ie - after saving, your next random was a 0-10 and came out 4. You reload the "No New Random" savegame, and you find that instead you get a 7. You think that is weird, so reload a dozen more times, it comes out 7 each time, because it doesn't get a new seed, but also doesn't replicate a non-loaded game flawlessly).



Obviously, you have to figure out how you are going to decide what is "improved" results at the end. Initial work to just get civs to live against the Barbarians is easily judged. Speed enhancements to AI processing are easily judged. Beyond that, you have to decide to do things like look at the average score values at a certain turn, or the variance of score values at a certain turn. Or you can just look at typical improvement of lands and tech choices across all players, or quantity of naval forces generated and potentially utilized. Or cut straight to the replay screen and watch for major announcements (heroes/wonders/great people). Depends on what you were trying to improve at that point. (You can open the replay without ending the game if you have chipotle enabled BTW)
 
My original idea was to use unit level because this is a simple way to do things. In practice, it has a few problems, e.g.

- Weapon promotions have nothing to do with level, so are not taken into account (probably the killer for me)
- Civ-specific promotions, like Horselord or Sinister, are ignored
- Trait-specific promotions (notably Aggressive giving Combat I) are ignored
- Free promotions given by buildings are ignored (e.g. golems with fireballs)
- Negative promotions, like disease, are ignored

The system I had eventually evolved into having values for each promotion, either increasing the base strength by a fixed value or by a percentage. It's maybe a bit overkill, but it covers all bases.

I toyed with the idea of squaring the final value for each unit, just to make sure the AI understands the value that powerful individual units have. I can't remember if I actually did this in the end, though. It's just a minor tweak, anyway.

well, makes sense. There are some problems going by promotion but overall it's probably better. If a Unit has Fire 2 and Air 2, it still can only use one of them.

If you want to remove the current tweaks and replace them with your system, search for "better UnitPower calculation"

edit: Wildmana uses the WoC Module Style, if you add an XML tag, you also need to modify copynondefaults function in CvInfos.cpp. The function is listed after the save/write/readpass functions. In most cases it's a single line only.
 
Personally, I think that the best approach to testing the AI is to ensure that any changes you make are savegame compatible (either insert any variables you will need in the save stream without any functional changes, or utilize the flags to achieve this), and then compare a gamestart autosave (every game you ever play makes one) run on AIAutoPlay for the same number of turns before and after the changes. Remember to avoid the New Random Seed on Reload option.

keep in mind that many macro AI decisions are quite random. Comparing tweaks to them on a single game can be very misleading.
 
I've shuffled the directories around a bit so that everything is now under 'trunk' (which it should be, if my understanding of svn is correct).
 
Top Bottom