I just looked at what the normal AI (without Better AI) does. On noble it tends to build a warrior and then a worker; on emperor (which is what I usually play on) it tends to go straight for the worker. Unfortunately for it, it does so even if the worker will have nothing to do — just like when I forced Better AI to do it. Strangely enough, in the map I've been using as a primary test neither Better AI or normal AI builds a worker first in the city that I think would benefit the most from it. Silly old Mansa Musa is too keen to build a skirmisher and thus squanders a massive early game advantage. (I've attached the file for anyone or is interested.)
Yakk, I like that sound of your suggestion. That would be much better than hard-coding a strategy in — which is effectively what I was talking about testing (force it to build a worker first, then force it to research a tech to help that worker).
In economics, people sometimes talk about a 'discount rate' — which describes an exponential decay of value over time, because "things in the future are worth less than things now." I think it would be a good idea to use that kind of reasoning all through the AI, and different AIs could even use different discount rates if they wanted to... but I'm not sure it would work if it only affected a special few decisions rather than all of them.
But I'm not entirely sure how to approach the coding of it. I'm pretty new to this whole modding business, so I'm not very familiar with most of the code. My impression so far is that the AI's choice of research, and city production, and what their units are doing, are all independent of one another. Your suggestion seems to rely on a more coherent decision making process. I'm still browsing through the code to see how things are done to see where it is best to change it... My thinking so far is that AI should highly value techs which would allow it get to food improvements if it doesn't already have plenty of food; and that it needs to take the outer part of the fat-cross into account for any city that has positive culture-per-turn, and also take into account the improvement options that will open up when the current tech has finished researching... Having written all of that, it's just pretty much what you said. I guess I'm not making any progress yet.
Maybe I'll try something different before tackling all of this. I could just tweak some stuff to make it more likely to build workers in general, and less likely to build a settler before a worker (which I think is almost aways a mistake.) It would be good to get the first few AI decisions to be perfect, but I think the AI's problems are much more broad than that anyway, so I'm going to look for some other stuff to improve while I learn more about the code and think about how to implement what we've talked about.
Are you using Better AI in your mod, or just plain Better AI?
It's my own mod, but it is a very minimalist mod; almost nothing has been changed. I've just tweaked how maintenance is calculated and made some minor changes to a couple of civics.
[edit]
There is already a way for AIs to choose a worker based on what they are currently researching... I wonder why it doesn't happen as often as I expect.
[edit again]
Combinations of factors can conspire to make the AI play poorly... for example, in the game I posted, the Germans get off to a really slow start. They _should_ start by researching animal husbandry and building a worker... but they choose fishing because they have more seafood nearby than land food. They then don't consider building a worker because they won't be able to improve the pig yet, so they choose a settler for lack of something more appealing. The settler takes a long time to build... when it is finally done, they already have animal husbandry but they decide to start building a workboat before a worker. The workboat is also painfully slow to build. Later, when they have settled their second city, they really need to research mysticism so that they can pop their borders to get the rice, but they don't think of that. They research all sorts of order junk first while their second city does basically nothing.
From my point of view, the key issue that caused the Germans to have a really slow start was that they started building a settler without good reason, and then felt obligated to finish building it before starting something more useful. The production of the settler is far too slow in this case to be worth while. Ideally they would have realised that researching animal husbandry first would give their city something useful to do (ie. build a worker), whereas fishing just makes their city waste time waiting for the research to finish. The AI is apparently capable of choosing to build a worker as a result of the research it has chosen, but what it needs this time is the other way around: choosing to research animal husbandry to suit the worker it is (should be) building!
But even after that initial mistake with the choice of fishing, they should realise that they need to interrupt their settler to build a workboat or two, so that they have 2 citizens working 2 high-food tiles instead of 1 citizen working 1 low food tile.
The mysticism thing is a separate issue.
To fix this stuff, I think the tech evaluation system needs to be changed. Having more seafood around the city doesn't mean fishing is better, because it takes a long time to build all the workboats to get the seafood, and you probably don't need all that food at once anyway. Initially, the city is only at size 1. So it only really needs 1 good tile to work until it grows, and the pig would be the best tile. So instead of just counting all the improvements it could make with a tech, the AI should only consider the improvements that it will actually be able to use in the near future — and getting one good tile early should be worth more than getting a few good tiles later.
Let me know if you have any thoughts about what I've said or any ideas for implementing this stuff. Like I said, I'm still a bit of a newbie when it comes to editing the code, so I'm still not confident enough to really start ripping up old code on my own.