AI/Interface Mod, Possible?

MeestaDude

Chieftain
Joined
Jul 21, 2002
Messages
19
I have not dug into the code yet, but I am very familiar with programming and am interested in making some mods to Civ IV of a possibly complicated nature. I'd like some feedback on whether these seem possible, or possibly have already been done.

Critical components of the AI mod are described in this first post, additional alterations will be posted in a reply right afterwards.

Can I?

-Overhaul the diplomacy dialog to add new options and completely replace the trading AI used by computer players.

WHY: My mod is based on giving the AI a more rational/strategic method of making trades. It will calculate the value of any trade to its empire, be it resource/tech/city/treaties/etc, and also estimate the value of what it is giving to you in return for your empire (as well as the cost to give it away).

The additional dialog options relate to making more complex negotiations possible. For instance one would give the player a general estimation of the value of tradeable items (for instance you could ask what your biggest non-capital city is worth in gold equivalent).

In addition to trade a similar process is also used for the value of peace treaties, alliances, and so on... the AI will attempt to use the Diplomacy screen more proactively to further its national interests. For instance, instead of asking the player to declare war on its enemies, it may offer tech/resources, a city, or even a 'partition' of the enemy empire (one of the new proposals, agrees to let you take over some cities if it is allowed to hold some cities, failure to keep with the terms may lead to war between your empires).

Replacing this AI and the supporting diplomacy changes is the most important feature.


-Change the way AI calculates stance towards the player.

WHY: I'd like to modify the scale to have a wider spread (-30 to 30). I'd change the values associated with some factors, and add new ones. It will generally be harder to get pleased/annoyed levels, but the rewards will be stronger part of AI diplomacy calculations. Also if you do tick off an AI the ability to rebuild your reputation will be somewhat easier.

-Overhaul the entire AI...

WHY: This is not a critical component, but as a further development I wouldn't mind digging into completely changing the way the AI runs its empire from every warrior on up to its nuclear policy. I'm assuming for the most part the existing code can be broken into its essential functions and reused and then study how to implement the features I would like.

-- Subpoint: Change the AI's method of conducting war

WHY: I would like to move the AI towards adopting several types of war (it can use and channge midflight its overall strategy), these could include:

= Defensive War: Hold onto main cities with some offense mixed in more to stop foreign invasions than to take territory. Mostly used if someone declares on you, and you have no interest in taking their land.

= Single Front - Single Point Invasion: The AI creates a massed army at one point and attacks the player at one location with everything. Then can move onto next target, or change strategy. It will be somewhat like a stack of doom, although given the collateral damage ability it will spread forces where it makes sense. Typically used when the AI is interested in a particular target (a city with a resource for instance).

= Single Front - Wide Invasion: The AI masses along a 'line' of attack. For instance, a common shared border with enemy. Force is roughly evenly distributed over area into multiple attack groups (so instead of one stack of doom, maybe three or four smaller stacks). The line generally advances in pace, eliminating everything in front of it. At cities attack groups may converge to siege, take city, and spread back into line. This is pretty much an all out war tactic, slow but thorough, and may result in WW1 like trench-warfare.

= Full Invasion: AI masses a complete assault upon an empire, with attack groups positioned to attack multiple insertion points at once. This is a premeditated warplan involving large resource contribution... however, if the player is attacked on all sides at once it would be pretty amazing. This attack method would often be done in coordination with other AI's or the player (through advanced diplomacy options).

= World War... Multi-front: When multiple nations are pulled into the war the AI might go into 'world war' mode and split its empire into multiple fronts. There are defensive fronts, the borders and chokepoints of its own nation, and offensive fronts, potential targets. Forces will be assigned to each threat as deemed appropriate. In this situation the AI will be cautious, focusing on defense before offense.

These war methods would generally involve programming unit management AI. Generally units will be organized into groups with some formation, and then the AI will operate on the group level to determine its overall military strategy (reduces operations at unit level, so hopefully it scales well).

-- Subpoint: AI Expansion modification

WHY: Generally have the AI spread its cities more, higher quality over quantity. Make sure it specializes them intelligently. Also make sure it meshes with the new strategies involved in the war/diplomacy mods.

-- Subpoint: Technological Development

WHY: Change the AI's technology strategy to be more varied and fit to certain purposes. Also make a cooperative technology trading based AI, the AI may negotiate 'research treaties' where it will gather into a consortium of tech research nations assigning each nation a set of tech's to target and trade to other players. This process accelerates tech growth, assuming the parties are honest (betrayal will result in bad relations/war).


This is the major AI changes I would like, although the first one, new Diplomacy is all I am currently targeting, and would be a significant improvement in itself. Remember, I would like to know whether anyone exploring the SDK/code has any information that can say whether this is possible, and of course any examples of alteration that are anywhere close to these is useful. For instance, if someone has an AI mod that changes unit behaviour, or made a Diplomacy screen mod, those things I can look at, break apart, and turn to my own uses.

Thank you, further changes are discussed in the next post. The alterations mentioned above only change the way the AI DECIDES how to play the game.
 
This list of changes involves changes to the way certain elements in the game work, that is, deviations from the basic rules of vanilla Civ IV.

-Give Forts Zone of Control: If you enter a square adjacent to the fort that is occupied by units (some minimum, maybe greater than one). That fort has zone of control, and the occupying units must be reduced below the minimum before you can move into another square adjacent to the fort.

WHY: Forts suck as they are. Also it allows forts to be used as a sort of border patrol possibility. Entry into adjacent squares is only prohibited, one could move into the fort zone, and then out of the fort zone in a different square, so a line of forts will be needed, or placement of the fort at a checkpoint.

The alterations necessary will involve limiting movement possibilities of units, checking to see if a square is adjacent to a fort, and determining whether the fort is occupied (and by how many units). If a fort doesn't have enough units it is assumed it doesn't have enough manpower to police the border, so it can't exert zone of control. Also, need to check if units are military units, no settlers/workers/scouts....

- Forts create national borders: Give all land in the fort and its adjacent squares to the nationality of the units in the fort (some minimum units required). Exception, overriden by cities.

WHY: Allows forts to be used to grab resources not normally within the cultural borders. Also can be used to establish a better border than that provided by the natural culture of cities. Demilitarized zones as well, a line of forts can be used as a buffer between two nations.

Changes involved: Somehow making national borders as a result of fort placement in addition to the city pass. Still must keep cities first, and culture should override and even FLIP forts to the dominant culture. However, a civ can't create a city within cultural borders, so smart fort placement should prevent flips. This will prevent forts being generated to cover all the resources and make cities ineffective. Also, even with open borders agreements, enemy units should be excluded from entering a fort square. Furthermore, upon a fort flip, all the units inside should be exiled to an adjacent tile, and if no open borders, further exiled according to that rule.

This makes forts very specialized. They need to be close enough to the cities to avoid getting flipped, but in a pinch they can be used to grab resources, especially if you can prevent other civs from creating nearby cities. However, it is dangerous to place forts in areas where cities have already been established, as the fort can flip, and if occupied by enemy units turn against you really quickly.


- Regicide: I heard someone already did this, I love regicide mode and assuming I can make the AI enhancements, would probably make it a part of my mod after giving the AI special procedures for protecting the leader. Might be interesting to make a technology that allows the creation of more leaders (making it harder to knock out a country), or civics that remove leader death penalty (if leader dies the nation still runs as long as it maintains the civic).


- More UN resolutions, better AI for determining votes.


- Open to suggestions. Particularly issues with the AI people want looked into. Of course I will focus on my own mod first, but I may look to make it easily reusable for others, or add suggestions to the end of my own list. I'm mostly interested in major overhauls to AI decision making, and all the other suggestions I've got here relate to certain strategies I'd like the AI to consider (using forts to establish borders, resource specific strategies, more cooperative/coordinated behaviour, maybe diplomat-AIs that try to use the UN for their goals, etc). Please, do not make unit mod suggestions or additional resources, and such that is covered by XML or simpler modifications, unless they relate to more complex suggestions.
 
I just skimmed what you want to do, but from my undestanding some of what you wish could be done witht he python code we have now. As for the rest we will have to wait until the SDK source code is releaced next month.
 
Ya, it looks like that. For some reason I thought the SDK was already out, lol. But I've started breaking down the python source to get started.
 
Very well thought out list. I am particularly interestedin the different methods of war. One other thing that you might add too your list would be to have the AI actualy focus on different types of victory.
 
My AI tries to constantly grow its empire along some point of the spectrum (a sort of empire net worth). The victory conditions are modeled as being very valuable targets so when possible the AI will choose that goal over others. The idea is that the AI will try the victory condition that most makes sense for its empire design.

The first step however is a making a rational AI with my system. If my calculation engine works I drastically cut down decision search time and can hopefully start some learning algorithms (I'm a computer science grad student in AI). I'm hoping then that once victory conditions are added as valuable targets that the AI will pursue them stronger and in more varied ways then the scripted AI (which is great, this is by far the best CIV AI).

My hope is the AI will play more like an actual world leader. They will care about keeping their culture in the game (or not if they are a warmonger, they might have varying motivations), and will be willing to give up a little bit when losing, backstab when it makes sense to backstab, scheme cooperatively (with the player even against other AIs), and so on. I really hate how there are two types of players in the game, AI and player. If you are the player depending on difficulty you have various penalties against you, and to top it off, the AI always gives you a hard case. I'd like to remove that, which might reduce the difficulty at first, but in the longrun will lead to a more challenging AI (as the engine gets tweaked).

The methods of war is just how I normally play my game. Squad management will make the AI armies less messy, and will help with calculating and controlling the cost of military expansion. I don't like seeing the AI having massive collections of units parked over cities that no doubt cost 10-20 gold per turn that could either be cut and spent on economy/trade or utilized on the front. Also squads will hopefully present a new challenge to the player.

While waiting for the SDK I'm already making Python mods to get myself ready (and get some small goals out of the way). Will put them up here as they get done. A website with my full AI design is on the way too.
 
Back
Top Bottom