Wiser Orcs (a FfH II mod)

xanaqui42

King
Joined
Sep 5, 2006
Messages
780
Wiser Orcs is a Fall From Heaven II mod that primarily deals in improvements to the Artificial Intelligence (AI). For the purposes of this mod (and the code), AI includes all complex decision-making done by the computer without direct human intervention. For example, automating a worker, allowing automatic determination of where your citizens will work, or giving a go to order all fall under this description. In other words, this mod should both improve the computer opponents' capabilities and reduce the advantages of micromanaging. It also should eventually reduce the need for cheating by the AI.

Wiser Orcs is not Smarter Orcs. Smarter Orcs was a merge between BetterAI and Vanilla-based FfH II with some added features. As BtS already has a large percentage of the changes from BetterAI, this is not the approach that was chosen for Wiser Orcs.

Unstable Release: Here

Source Code: Sourceforge project link. Note that it's under the BtS Trunk.

Quiz: Here.

License: This project is dual licensed. It is both licensed under the LGPL, and under the same terms as FfH II.
 

xanaqui42

King
Joined
Sep 5, 2006
Messages
780
  • Release 0.06 - based on FfH II 0.33e (Will break saved games)
    • Known Defects:
      • Wild Hunt does not work correctly.
    • Features:
      • Merge with 0.33e
      • Expose some of the constants in AI_yieldValue to XML, and changed them slightly.
      • Added XML support for Strategy Framework.
      • Added Flavors from Smarter Orcs (by Bringa) & added ones for each religion.
      • Added strategy framework (strategy types logic not tested yet).
      • Added single strategy (Octopus Overlords Religion).
      • Modified technology choosing to favor cheap techs 1 time in 30 (instead of 1 in 5).
      • Multiple asserts addressed, including one related to immobility.
      • Fix to food logic for minor civs (defect from Wiser Orcs 0.01(?)).
      • Patch animal logic (when owned by non-Barbarian player)
      • Adding ReligionWeightModifiers to civilization strategy - affects religion choice
      • ReligionWeightModifiers now affect the unit chosen to spread religion.
      • Expose flavor effects on technology weights to human (mostly to make debugging flavors easier).
      • Large fix to Tech choosing; previous logic was wrapping around (so a high positive number would become a negative number, or a smaller positive number).
      • Falamar will always attempt to "rush" for Octopus Overlords
    • Files Changed
      • CIV4CivilizationsSchema.xml
      • CIV4LeaderHeadInfos.xml
      • CIV4CivilizationStrategyInfos.xml (new)
      • GlobalDefinesAlt.xml
      • GlobalTypes.xml
      • CIV4TechInfos.xml
      • CvSpellInterface.py
      • CvCivilizationStrategyInterface.py (new)
      • CvEventManager.py
      • CvGameCoreDLL.dll
      • CvUnitAI.cpp
      • CvCityAI.cpp
      • CvEnums.h
      • CyGlobalContext.cpp
      • CvGlobals.cpp
      • CyGlobalContext.h
      • CyGlobalContextInterface1.cpp
      • CvPlayerAI.h
      • CyPlayer.h
      • CvInfos.cpp
      • CvGlobals.cpp
      • CvXMLLoadUtilitySet.cpp
      • CvDefines.h
      • CvXMLLoadUtilitySet.cpp
      • CvDefines.h
      • CyPlaerInterface1.cpp
      • CvPlayer.h
      • CyPlayer.cpp
      • CvPlayer.cpp
      • CvInfos.h
      • CyInfoInterface3.cpp
      • CvPlayerAI.cpp
      • CvUnit.cpp

  • Release 0.05 - based on FfH II 0.33d (Will break FfH II saved games; will not break Wiser Orcs 0.04 Saved games)
    • Files Changed
      • CvModEvents.py
      • CvRandomEventInterface.py
      • CvSpellInterface.py
      • CustomFunctions.py
      • CvGameCoreDLL.dll
      • GlobalDefinesAlt.xml
      • CIV4LEaderHeadInfos.xml
    • Known Defects:
      • Found an edge case where growth is limited (this is an imperfection in the new algorithm; it still behaves far better than the original code).
      • Minor civ food per population is calculated incorrectly.
    • Features:
      • Fix City Plots
      • Fix City Radius
      • Speedup canMoveInto (minor optimization)
      • Speedup color acquisition (partial, through Player.cpp)
      • Fixes to food logic - defect from Wiser Orcs 0.04
      • Fixes to logic so that cities don't prevent themselves from growing.
      • Infinite loop removed (was previously broken out of, but may have been a time-waster).
      • Merge with FfH II 0.33d
      • Cities can not produce negative commerce.
  • Version 0.04 - based on FfH II 0.33c Will break saved games
    • Files Changed
      • CvModEvents.py
      • CvSpellInterface.py
      • CustomFunctions.py
      • CvGameCoreDLL.dll
      • GlobalDefinesAlt.xml
      • CIV4LEaderHeadInfos.xml
    • Known Defects:
      • foodConsumptionPerPopulation conflated with foodConsumption. This may cause problems for the food logic (although there are other problems in the main code).
      • infinite loops for immobile units (from main FfH II Mod)
    • Features
      • Merged to 0.33c
      • 0-food (and a few 1-food) issues fixed.
      • Healing times should now display correctly under "fair combat"
  • Version 0.03 - based on FfH II 0.33c Wrong DLL - shouldn't break saved games, but most features are missing
    • Files Changed
      • CvModEvents.py
      • CvSpellInterface.py
      • CustomFunctions.py
      • CvGameCoreDLL.dll
      • GlobalDefinesAlt.xml
      • CIV4LEaderHeadInfos.xml
    • Known Defects:
      • If HIT_POINT_FACTOR is set to a non-default value, the displayed healing times are inaccurate. Healing occurs at the correct rate.
      • Hyborem no longer correctly ignores food.
    • Features
      • Merged to 0.33c
  • Version 0.02 - based on FfH II 0.25l breaks saved games
    • Files Changed
      • CvModEvents.py
      • CvSpellInterface.py
      • CustomFunctions.py
      • CvGameCoreDLL.dll
      • GlobalDefinesAlt.xml
      • CIV4LEaderHeadInfos.xml
    • Known Defects:
      • If HIT_POINT_FACTOR is set to a non-default value, the displayed healing times are inaccurate. Healing occurs at the correct rate.
    • Features
      • Increased base barbarian technology increase (modifiable via XML).
      • Barbarian technology increase modified by Game Speed, World Size, and Start Era.
      • Better AI response to Barbarian attacks (this breaks saved games)
      • The AI can create Great Works with military units, and will tend to disfavor doing this to highly experienced units.
      • Support for "Fair Combat" - HIT_POINT_FACTOR in GlobalDefinesAlt.xml acts as a multiplier to First Strikes, healing, Magic damage, damage limits, and maximum HP. The end result is that the higher the value, the more the more powerful unit will be favored in a 1 on 1 combat. However, the stronger unit is also more likely to be injured. Note that it is probable that this will break with sufficiently high values, however, it should work for values in the 1-20 range.
      • AI Exploration units no longer self-destruct once the map is complete.
  • Version 0.01 - based on FfH II 0.25l
    • Files Changed
      • CustomFunctions.py
      • CvGameCoreDLL.dll
      • GlobalDefinesAlt.xml
      • CIV4LEaderHeadInfos.xml
    • Known Defects:
      • None at this time.
    • Features
      • Arturus and Kandros can now trade up to 10% of their maximum gold. This is because some of the below changes make this less dangerous. Choosing not to trade Gold/Turn has not changed.
      • AI_BASE_MAXIMUM_KHAZAD_GOLD_PER_TURN and AI_PER_CITY_MAXIMUM_KHAZAD_GOLD_PER_TURN added to GlobalDefinesAlt.xml to allow a linear function for the Kahzad AI's gaining of gold (AI_BASE_MAXIMUM_KHAZAD_GOLD_PER_TURN + AI_PER_CITY_MAXIMUM_KHAZAD_GOLD_PER_TURN * the number of cities) is the maximum goal, until the player has vaults large enough to be overflowing with an additional city. If these are set correctly (I think the present values are pretty good), it should allow the Khazad AI to obtain overflowing vaults without too much effort.
      • Ignore food (Hyborem) is mostly supported. This both helps the AI and many decisions for the player; you no longer should need to override each citizen's choice of plot.
      • Food varying by Civic choice (Sacrifice the Weak) is mostly supported. Note that the effect here is much less significant than it is for the Ignore Food Logic.
      • Defect that caused a civilization to nearly always Gold rush under good population circumstances has been removed. This was preventing the Khazad from keeping any vault above Empty when it had an appropriate civic.
      • ExtraGoldTarget is used to track the amount of Gold the Khazad want for their vaults. It is also used in numerous spending calculations, from ones for trade deals through ones for rushing, and more. The end result is that the Khazad should actually attempt to maintain Overflowing vaults once they get them.
      • Civilizations will always try to get at least enough gold to survive Anarchy.
 

xanaqui42

King
Joined
Sep 5, 2006
Messages
780
  • Release 0.07 (unreleased)
    • Features:
      • Merge with 0.33g
      • Display tech values on tech popup screen (mostly for debugging weights and flavors)
      • Wild Hunt Fix (defect injected in Wiser Orcs 0.06)
      • Make more intelligent tech choices in anarchy (presently, they're very stupid).
      • Add XML for controlling response to barbarians.
      • Set up behavior change for minimum research.
      • Some religious strategies added, using quiz input from:
        • xienwolf
        • [to_xp]Gekko
        • avalonnn
        • kobo1d
        • Vehem
        • MagisterCultuum
        • Schmoe
        • Monkeyfinger
        • Zechnophobe
        • brucedecatz
      • Work on Spells:
        • Drown and other non-offensive spells that require the unit to move to a city (or your territory), and that also don't have python requirement code.
    • Files Changed
      • CIV4CivilizationsSchema.xml
      • CIV4LeaderHeadInfos.xml
      • CIV4CivilizationStrategyInfos.xml
      • GlobalDefinesAlt.xml
      • GlobalTypes.xml
      • CIV4TechInfos.xml
      • CvSpellInterface.py
      • CvCivilizationStrategyInterface.py
      • CvEventManager.py
      • CvGameCoreDLL.dll
      • CvUnitAI.cpp
      • CvCityAI.cpp
      • CvEnums.h
      • CyGlobalContext.cpp
      • CvGlobals.cpp
      • CyGlobalContext.h
      • CyGlobalContextInterface1.cpp
      • CvPlayerAI.h
      • CyPlayer.h
      • CvInfos.cpp
      • CvGlobals.cpp
      • CvXMLLoadUtilitySet.cpp
      • CvDefines.h
      • CvXMLLoadUtilitySet.cpp
      • CvDefines.h
      • CyPlayerInterface1.cpp
      • CvPlayer.h
      • CyPlayer.cpp
      • CvPlayer.cpp
      • CvInfos.h
      • CyInfoInterface3.cpp
      • CvPlayerAI.cpp
      • CvUnit.cpp
  • Work on Strategy Framework.
  • Work on AI_plotValue, AI_yieldValue - Improve avoid growth logic.
  • Work on Technology choices.
  • Workers shouldn't build non-mana improvements on mana nodes.
  • Work on adept mana node building. (This may be more general - any non-worker building)
  • Workers shouldn't destroy mana nodes.
  • AI protects its own heavily promoted units more.
  • AI targets enemy highly promoted units more.
  • Settlers are trying to settle with too few guards.
  • Look at CvPlot::changeVisibilityCount to determine if the visibility fix causes the same defect found in an early version of Smarter Orcs (with a similar fix).
  • Barbarian trait players are wasting troops preparing to attack Barbarian cities (?)
  • Look at chooseSpell
  • look at making adjustments for AI based on era based on game turn instead (present mechanism essentially favors some religions over others).
  • consider handling 0-movement units (separating them from main group unless they have a high value).
  • Make the food algorithm in AI_yieldValue respond to food from buildings (Breeding Pit).
  • Hyborem creation fixes
  • Re-check Khazad Strategy
  • Look at Science optimization - high science output cities should favor high science output buildings
  • Stop building cities & units at some point to present science collapse
  • valuing other's highly promoted units high as targets and actually making the AI go for suicide attacks as long as there's a good chance one of another's hero units gets taken out.
  • building non-military units (ex: settlers) when under attack
  • Bad Tactical movement - moving to a place where the unit will likely get crushed easily.
  • We want some determiner for when to prepare for war.
  • We want some determiner for whom to wage war against.
  • We want some trigger for a mid-game land grab.
  • Add XML switch to turn off Tech value display.
  • Better stack attack logic - more like a human would do - either using most powerful units with weaker defenders against counter-attack, or using weaker attackers to soften up defenses for the stronger attackers.
  • AI appears to not reduce unit and city creation based on economic problems.
  • The AI isn't recognizing that coastal areas are good for the Lanun.
  • The AI isn't focusing on transport technology and/or building transports when its growth is limited.
  • The AI isn't settling on non-primary areas.
  • Consider altering Faeryl's religious decisions favor Esus more, either as first or second religion.
Spoiler :

Unit AIs: UNITAI_CITY_DEFENSE, UNITAI_ATTACK, UNITAI_PILLAGE (this will handle drown; consider adding to all UNITAIs)

For all spells with UnitClassPrereq, as a low priority action, try to arrainge so that the spells are useful.

  • if fail civ pre-req, ignore.
  • if fail state religion, ignore.
  • if bInBordersOnly, move in borders.
  • if bInCityOnly, move in (closest?) city
  • if creates building, move to city with no building of that type
  • if building pre-req, move to closest city with that pre-req.
  • if has cost, reserve enough money for one casting. Only move when have enough money.
  • spellCallOfTheGrave - move to closest graveyard (?)
  • convertCityRantine - barbarian, weaker than Rantine
  • CreateDenBear, CreateDenLion - unowned, no improvement, at least 4 plots from any other bear den
  • Disrupt - other (neutral) player's city with weak culture.
  • Entertain - other (neutral) player's city, or own with hapiness problems.
  • Weapon upgrade - treat as spell requiring own city with forge, trade agreement, and better metal than already possessed, as well as a unit class requirement.
 

xanaqui42

King
Joined
Sep 5, 2006
Messages
780
New XML fields & python functions:

  • GlobalDefinesAlt.xml
    • AI_BASE_MAXIMUM_KHAZAD_GOLD_PER_TURN - the base maximum amount of gold the Khazad will attempt to obtain per turn.
    • AI_PER_CITY_MAXIMUM_KHAZAD_GOLD_PER_TURN - the additional maximum amount of gold per city the Khazad will attempt to obtain per turn.
    • BARBARIAN_FREE_TECH_PERCENT - the base research factor for the barbarians. Note that this is affected by world size, start era, game speed, and the number of civilizations which have this technology.
    • HIT_POINT_FACTOR - a factor for first strikes, hit points, healing, and direct damage. Note that very high values will not function (1-10 have been tested), and that 1 will give normal behavior. Changing this from 1 gives "Fair Combat" - essentially, less random combat.
    • YIELD_BASE_PRODUCTION_VALUE - the base yield value for a unit of production on a plot.
    • YIELD_BASE_COMMERCE_VALUE - the base yield value for a unit of commerce on a plot.
    • LOW_FOOD_DIVISOR_TENTHS - the divisor in tenths to the base yield value for low food (< than needed for 1 population) on a plot, assuming that growth is less than needed for 1 population. Note that 10 would give default behavior.
    • VERY_LOW_FOOD_DIVISOR_TENTHS - the divisor to the base yield value for low food (< than 1/2 of needed for 1 population) on a plot, assuming that growth is less than 1/2 needed for 1 population. Note that 10 would give default behavior, and that this does not trigger if LOW_FOOD_DIVISOR_TENTHS triggers.
    • RELIGION_WEIGHT_SPREAD_MULTIPLIER - a multiplier for the religion weight in creating a unit that will spread the religion. Note that a value of 0 will remove this behavior.
    • BARBARIAN_LOSS_MEMORY_TURNS- the number of turns a loss by a barbarian unit will be remembered by an AI.
    • BARBARIAN_LOSS_THRESHOLD_UNITS- the number of units that need to be lost within BARBARIAN_LOSS_MEMORY_TURNS to put the AI on a war footing with the Barbarian player.
      Spoiler :

      • MINIMUM_RESEARCH_DESIRED- the minimum research percentage desired by the AI, for he purposes of determining if said player in in financial trouble. Note that a value below 40 may have undesired effects.
  • CIV4LeaderHeadInfos.xml
    • PyInitialFunction - the python function to call at initialization in CivilizationStrategyInterface.py. It must be of the format functionName(iPlayer), or have no content. The python function it refers to must be declared in exactly the same manner.
  • CivilizationStrategyInterface.py
    • initial(argsList) - a way of hooking into the other initial functions. It's unlikely that you'll need to modify this.
    • initial<LeaderHeadName>(iPlayer) - the initial function for this leader head. At the moment, most of them do nothing.
    • turn(argsList) - a way of hooking into the other turn functions. It's unlikely that you'll need to modify this.
    • turn<StrategyName>(iPlayer) - the function called each turn for a civilization strategy. Like all functions called each turn, try to make it relatively efficient.
      Spoiler :

      • religionFounded(argsList) - a way of hooking into the other religionFounded functions. It's unlikely that you'll need to modify this.
      • religionConvert(argsList) - a way of hooking into the other religionConvert functions. It's unlikely that you'll need to modify this.
      • religionFounded<StrategyName>(iPlayer, eReligion, iFoundingPlayer) - the function called at the founding of religion eReligion by player iFoundingPlayer for a civilization strategy. Use this function instead of the turn function when appropriate.
      • religionConvert<StrategyName>(iPlayer, eReligion) - the function called at the conversion of religion eReligion for a civilization strategy. Use this function instead of the turn function when appropriate.
  • CIV4CivilizationStrategyInfos.xml
    • Type - the name for this civilization strategy.
    • CivilizationStrategyType - Civilization Strategy types are exclusive; that is, if a player gains any civilization strategy with the same type as any previous civilization strategy, it will automatically remove the previous civilization strategy. That's the theory anyway; it hasn't been tested yet.
    • FlavorType - the name of a flavor
    • iFlavor - this is added to any other player modifiers for this particular flavor. The other sources would be other civilization strategies, and the leader head.
    • ReligionType - the religion name
    • iWeightModifier - this is added to any other player modifiers for this particular religion weight. The other sources would be other civilization strategies, and the leader head. Note that unlike the leader head religion weight modifier, this does not affect the ability or inability of a civilization to gain a religion.
    • PyTurnFunction - the python function to call each turn in CivilizationStrategyInterface.py. It must be of the format functionName(iPlayer), or have no content. The python function it refers to must be declared in exactly the same manner.
      Spoiler :

      • PyReligionFoundedFunction- the python function to call each on a region's founding in CivilizationStrategyInterface.py. It must be of the format functionName(iPlayer, eReligion, iFoundingPlayer), or have no content. The python function it refers to must be declared in exactly the same manner.
      • PyReligionConvertFunction- the python function to call each on a the conversion of this player to a religion in CivilizationStrategyInterface.py. It must be of the format functionName(iPlayer, eReligion), or have no content. The python function it refers to must be declared in exactly the same manner.
      • iMinimumResearchChange - the change to the minimum research % (presently only used to determine if a player is in financial trouble).
Spoiler :

New Interfaces into C++ for Python:
  • CyGlobalContext
    • CvCivilizationStrategyInfo* getCivilizationStrategyInfo(int i) - returns a strategy info of the given index
    • int getNumCivilizationStrategyInfos() - returns the number of civilization strategy infos.
  • CyPlayer
    • void processCivilizationStrategy(int eCivilizationStrategy, int iChange) - if iChange == 1, add the civilization strategy eCivilizationStrategy to CyPlayer. if iChange == -1, remove the civilization strategy eCivilizationStrategy to CyPlayer.
    • int AI_getReligionWeight(int /*ReligionTypes*/ eReligion); - returns the current weight of religion eReligion to CyPlayer.
 

xanaqui42

King
Joined
Sep 5, 2006
Messages
780
Note that this is a mod off of Fire, not Shadow.

I like the Khazad being more viable as an opponent, and I love the reduced micro-management when I play Hyborem. The Sacrifice the Weak changes are a bit disappointing; I may want to re-visit them to determine if further tweaking is needed, or if the optimal choices are that similar between 1 and 2 food/pop.
 

MagisterCultuum

Great Sage
Joined
Feb 14, 2007
Messages
16,459
Location
Kael's head
Frankly I don't see much of a point in releasing this for .25, especially less than a weak before Shadow is released. It is supposed to fix many of the AI problems anyway. I would say you shouldn't waste you efforts until you know exactly what the AI can and can't do well in .30. The last Fire version is really just a BtS Beta, not meant to be used for serious gaming/modmods.


Still, some of the changes (like ignoring food) look like they will be quite useful; if you already have them working, then why don't you see if you can get Kael to add them to Shadow? There is probably still enough time for him to do so without delaying the release.

(Even if this does delay it by a little, I won't mind; since I finished my finals today I'm going home tomorrow, and thus will be limited to dial-up for a while. I could probably ask to go to my dad's office to use his DSL to download it, but I think I'd better wait until Christmas to do that. I got BtS as a Christmas present from my sister, which she let me have early if I agreed to keep it a secret and to wrap it for her. Downloading a mod for a game that I "don't have yet" might be suspicious. )
 

xanaqui42

King
Joined
Sep 5, 2006
Messages
780
Frankly I don't see much of a point in releasing this for .25, especially less than a weak before Shadow is released. It is supposed to fix many of the AI problems anyway. I would say you shouldn't waste you efforts until you know exactly what the AI can and can't do well in .30. The last Fire version is really just a BtS Beta, not meant to be used for serious gaming/modmods.
I'd started on this modmod prior to the announcement of the Shadow release date. I feel that since the initial version is going to be based off of late Fire anyway, a release prior to Shadow makes more sense than one after Shadow (the main mod group typically releases source code well after the release date). While this release is no where as dramatic as the earliest working version of Smarter Orcs, I feel that it's a significant improvement- and therefore worth releasing.

If Shadow fixes an AI problem, I'll be happy. At worst, I'll have to choose the better of their fix or mine for a particular issue - however, there are so many AI issues, that I doubt there will be much unintentional overlap, at least for the time being.
Still, some of the changes (like ignoring food) look like they will be quite useful; if you already have them working, then why don't you see if you can get Kael to add them to Shadow? There is probably still enough time for him to do so without delaying the release.
If his group does what it has previously, I'd guess that they'll seriously look at taking material from modmods in late Shadow, although I would have no objection to their choosing to do so at another time. For that matter, the combination of released sources and licensing under their own terms are specifically so that both the main modders and any other modmoders who are interested can use this work (or any portion thereof), even without contacting me.
 

Bringa

King
Joined
Jan 23, 2006
Messages
677
Hey xanaqui, how could I make myself useful right now?
 

it-ogo

Hedgehog
Joined
May 23, 2007
Messages
589
And what about magic system for AI? Is it a problem of Artificial Intellect or Artificial Wisdom?
 

xanaqui42

King
Joined
Sep 5, 2006
Messages
780
And what about magic system for AI? Is it a problem of Artificial Intellect or Artificial Wisdom?

Really, it's mostly a problem of specification. While there are a couple large groups of spells, many spells or special abilities have their own optimal use, which means that it needs to be specified separately and coded separately. While I suspect that few individual spells are hard, there are a lot of them.

Would I like to address them? Yes. However, we're going to consider most spells individually simply because that's how we're going to have to code most of them.
 

xanaqui42

King
Joined
Sep 5, 2006
Messages
780
Note that this is a mod off of Fire, not Shadow.

This will break saved games

The big addition in my mind is the resilience against the Barbarians. For fans of Fair Combat, the re-addition of this code will be significant (note, however,that the default, 1, essentially turns this off). However, note that the XML interface is different from the Smarter Orcs version - it's a single multiplier.

Also, there's a change a few people may not like - the base teching of the barbarians is set to be higher. This is in response to the wider tech tree - presently, it can take an inordinately long time for barbarians to even gain LV 2 units. Note that this can be turned back to its original value via XML.
 

xanaqui42

King
Joined
Sep 5, 2006
Messages
780
The short version is that I haven't spent enough time on it recently.

The long version is that hours after my last release, my compiler was attacked by a virus, then after that my computer was attacked by a pack of new trojan horses - the later were new/unique versions, as far as I could tell, so it took a while to root them out. Although I do hope to release during Shadow, I wouldn't expect a release in the immediate future.
 

Sandro

Chieftain
Joined
Aug 3, 2006
Messages
71
Location
Cph, DK
Darn, could really use an option for blocking the AI access to magic for more challenging games...
 
Top Bottom