Skip to content

Commit

Permalink
v0.88:
Browse files Browse the repository at this point in the history
* When the player tries to pay an AI civ for war, the trade screen no longer says "Maybe we'll change our minds in a few years" when the AI is almost willing to agree. I figured this gives away a bit too much information.
* BUG City Cycle Arrows disabled because they crash the game and I can't figure out why. It works in K-Mod, so this is somehow my fault. In an attempt to fix the issue, I've restored the signatures of several exported DLL functions. Didn't help, but I'm keeping the BtS signatures now; it's safer. [advc.042, advc.003]
* On Noble difficulty and higher, the AI no longer demands things of little value as tribute. E.g. won't demand a bonus resource in the Medieval era. [advc.104m]
* Reduced the research bonus from Raging Barbarians. I had added this in v0.80 to keep tech in games with Raging Barbarians closer to the real time line, but it was a bit much. [advc.308]
* 10-turn grace period for revolts in newly founded cities now only applies during the Ancient era. [advc.099c]
* War-on-friend diplo penalty corrected (was still not right in v0.88rc) [advc.130h]
* Rare(?) bug fixed in change advc.040 that caused a crash on maps with land near the poles.
* Fixed an issue with an earlier change to AI Auto Play - sometimes, it ran endlessly if started after switching to another civ. [advc.127]
* Some misc. tweaks in UWAI code.
* Can adjust UWAI war evaluation through AI_Variables_GlobalDefines.xml. [advc.104x]
* Added an assertion that checks if integers from XML are loaded successfully. Found and corrected a couple of unimportant errors this way and changed some game initialization code that had been trying to use XML data before it was loaded. [advc.003c]
  • Loading branch information
f1rpo committed Aug 24, 2017
1 parent 3b8bce6 commit fcf9a50
Show file tree
Hide file tree
Showing 39 changed files with 610 additions and 259 deletions.
5 changes: 3 additions & 2 deletions Assets/Config/BUG Main Interface.xml
Expand Up @@ -57,9 +57,10 @@
</option>

<!-- City Cycle Arrows by SimCutie -->
<option id="CityArrows" key="City Cycle Arrows"
<!-- advc.042: Commented out -->
<!--<option id="CityArrows" key="City Cycle Arrows"
type="boolean" default="True"
get="isShowCityCycleArrows" dirtyBit="MiscButtons"/>
get="isShowCityCycleArrows" dirtyBit="MiscButtons"/> -->

<!-- Progress Bar Tick Marks -->
<option id="ProgressBarsTickMarks" key="Tick Marks"
Expand Down
Binary file modified Assets/CvGameCoreDLL.dll
Binary file not shown.
3 changes: 2 additions & 1 deletion Assets/Python/BUG/Tabs/BugGeneralOptionsTab.py
Expand Up @@ -92,6 +92,7 @@ def createMiscellaneousPanel(self, screen, panel):
self.addCheckbox(screen, panel, "MainInterface__MinMax_Commerce")
self.addCheckbox(screen, panel, "MainInterface__ProgressBarsTickMarks")
self.addTextDropdown(screen, panel, panel, "MainInterface__BuildIconSize", True)
self.addCheckbox(screen, panel, "MainInterface__CityArrows")
# advc.042
#self.addCheckbox(screen, panel, "MainInterface__CityArrows")
self.addCheckbox(screen, panel, "MainInterface__RapidUnitCycling")
self.addCheckbox(screen, panel, "MainInterface__SimpleSelection")
5 changes: 3 additions & 2 deletions Assets/Python/BUG/TechPrefs.py
Expand Up @@ -36,8 +36,9 @@ class TechPrefs:

def __init__(self):
self.NUM_TECHS = gc.getNumTechInfos()
self.NUM_AND_PREREQS = gc.getDefineINT("NUM_AND_TECH_PREREQS")
self.NUM_OR_PREREQS = gc.getDefineINT("NUM_OR_TECH_PREREQS")
# <advc.003c> Was getDefineINT; use the cached values instead
self.NUM_AND_PREREQS = gc.getNUM_AND_TECH_PREREQS()
self.NUM_OR_PREREQS = gc.getNUM_OR_TECH_PREREQS() # </advc.003c>

self.mTechs = {}
self.lTechsByFlavor = []
Expand Down
5 changes: 3 additions & 2 deletions Assets/Python/BUG/TradeUtil.py
Expand Up @@ -116,8 +116,9 @@
DOMESTIC_OVERSEAS_TRADE = 1
FOREIGN_TRADE = 2
FOREIGN_OVERSEAS_TRADE = 3

MAX_TRADE_ROUTES = gc.getDefineINT("MAX_TRADE_ROUTES")
# advc.003c: XML isn't loaded when this line is executed; the value isn't used
# either, so I'm removing this line (to avoid a failed assertion)
#MAX_TRADE_ROUTES = gc.getMAX_TRADE_ROUTES()
FRACTIONAL_TRADE = False
TRADE_PROFIT_FUNC = None

Expand Down
29 changes: 25 additions & 4 deletions Assets/Python/K-Mod/AIAutoPlay.py
Expand Up @@ -143,11 +143,11 @@ def onBeginPlayerTurn( self, argsList ) :

if( game.getAIAutoPlay() == 1 and iPlayer > game.getActivePlayer() and gc.getActivePlayer().isAlive() ) :
# Forces isHuman checks to come through positive for everything after human players turn
# <advc.127> Commented out; pass instead. (The setAIAutoPlay
# call might be superfluous in any case.)
# <advc.127> Commented out; pass instead. (The setAIAutoPlay
# call might be superfluous in any case.)
#self.checkPlayer()
#game.setAIAutoPlay(0)
pass # </advc.127>
pass # </advc.127>

elif( self.bSaveAllDeaths ) :
if( game.getAIAutoPlay() == 0 and not gc.getActivePlayer().isAlive() and iPlayer > game.getActivePlayer() ) :
Expand All @@ -164,7 +164,28 @@ def onEndPlayerTurn( self, argsList ) :
# Replacement below.
#if (iPlayer == gc.getBARBARIAN_PLAYER() and game.getAIAutoPlay() == 1):
turnsLeft = game.getAIAutoPlay()
if (turnsLeft == 1 and iPlayer == gc.getBARBARIAN_PLAYER() and gc.getPlayer(0).isHumanDisabled()) or (turnsLeft == 0 and iPlayer < gc.getBARBARIAN_PLAYER() and gc.getPlayer(iPlayer + 1).isHumanDisabled()):
if turnsLeft > 1:
pass
# Find the closest player preceding the disabled human in the turn order
# (normally the barbarians)
disabledHuman = -1
for x in range(gc.getMAX_CIV_PLAYERS()):
if gc.getPlayer(x).isHumanDisabled():
disabledHuman = x
break
if disabledHuman == -1:
pass
preceding = iPlayer
turnsLeftTarget = 0
m = gc.getMAX_PLAYERS()
for x in range(disabledHuman - 1, disabledHuman - m, -1):
y = x % m
if gc.getPlayer(y).isAlive():
preceding = y
break
if preceding > disabledHuman: # If turn order wraps around
turnsLeftTarget = 1
if turnsLeft == turnsLeftTarget and iPlayer == preceding:
# </advc.127>
# About to turn off automation
self.checkPlayer() # advc.127: Un-commented this line.
Expand Down
4 changes: 2 additions & 2 deletions Assets/Python/Screens/CvMainInterface.py
Expand Up @@ -1655,8 +1655,8 @@ def updateMiscButtons( self ):
screen.show( "MilitaryAdvisorButton" )
screen.show( "VictoryAdvisorButton" )
screen.show( "InfoAdvisorButton" )
# BUG - City Arrows - start
if (MainOpt.isShowCityCycleArrows()):
# BUG - City Arrows - start advc.042: commented out
if false: #(MainOpt.isShowCityCycleArrows()):
screen.show( "MainCityScrollMinus" )
screen.show( "MainCityScrollPlus" )
else:
Expand Down
245 changes: 245 additions & 0 deletions Assets/XML/AI_Variables_GlobalDefines.xml
@@ -0,0 +1,245 @@
<?xml version="1.0"?>

<Civ4Defines xmlns="x-schema:CIV4GlobalDefinesSchema.xml">
<!-- [advc.104x] This file used to be called BBAI_AI_Variables_
GlobalDefines.xml; now also contains UWAI parameters.
UWAI breaks down the computation of AI war utility into a sum of
26 "aspects", most of which are either in favor of war (added to the
total war utility) or against war (subtracted). There are a few mixed
aspects that could either increase or decrease war utility.
Each aspect corresponds to one particular motivation for or against war.
Through this file, a weight is assigned to each aspect. This weight is
interpreted as a percentage by which the aspect utility is multiplied.
The default (recommended) weights are all 100. This doesn't imply though
that all aspects contribute equally by default; the weights are only a
final adjustment to the (hardcoded) formulas.
A weight of e.g. 50 halves the default impact of an aspect, 200
doubles it. 0 means that the aspect is entirely disregarded. A
negative weight (not recommended) turns a pro-war aspect into an
anti-war aspect or vice versa.
In the descriptions below, "we" refers to the AI civ that is
considering war. -->
<Define>
<!-- The cities we expect to conquer as economical assets. -->
<DefineName>UWAI_WEIGHT_GREED_FOR_ASSETS</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- The economical value of accepted capitulations.
(Not: Getting closer to a Conquest victory; that's handled under
MILITARY_VICTORY.) -->
<DefineName>UWAI_WEIGHT_GREED_FOR_VASSALS</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- By eliminating a civ early in the game, some of the unsettled land
near it can be settled and exploited. Lebensraum if you will (and
in Civ, it actually works). -->
<DefineName>UWAI_WEIGHT_GREED_FOR_SPACE</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Just the value of expected reparations really. Sponsored war is
covered by HIRED_HAND. -->
<DefineName>UWAI_WEIGHT_GREED_FOR_CASH</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- The satisfaction of seeing our (worst) enemies devastated. -->
<DefineName>UWAI_WEIGHT_LOATHING</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- The prospect of a speedy military victory incites us to wage war.
This covers Domination, Conquest and Diplomatic victory; Diplo
victory also factors into ILL_WILL. -->
<DefineName>UWAI_WEIGHT_MILITARY_VICTORY</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Protect our partners because we want to continue trading with
them, and don't want to become isolated. Assistance for more
principled reasons is covered by FIDELITY; the "mutual strugle"
diplo bonus by SUCKING_UP. -->
<DefineName>UWAI_WEIGHT_PRESERVATION_OF_PARTNERS</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<!-- The next four - Reconquista, Rebuke, Fidelity and Hired Hand - are about
upholding a reputation. Since Civ 4 doesn't have a reputation system,
this is mostly (irrational) role-playing. -->
<Define>
<!-- By reconquering previously owned cities, we show that it's not
worthwhile to conquer our cities; we'll get them back. -->
<DefineName>UWAI_WEIGHT_RECONQUISTA</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- We show we can take by force what was denied to us when we
demanded tribute. I.e. increased war utility if we remember how
they "refused to give us tribute". A rebuked demand can also lead
to an immediate change in war planning, but that's handled by
WarAndPeaceAI::Team::respondToRebuke, not in XML. -->
<DefineName>UWAI_WEIGHT_REBUKE</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- By declaring war on a civ that recently attacked one of our
partners, we demonstrate that its worthwhile to be our partner,
and dangerous to attack our partners. -->
<DefineName>UWAI_WEIGHT_FIDELITY</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- We continue a war because we've been paid for it. (Or maybe rather
to prove that we're a reliable hireling.) -->
<DefineName>UWAI_WEIGHT_HIRED_HAND</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- By conquering cities, we reduce culture pressure on our cities. -->
<DefineName>UWAI_WEIGHT_BORDER_DISPUTES</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Fight a joint war for the "mutual struggle" diplo bonus. -->
<DefineName>UWAI_WEIGHT_SUCKING_UP</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- To weaken a civ that we perceive as a long-term threat. -->
<DefineName>UWAI_WEIGHT_PREEMPTIVE_WAR</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Stop civs that we don't like from winning the game, or even civs
that we're Pleased with if we're in contention ourselves. Likely
winners can be civs close to a victory condition, but also civs
that have gotten ahead in score or that we expect to get ahead
through an ongoing war. -->
<DefineName>UWAI_WEIGHT_KING_MAKING</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Our military build-up, lost units and ravages of war. Adjusted
based on our opportunities for peaceful development (i.e. an
opportunity cost). Also takes into account whether we'll have
further use of units surviving the war and whether lost units
will have to be replaced. -->
<DefineName>UWAI_WEIGHT_EFFORT</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- The risk of losing cities or vassals in the war, or even having to
capitulate or being eliminated. -->
<DefineName>UWAI_WEIGHT_RISK</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- The negative diplomatic consequences of war: angering the civ
we're fighting against and third parties. -->
<DefineName>UWAI_WEIGHT_ILL_WILL</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Don't want to plan war against civs that we like. This is only
role-playing; ILL_WILL handles the rational reasons for not
attacking partners. -->
<DefineName>UWAI_WEIGHT_AFFECTION</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Distractions from fighting multiple wars are already covered by
the military analysis, but not quite reliably so, so this is an
extra cost to discourage wars on multiple fronts. -->
<DefineName>UWAI_WEIGHT_DISTRACTION</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Anger from war weariness and bonds of faith. -->
<DefineName>UWAI_WEIGHT_PUBLIC_OPPOSITION</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- War leaves fewer units stationed in cities, which can lead to
revolts in cities conquered in some previous war. Due to the
"Immortal Culture" changes, this can be a significant considera-
tion sometimes. -->
<DefineName>UWAI_WEIGHT_REVOLTS</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Applies only when we're paid to start a war and the sponsor isn't
apparently in need of assistance (or not even at war). Why hire
us then? Will have to pay extra to allay our suspicions. -->
<DefineName>UWAI_WEIGHT_ULTERIOR_MOTIVES</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Discourages early war against humans; not fair when the AI has a
head start. -->
<DefineName>UWAI_WEIGHT_FAIR_PLAY</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- War as its own purpose. Before this aspect was added, there was too
little war before the Medieval era. Especially affects AI
leaders with aggressive/ suicidal personalities. -->
<DefineName>UWAI_WEIGHT_BELLICOSITY</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<Define>
<!-- Is the tactical situation favorable, i.e. do we/ do they have
exposed damaged units, cities that are about to fall, or
reinforcements coming up. When in doubt, entangled units lead to
increased war utility. If still preparing war: Do we have suffi-
cient units to start the war; is there still enough time to build
them? -->
<DefineName>UWAI_WEIGHT_TACTICAL_SITUATION</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>
<!-- [/advc.104x] -->

<!-- -->
<!-- Better BTS AI / K-Mod variables to allow easy AI tweaking -->
<!-- by jdog5000 / karadoc -->
<!-- -->
<Define>
<!-- War success value of capturing a city. BBAI default: 25, BTS 10 -->
<DefineName>WAR_SUCCESS_CITY_CAPTURING</DefineName>
<iDefineIntVal>25</iDefineIntVal>
</Define>
<Define>
<!-- Ratio of enemy power to team power for AI to consider running TURTLE (all out defense, no offensive forays) strategy.
Equal power would be 100. BBAI default: 250 -->
<DefineName>BBAI_TURTLE_ENEMY_POWER_RATIO</DefineName>
<iDefineIntVal>250</iDefineIntVal>
</Define>
<Define>
<!-- Minimum stack strength ratio at which AI will attack enemy city it is next to, higher means less suicide. BTS default: 120 -->
<DefineName>BBAI_ATTACK_CITY_STACK_RATIO</DefineName>
<iDefineIntVal>125</iDefineIntVal>
</Define>
<Define>
<!-- Minimum attack odds of best attacker for AI to skip bombarding a city and just attack. BBAI default: 12 -->
<DefineName>BBAI_SKIP_BOMBARD_BEST_ATTACK_ODDS</DefineName>
<iDefineIntVal>10</iDefineIntVal>
</Define>
<Define>
<!-- Base ratio of stack strengths for AI considering skipping bombard and just attacking enemy city.
This ratio is reduced by the AI's best attacker odds and how long it will take to bombard the city.
Lower means AI will more readily skip bombarding. BBAI default: 300 -->
<DefineName>BBAI_SKIP_BOMBARD_BASE_STACK_RATIO</DefineName>
<iDefineIntVal>260</iDefineIntVal>
</Define>
<Define>
<!-- Minimum stack strength ratio for AI to skip bombarding city and just attack, higher is more conservative. BBAI default: 150 -->
<DefineName>BBAI_SKIP_BOMBARD_MIN_STACK_RATIO</DefineName>
<iDefineIntVal>140</iDefineIntVal>
</Define>
<Define>
<!-- Minimum city site value that the AI will consider settling. default: 600. (K-Mod) -->
<DefineName>BBAI_MINIMUM_FOUND_VALUE</DefineName>
<iDefineIntVal>600</iDefineIntVal>
</Define>
</Civ4Defines>
45 changes: 0 additions & 45 deletions Assets/xml/BBAI_AI_Variables_GlobalDefines.xml

This file was deleted.

0 comments on commit fcf9a50

Please sign in to comment.