Creating a dynamic research pathern. |
Right now, i'm working on making my AI research things in a less predictible manner. Right now it just pick things on a list in a sequential order wich means that all AI gets the same things (at least until racial techs start to be researched). My new AI does quite well in all area (it does expend and build stuff quite well) but it's research pathern is lame. I could take hours to make a very elaborate research queue but i would prefer to let the AI choose what it need and pick appropriate tech to level up. I also don't like it to queue up 5-10 level at once as it waste a reseach slot for a long time and the other research fields are left destitute.
I tryied to use the random function, but the random function run each turns and when the roll fail, the item currently researched disapear and research points are wasted. Worst the AI don't fill the free slot so the AI stop researching (though there might be a work around)...
Bah, i'll try something else later today, for now i need some sleep...

Use the AI state to prioritize research
What you might want to do is use the AI's current state (explore, infrastructure, attack, defend, etc) to push certain techs ahead of others using conditional statements.
I plan to this in two ways for the Balance Mod AI. The first will be set percentages for each research type (theoretical, weapons, applied, custom ones etc.) and the second way is in the research script itself to push "needed" techs based on the current state.
-----

Grr...
I forgot to escape my greater signs, so I lost most of the rest of that post... crap...
Just in case you didn't know, there is a file in the SE5/Docs folder that explains most of the basic scripting. Even if you know about it I can understand how long getting a hold of the calls can be. I know I still haven't gotten many down...
I'm tired and running low on waking moments, so if you want, I could take some time to explain how to do what I proposed. It'll make more sense than my first ramblings, too. I'll probably think about the best way to do it during school, so I'll have a smoother way of doing it by tomorrow. Or I'll just make a giant topic in the mods forum about dynamic research, and give an example script.
-----
Watch for my mod - codename: Dimensions - coming by Summer, 2007!

Setting up research priorities...
It's not too hard.
First thing is you'll want to organize the techs in the research script individually or for stock-type level amounts, perhaps in jumps of 2 or 3 levels at a time. I sorted further into the groups that matched the different tech groups.
In the empire's main script file, there is a function "Set_Race_Research_Spending". Essentially create a case structure for the AI's state like this example:
set ai_state := Sys_Get_AI_State(sys_long_Player_ID)
case (ai_state)
AI_STATE_EXPLORE_AND_EXPAND:
call lst_Research_Spending_Group_Name.add("Cultural Advancement")
call lst_Research_Spending_For_Group.add(2)
call lst_Research_Spending_Group_Name.add("Theoretical Science")
call lst_Research_Spending_For_Group.add(20)
call lst_Research_Spending_Group_Name.add("Applied Science")
call lst_Research_Spending_For_Group.add(48)
call lst_Research_Spending_Group_Name.add("Weapon Technology")
call lst_Research_Spending_For_Group.add(30)
AI_STATE_INFRASTRUCTURE:
blah blah
AI_STATE_ATTACK:
blah blah
AI_STATE_DEFEND:
blah blah
AI_STATE_NOT_CONNECTED:
blah blah
endcase
-----




.
I've had the same idea
Research was the first section I attempted to do in my AI. Unfortunately, I realized that there was a huge amount of work to be done in this regard. I suggest you manually setup a list of the various technologies (a longlist of IDs) and a list of the type of research (longlist of constants you define elsewhere). Put all techs in this list, and later you can pick and choose which ones to exlcude to make more unique AIs.
When the AI gets around to choosing its research, make a longlist of weighting of the various kinds of technologies. If it's in a war, boost up the weighting on battle technologies. If its production is lagging behind, increase the facility research. Pick a random type from this list, and then choose a random technology of that type.
I suggest using something like this (in psuedo code):
goodtech = false
tries = 0
while (not goodtech) and (tries