Author Topic: Ai Tech Research Ideas  (Read 2036 times)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Ai Tech Research Ideas
« on: July 19, 2008, 07:35:01 AM »
I sort of had ideas for writing some library functions to help with research. (Not plans, just ideas. Maybe some other time, or by someone else). Something along the lines of specifying a target research, and it would return a list of possible next researches that will lead towards that one. That way you don't have to specify every research in some kind of ordered list. You'd just specify certain key targets, and it would work it's way there. I was thinking you could parse the in memory structures containing the research tree. That way the functions would still work with custom tech trees.

There were a number of boolean checks that I could think of being needed for this sort of thing. These could be used as some sort of filter when traversing the structs to pull out the interesting techs. Stuff like:
 - HasTech<player>
 - NotYetResearched<player>,
 - HasAllPrerequisites<player>,
 - ImmediatelyResearchable<player> = (NotYetResearched AND HasAllPrerequisites),
 - FromCategory<category>,
 - FromLab<labType>
 - IsTech<techID>
 - IsAvailable<colonyType>  (Eden/Plymouth)

There was also a number of ways of traversing the tech structs. You could just iterate over all of them, or you could start at some target tech, and check backwards recursively through the REQUIRES field. Note that this second method could potentially check the same tech twice. You'd probably want to keep a list of what ones have been checked so far in the traversal. Either way of traversing the list could then apply the above filters to narrow down the list of techs. Although, there are some efficiency gains if some filters are use in a special way for the recursive traversal. In particular, if you wanted to know what to research next to get to some goal, you'd only need to check back until a player has the tech. Thus HasTech could be used as a traversal termination condition, so it doesn't keep checking back through prerequisite techs that the player has already researched. A search like this could take two lists of filters. One list is used just simply as filters, like would be the case when all techs are being iterated over. Another list could be used as termination conditions. When such a tech is encounted, that branch of the traversal is terminated.


It would also be useful to split lists. Say, get a list of topic to research next to make it to some goal, and then after the list is produced, split it into lists of topics at the advanced lab, standard lab, and basic lab.


If you wanted to make the problem more complex, you could even try to schedule research so as to keep labs "producing" at maximum efficiency. Suppose you can research two topics at a certain time, say both at a standard lab, one of which opens up a new research topic in the standard lab, and the other opens up two new research topics, one in the standard lab, and one in the advanced lab. Then by researching the second topic first, you have greater potential for parallel research, which can reduce the overall time to reach a target goal.

To do that, you'd probably also need functions to calculate, or at least estimate research times. Keep in mind that some techs have different costs for Eden or Plymouth, and that would need to be taken into consideration. It would also depend on the number of available scientists, and the number of labs of each type. (Don't forget the list of techs either, which it obviously depends on, as well as the order in which they're researched). You might even consider the cost of moving scientists around between active research topics.


Taking things even further, you might also consider scanning the upgrade tags to base the value of a tech on. It's quite possible things like the category tag will lie. Or it's even quite possible that a tech tree will contain a bad tech, that the player knows not the research, but the computer may go blindly researching trying to finish off the tech tree. It's even more interesting if other techs depend on that tech, or if it's one whose timing determines it's usefulness, such as one that increases one value, while decreasing another. An example would be the Jihad tech in Age of Empires. It increases the attack skill of your peasants, but it reduces their ability to collect resources. After you're done harvesting all the resources on the map, you can research this and put your peasants to use one final time up against your enemies fortifications.  ;)


There's one slight limitation to all this thinking though. You have no way of anticipating custom tech affects, such as the results of a Research Trigger callback. Even things like enabling buildings, or vehicle construction are stored seperate from the tech info, and would require scanning the unit type info. At least the later case is still doable, if somewhat inconvenient. But, it's an example of the more general problem of not all tech effects being described by properties/tags of the tech. You have to know beforehand to look in these places and consider their effects, rather than simply examine the tech structures.