Replies: 1 comment
-
Seems you got this figured out more or less. I've been looking for AI mechanics, some of it can be found on civfanatics, e.g. here, stuff from that thread that could be useful:
As for mechanics of player's reputation, how it deteriorates, how it can be increased and what it actually affects AI-wise can be found here. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Here's some note for my thoughts on the AI implementation, I think this is technically feasible any comments would be appreciated
AI script should run after others but before first turn.
Player 0 will use barbarians.lua
Other players can be set or will use default AI script default_ai.lua
Executed in a special context the ai object will be specially bound and unique for that ai
Within this file you can access any of the standard lua functions. The game has not started at this point but initial setup is otherwise complete.
The file should register for the events this ai is interested in any event not registered will be ignored and result in no action, the exception is events that require a response such as audience requested if the ai doesn't handle these they will be answered with a negative. The barbarian ai is an example of ignoring these events... if you ignore diplomacy events you will end up at war with everyone.
Events:
Init - called shortly after this script if load game this is supplied with any ai state data that this script store on save.
Save - called when the user triggers a save the return of this method is treated as a binary blob in the save file and returned if the game is loaded via init
Turn - called at the beginning of each turn after city production you can decide ai strategy and issue orders to units here,
Units Orders Needed - called once for each unit that still needs orders if no orders are issued to the unit it will do nothing this turn
Foreign Unit Encountered - called when a foreign unit moves into visual range, can be a good place to initiate diplomacy especially if you encounter a unit from a new player or a player you've not seen in a while. This event is issued first to the player or players who's units did not move and then to the moving player
City Event X
A set of events fired in the preflight process of the turn if certain issues happen gives the AI a chance to handle these
End Of Turn - called after all other events just before turn passes to the next player, good place to check production orders etc..
Beta Was this translation helpful? Give feedback.
All reactions