Wouldn't it make more sense, and be more practical, to use lua events to override the ai?
Yes. The large language models aren't a general form of intelligence. If we were trying to design a computer program that could play as the
player and understand event text, etc, then an LLM would be a useful part of that program, but there would be a lot more to it.
This video talks about how an LLM was given extra tools in order to "understand" and beat Pokemon Blue. In any case, we can't give arbitrary commands to an AI player.
We can use Lua to exercise a lot of influence/control over the AI.
Choosing Production
Using Lua, we can change a city's current production order to whatever we like. Using the
canBuild mechanic, we
should be able to give the AI only one thing to build at a time, so it won't decide to build something else. The hard part is coming up with a way of deciding exactly what should be produced, especially if you want the code to be portable between scenarios.
City Worker Allocation
Lua lets us choose what tiles a city is working using city.workers and city.specialists, but I don't know if/when the AI will revert back to its defaults. This also seems easiest to compensate for with a relatively small amount of "cheating".
Taxes and Research
We can force a tribe to research the "right" thing by changing tribe.researching, if we can't adequately influence it by changing tech.aiValue and tech.modifier. We can't change a tribe's tax rates, but we can give/take gold and science progress if we want.
Settlers
We can use civ.scen.onCanFoundCity to disallow an AI from founding "bad" cities. If we really want to, we can also use civ.createCity (and delete a settler) to found a city if changing tile.fertility doesn't make the AI "want" to found a city. I presume we can give goto orders to settlers (IIRC,
@JPetroski couldn't give Sea Transport role units goto orders, since they immediately try to do something else, but that was fixed by changing their role), as well as giving a settler orders to change terrain. In fact, I believe I could give non-settler units change terrain orders via Lua, and they'd do it. If all else fails, we can spend settler movement allowances and change terrain under them.
Moving Units to Attack
As far as I know, we can't actually force units to attack other units, since the goto order will clear when they're adjacent to an enemy unit. If we want units to attack in groups instead of one by one, we should be able to give them orders to go to a "rally point", and then clear their movement so they can't wander off on their own. Then, when there are "enough" units in the stack, they can proceed.
When working on 1937 with
@techumseh I found out that the AI chooses what unit to move by going through their IDs one by one, and moving each unit in turn. IIRC, the AI only goes through the list twice. In any case, we can't make units move/attack in an arbitrary order, which means the AI's attack will be at a disadvantage, since we can't make it go from best to worst attack.
There is also the issue of deciding where to attack, and how many units should be involved.