Smarter Orcs (a FfH II mod)

Great Works
The first unit-based special feature is in. Prophets and Disciples can now both create Great Works, and will do so as a fairly low-priority task, and only when both the unit has relatively little XP, and the benefit is regarded as large (for example, a city with 0 culture). The AI will also create a great work instead of destroying a unit. Question: should this also be done for human players, or can someone think of a reason why a human wouldn't want a great work instead of destruction (obviously, only in cases where the great work is valid)?

most common uses that i have seen are for rapid gain of a captured city (it instantly solves the cities anarchy period. also , does the AI look for culture war cities (aka where culture push is an issue) on where to burn these?
 
Great Works
The first unit-based special feature is in. Prophets and Disciples can now both create Great Works, and will do so as a fairly low-priority task, and only when both the unit has relatively little XP, and the benefit is regarded as large (for example, a city with 0 culture). The AI will also create a great work instead of destroying a unit. Question: should this also be done for human players, or can someone think of a reason why a human wouldn't want a great work instead of destruction (obviously, only in cases where the great work is valid)?

most common uses that i have seen are for rapid gain of a captured city (it instantly solves the cities anarchy period. also , does the AI look for culture war cities (aka where culture push is an issue) on where to burn these?

In the former issue, it will under some circumstances. I'm nthot clear that it will under all circumstances (and in any case, if the unit has enough XP, it will never create a Great Work). In the later case, it will only do that if the results are on the margin - in other words, if the AI calculates that having a single such great work would have a significant impact; this will not be true in most cases. It does not calculate the potential effect of multiple Prophet sacrifices in a single city.

Frankly, the code is a small modification of the general Great Artist great work code. The modification is pretty much to disfavor using this for units with significant XP.

The algorithm (note that this is only called when the unit has nothing better to do):
Code:
  For each city,
    If it's possible to create a great work there, and there are no visible enemy units, and no other units are planning to create a great work in this city,
      If a path can be generated from this unit to this city,
        Value = The Culture pressure of that city.
        Value = Value - (100 * the culture in the city)/the Culture from the great work.
        Value = Value  - (10 * (the unit's XP - its owner's free XP)/the Culture from the great work
        If the value is greater than 0, decide that this could be a great work.
Use the greatest value over 0 for the city to create the great work within.
Culture Pressure:
Code:
  For each plot in the maximum working city radius:
    that is not owned, PlotValue = 1
    that is owned either 0% or 76-99% by the city's owner, PlotValue = 1
    that is owned 1-75% by the city's owner off of central plot:
      PlotValue = (100 - city owner's ownership %) 
    If it's not the central plot:
      PlotValue = PlotValue * 4/(the number of city plots in the radius)
    If there's a bonus here, and it's the last one for this player:
      PlotValue = PlotValue + 4* the value of the bonus (0-100)
    If there's a bonus here, and it's not the last one for this player:
      PlotValue = PlotValue + 2* the value of the bonus (0-100)
    If PlotValue > 80 and the owner of the plot is equal to the plot area ID,
      PlotValue = PlotValue * (100-PlotValue)/100
    If the plot is owned by the same team as owns this city,
      PlotValue = PlotValue / 10
    If the plot is owned by a friendly player,
      PlotValue = PlotValue / 5
    If the plot is owned by a non-friendly player,
      PlotValue = PlotValue * 2
The Total value is the sum of the plot values.

My comments on the Culture Pressure algorithm:
  1. The present bonus code can account for if it's the last one for this player, or not. This should likely be replaced by, say, 4 * the value of the bonus.
  2. "owner of e plot is equal to the plot area ID" is meaningless; it's comparing apples to oranges.
  3. A plot value of 101 or higher in "PlotValue = PlotValue * (100-PlotValue)/100" can result in a negative value. This should not be the case.
  4. I'd reduce the friendly divisor down, perhaps to 4.5 or so.
 
The main change is that there's a merge with 0.23c. Obviously, this will break saved games.

There are also some changes to the great works code. Besides the suggestions I mention above, I made it much less likely that units with significant XP will choose to create great works.
 
As a warning for anyone using any of the version with the combat changes: A FIRST_STRIKE_FACTOR other than 1 (via XML change) will both cause the wrong defender to be chosen in certain cases, and the odds to be displayed incorrectly in any cases where first strikes are involved.
 
Between turns 153 and 154:

Traceback (most recent call last):

File "CvEventInterface", line 24, in onEvent

File "CvFFHSpellsEventManager", line 78, in handleEvent

File "CvFFHSpellsEventManager", line 89, in _handleDefaultEvent

File "CvEventManager", line 759, in onBuildingBuilt

RuntimeError: unidentifiable C++ exception
ERR: Python function onEvent failed, module CvEventInterface

The Great Library was completed at beginning of turn 154, and a great prophet spawned.

Additionally, using that great prophet to construct tablets of bambur a ctd occured

Log Files

autosave turn 154(after great prophet)

autosave turn 153

edit: reloading turn 154 instead of CTD on tablets of bambur creation the above python message occured.
 
Between turns 153 and 154:

Traceback (most recent call last):

File "CvEventInterface", line 24, in onEvent

File "CvFFHSpellsEventManager", line 78, in handleEvent

File "CvFFHSpellsEventManager", line 89, in _handleDefaultEvent

File "CvEventManager", line 759, in onBuildingBuilt

RuntimeError: unidentifiable C++ exception
ERR: Python function onEvent failed, module CvEventInterface

The Great Library was completed at beginning of turn 154, and a great prophet spawned.

Additionally, using that great prophet to construct tablets of bambur a ctd occured

Log Files

autosave turn 154(after great prophet)

autosave turn 153

edit: reloading turn 154 instead of CTD on tablets of bambur creation the above python message occured.

Wow! Rolled up into one, you appear to have found a FfH II defect and a Vanilla defect. I also noted another defect setting up to run this test.

I've removed the infinite loop and fixed the movie check (locally), but I'm going to need to do more verification. It would also be good to try to fix the path issue (if I can).

Edit: I was wrong, there is no FfH II defect; this is strictly a Vanilla defect.
 
This is a modification to Fall From Heaven II (0.22h) to improve its AI.

You probably want to change this line in the download database ;)
 
You probably want to change this line in the download database ;)
Thanks.

Version 0.14:
An infinite loop from failing to find a movie (or other art object) was removed.

Version 0.13:
FIRST_STRIKE_FACTOR should now work correctly for non-default values (combat odds and defender determination both had issues when the number of first strikes changed).
Minor speedup changes.

One thing that did not get in was the path fix; I've given up on trying to fix that for the moment. I placed a new line in the Installation instructions to inform those interested how to address the issue manually.

The next most likely feature (barring another major defect report) is to work on a substantive speed issue.
 
Giddion, you seem a little confused. Yes, ffh is at 023c now, and that's the version Smarter Orcs is running on. I don't understand what your question is.
 
I'm relatively new to FFH, but fairly experienced with Blake's AI improvements. I recently downloaded Smarter Orcs and just wanted to thank you guys for all the hard work you're putting into this. My typical map setting is small, cold, pangea, low sea level, aggressive AI with 5 civs on Prince. I played a few games over the weekend and here are some thoughts:

I had to turn raging barbs off as the first several games I played 2 out of the 4 AI civs would fall to the barbs, without Orthus bugging them either (he was usually near me... :eek:). I don't mind a civ going down every now and then, but when half the AI's consistently go down, it's a bit much.

It seems like the AI expands a bit on the slow side. It depends on what civ they are, but in general, I didn't have any difficultly out-expanding them while maintaining military and economy, and I'm typically a slow expander. Maybe it's a play style issue and with FFH, it's better not to expand too quickly? I sometimes lose momentum in the mid game so maybe I'm not setting up my early game right.

Workers seem a bit smarter. Are automated workers and the AI worker code the same? I think I read where with Blake's AI, they were the same. Sometimes, I'll test the AI worker code and I'm not sure that automated workers are using the same code. For example, it still seems as if workers ignore river tiles within the city limits and prioritize building farms outside of the city limits. Something that I never understood is why the AI feels it's necessary to build farms outside of city boundaries? It's good to see the AI workers building improvements on resources even if they don't have the tech (e.g. farming a river elephant prior to hunting).

Tech priorities are much improved and it's great to see the AI actually using some of the available civic options, like Agriculture. Flauros prioritizing Code of Laws for Aristocracy, his favorite civic, adds some good flavoring too.

Performance does suffer. I dropped down to the small map size and while the beginning of the game if fine, mid-late game really starts to slow down. Small price to pay though.

On more question, was the :gp: tech bulbing changed from 22h to 23c? Or is it something in Smarter Orcs? I noticed that my first great sage (I usually get him with Writing) bulbs Mathematics, and not KotE.

Thanks again for this. Overall, I love it, can't go back to vanilla FFH. :goodjob:
 
xanaqui is doing most of the work on this, and he will be able to answer you much better than me, but I'll just quickly answer what I can:

As far as I know, automated worker use pretty much the same AI as the AI's workers (same for city governor). I haven't seen AIs building farms outside of fat crosses, but then again, I haven't watched out for that sort of thing. Could it be that the AI played Kuriotates? The sprawling trait gives them an additional ring to work. Otherwise this is a curious bug, and one that we should definitely address.

Tech priorities are a little undone still, but I do feel I could improve on vanilla ffh a little. What you've observed, for instance, is a function of a new flavor I introduced (FLAVOR_CALABIM), which greatly favors Code of Laws. Similarily, the Luchuirp will go for Construction very quickly, and so on. I'm still not happy with this. This is semantically nonsense. There *ARE* situations when those civs will want to go for something else first. What we need is a finely tuned model of goals for the AI, where it sets tech goals (and does other things) according to what it deems most important right now. However, for the time being, our solution works.

I don't think we've changed any game mechanics such as which tech you get for popping a GS. This information should be in the XML though, so if you're really curious, you can have a look at civ4wiki's documentation of the XML files and find the one that contains this information. Generally we try not to change any game mechanics. We did implement the combat change (something I can absolutely not live without anymore; the other night I wanted to test whether an OOS bug in multiplayer was an FFH defect or something in smarter orcs, so I went back to a 100% pristine 023c, but me and the friend I usually play with could absolutely not bear more than 50 rounds of the vanilla combat. It's painful! Why would you lose 90% combats? It's frustrating and arbitrary)

I did implement (with xanaqui's help) a minor speedup change in 010, I think; from xanaqui's todo I see that the next order of business is another speedup. I hope that ultimately we'll carry this over to FFH 0.3 for BtS, and that THAT will take care of the speed problems. BtS really is very very fast.

I'm very glad you're enjoying this modmod :)
 
I haven't seen AIs building farms outside of fat crosses, but then again, I haven't watched out for that sort of thing. Could it be that the AI played Kuriotates? The sprawling trait gives them an additional ring to work. Otherwise this is a curious bug, and one that we should definitely address.
Not a bug, feature. If the worker has nothing better to do it tries to spread irrigation. Possible benefits are using the irrigation (if ever needed) and using the improvement (if a city is placed close enough). Only problem is if the worker get killed for it. Like one of mine did in BtS... went to the border of the English near two of their cities in the middle of a war to provide irrigation I didn't need. Great idea :rolleyes:
 
Well, I wasn't 100% sure if the auto workers prioritizing farms outside of the city limits was correct, so I just ran a test scenario. Here is the result. Not sure if the AI workers do this, but I can test that out too with Alt-Z. Here's a screenie.

In this test case, the only worker tech I researched was agriculture. The worker popped just as the tech was complete and he promptly farmed the rice. He then went back to the capital and fell asleep until border expansion. That's when the screen shot is taken.

Spoiler :
AutoWorkerEx.jpg
 
Okay, sorry to spam messages, but this appears to be only for human player's automated workers. I just went back and loaded up a previous autosave, alt-z'd to another player and ran the game for a few turns. When I went back, the worker was building a farm on the flood plains.

No big deal, I'm not sure how many people use auto workers at all, I just use it for testing every now and then.
 
I'm relatively new to FFH, but fairly experienced with Blake's AI improvements. I recently downloaded Smarter Orcs and just wanted to thank you guys for all the hard work you're putting into this. My typical map setting is small, cold, pangea, low sea level, aggressive AI with 5 civs on Prince. I played a few games over the weekend and here are some thoughts:
I had to turn raging barbs off as the first several games I played 2 out of the 4 AI civs would fall to the barbs, without Orthus bugging them either (he was usually near me... :eek:). I don't mind a civ going down every now and then, but when half the AI's consistently go down, it's a bit much.
I gather that this is bad? My experience with core FfHII and raging Barbarians was that all non-Barbarian trait civilizations (except, sometimes, the human one) would die, every time I tried it.

It seems like the AI expands a bit on the slow side. It depends on what civ they are, but in general, I didn't have any difficultly out-expanding them while maintaining military and economy, and I'm typically a slow expander. Maybe it's a play style issue and with FFH, it's better not to expand too quickly? I sometimes lose momentum in the mid game so maybe I'm not setting up my early game right.
You may be correct. I think it's a little faster than core FfH II, but it could be pumped up (at least for those civs where doing so would help).

Workers seem a bit smarter. Are automated workers and the AI worker code the same? I think I read where with Blake's AI, they were the same. Sometimes, I'll test the AI worker code and I'm not sure that automated workers are using the same code. For example, it still seems as if workers ignore river tiles within the city limits and prioritize building farms outside of the city limits. Something that I never understood is why the AI feels it's necessary to build farms outside of city boundaries? It's good to see the AI workers building improvements on resources even if they don't have the tech (e.g. farming a river elephant prior to hunting).
I thought so, but your testing shows otherwise. I'll put looking at the worker AI on the list.

Tech priorities are much improved and it's great to see the AI actually using some of the available civic options, like Agriculture. Flauros prioritizing Code of Laws for Aristocracy, his favorite civic, adds some good flavoring too.
Thank Bringa for that; I've yet to get to Technologies (other than reducing the frequency of grabbing low-hanging fruit). Static evaluation is hardly perfect, but a good fairly static evaluation is far better than a bad fairly static evaluation.

Performance does suffer. I dropped down to the small map size and while the beginning of the game if fine, mid-late game really starts to slow down. Small price to pay though.
I agree; I'm going to try attacking one of the worst performance blocks (after defect fixes). If it works well, I'll apply it elsewhere.

On more question, was the :gp: tech bulbing changed from 22h to 23c? Or is it something in Smarter Orcs? I noticed that my first great sage (I usually get him with Writing) bulbs Mathematics, and not KotE.
Yes; I noticed this too. Unfortunately, the numbers for the bulbing are directly from the AI numbers for specific flavors for technology (FLAVOR_SCIENCE in this case). Since these numbers were altered to grant better technology evaluation, we'd need to make a moderate change to restore the original bulbing preferences without affecting the technology AI choices. Do you think we should do so?

Thanks again for this. Overall, I love it, can't go back to vanilla FFH. :goodjob:
Thanks :)
 
Tech priorities are a little undone still, but I do feel I could improve on vanilla ffh a little. What you've observed, for instance, is a function of a new flavor I introduced (FLAVOR_CALABIM), which greatly favors Code of Laws. Similarily, the Luchuirp will go for Construction very quickly, and so on. I'm still not happy with this. This is semantically nonsense. There *ARE* situations when those civs will want to go for something else first. What we need is a finely tuned model of goals for the AI, where it sets tech goals (and does other things) according to what it deems most important right now. However, for the time being, our solution works.
I agree. By the way, if you'd like to take a stab at writing up how you think it should work, feel free to do so. Decent technology AI is my primary goal for 0.30, so you have time.
 
I gather that this is bad? My experience with core FfHII and raging Barbarians was that all non-Barbarian trait civilizations (except, sometimes, the human one) would die, every time I tried it.

Hmmm.... I don't recall this happening too often in core FFH2 in my previous games. Typically, one civ might go down if Orthus caught them off guard. I do like to play FFH2 with raging barbs, but I always thought there should be a barb slider instead of the set three options (no barbs, regular barbs, raging barbs). My happy medium lies somewhere between regular and raging, but that's just me... :D

Yes; I noticed this too. Unfortunately, the numbers for the bulbing are directly from the AI numbers for specific flavors for technology (FLAVOR_SCIENCE in this case). Since these numbers were altered to grant better technology evaluation, we'd need to make a moderate change to restore the original bulbing preferences without affecting the technology AI choices. Do you think we should do so?

If I recall correctly from a previous post, you said your tech priorities would steer the AI away from magic techs because they can't really handle it ATM. Perhaps it would be a good idea to wait until the magic AI is written and the tech priorities are re-evaluated before you start tweaking the bulbing? Or am I not understanding how it works?
 
Hmmm.... I don't recall this happening too often in core FFH2 in my previous games. Typically, one civ might go down if Orthus caught them off guard. I do like to play FFH2 with raging barbs, but I always thought there should be a barb slider instead of the set three options (no barbs, regular barbs, raging barbs). My happy medium lies somewhere between regular and raging, but that's just me... :D
I'll put that on the list, then. I suspect that the problem is that the AI doesn't treat the Barbarians as a threat, so they don't build up their military properly upon a significant Barbarian attack. It's also possible that the barbarians are simply more of a threat.
 
ok, just assuming this is related. I haven't really played Basium/Hyboreum much at all.

First issue is real minor: options reverting to default after switching to Basium(namely: wait at end of turn, quick offense). The check box is still marked but they both act as though they are not. unchecking and rechecking them resolves the issue.

Second is the teammate (Basium or your previous civ) likes to gift all their resources to you, 1 every turn. Occassionally they will cancel the gift made last turn, only to offer it again the following. I assume this will follow suit when configuring teams in custom game.

Kuriotates gifted all their dye, sheep, each mana, pig, etc.
Malakim strangely gifted 3 mind mana(1 at a time) with only 2 nodes, one with mind, one with life(gifted life too).
Basium gifted all mana and then pig once he acquired it.

An afterthought, I don't recall having an actual plot of any of the resources given. That is my civ may have obtained a resource but it was not through a node, pasture, farm etc. If that's the case then the AI is just not limiting itself to holding onto the last of a resource.

Sorry I didn't save anything as an example :( Just wanted to put this up here as something to keep in the back of your head.

PS much love for the path fix! I didn't even realize there was system path info in any of the python files. Will have to poke around more to see if there are any others. If no other recourse comes up, that file could be written on the fly from an nsis installer.
 
Back
Top Bottom