Page 2 of 3

Re: More Varied AI Research Paths

Posted: Tue Apr 24, 2018 7:39 am
by harpy eagle
Update (8e80cf5):
  • Added research paths for planetary invasion, planetary defense.
  • Added viper dynamics tech for the Gremak.
  • Increased the amount of emphasis the AI puts on desired tech paths compared to undesired ones.

Re: More Varied AI Research Paths

Posted: Tue Apr 24, 2018 11:52 pm
by harpy eagle
Not directly related to AI research, but the AI now chooses to integrate captured ships into it's navy when it can do so. This should make Xeno-Engineering a little bit more useful for the AI (c005166).

Re: More Varied AI Research Paths

Posted: Thu Apr 26, 2018 1:54 pm
by zolobolo
In the below save, the Phidi AI has concentrated heavily on Torpedoes but did not research Fusion warheads at leas till Turn 300
Since this is their main weapon of choice, it reduces their combat effectiveness considerably

Is this an issue in the research path logic?

Save: https://www.dropbox.com/s/fbcglyngz7gcy ... g.rar?dl=0

Re: More Varied AI Research Paths

Posted: Thu Apr 26, 2018 6:32 pm
by harpy eagle
zolobolo wrote:In the below save, the Phidi AI has concentrated heavily on Torpedoes but did not research Fusion warheads at leas till Turn 300
Since this is their main weapon of choice, it reduces their combat effectiveness considerably

Is this an issue in the research path logic?

Save: https://www.dropbox.com/s/fbcglyngz7gcy ... g.rar?dl=0
I gotta look at the save, but there's a number of possibilities.

1. Since research focus and navy compositions decisions are entirely decoupled from each other, it's possible that Torpedoes isn't even an important a research focus for them. But once they researched it, the navy composition logic decided it wanted a lot of torpedo destroyers.

Sven had a lot of good ideas about how to deal with this. At first I thought it wasn't really a big deal but maybe he was right...

2. Since research focus is completely random, it's possible the AI is spreading out it's research too thinly. I had some ideas about using the current research desire values to just sort the different research paths, and then enforce a particular distribution.

If I do this, the "spacing" between research paths in the distribution probably should not be uniform. I'm thinking for each path I should choose a tech that represents the minimum amount of effort you want to really put into the path, should you go for it. Then the amount of beakers needed to get to that tech would determine the spacing.

So for example, lets say there's a research path whose "minimum effort" tech is expensive. If this path is strongly desired, then the AI will really put a disproportionate amount of research into it. Conversely if that path is undesired, then the AI will ignore the path to an even greater extent than it would otherwise.

3. It's possible that the spread of research paths isn't too bad, but the AI empire's research rate is so slow that it can't get very far with anything. Not sure if this is something worth worrying about, or if so, what to do about it.

Re: More Varied AI Research Paths

Posted: Thu Apr 26, 2018 6:55 pm
by zolobolo
They have a bunch of research :) they are the second most powerful empire on the map at Turn 300

So in theory, the AI should already choose some research lines and stick with them the only limitation should be research capacity right?
They would only need 6 Turn to research Fusion warheads at this point and are currently researching 3rd level or armor instead which will take 26 Turns

Re: More Varied AI Research Paths

Posted: Thu Apr 26, 2018 7:24 pm
by harpy eagle
zolobolo wrote:They have a bunch of research :) they are the second most powerful empire on the map at Turn 300

So in theory, the AI should already choose some research lines and stick with them the only limitation should be research capacity right?
They would only need 6 Turn to research Fusion warheads at this point and are currently researching 3rd level or armor instead which will take 26 Turns
As you can see the Phidi are far more interested in armor than they are torpedoes (i.e. "heavy_missiles").

Image

Re: More Varied AI Research Paths

Posted: Thu Apr 26, 2018 7:39 pm
by harpy eagle
harpy eagle wrote:As you can see the Phidi are far more interested in armor than they are torpedoes (i.e. "heavy_missiles").
So, I guess the real problem here is that they researched torpedoes at all? If it isn't huge priority for them it means less beakers for the things they do desire. Though I suppose if they are researching tier 3 armour getting heavy missiles wasn't a huge research detour.

Re: More Varied AI Research Paths

Posted: Thu Apr 26, 2018 7:48 pm
by zolobolo
harpy eagle wrote: So, I guess the real problem here is that they researched torpedoes at all?
That is fine... you need some variation within the same empire a well...

The issue rather seems to be that there is no "primary" weapon in the top 5 priorities
Can you alter the logic in way that at least one such weapon (heavy_laser, torpedo, ion or kinetics) is always in the top 5? This is to make sure that they will always have something modern to mount on Heavy hardpoints

Re: More Varied AI Research Paths

Posted: Thu Apr 26, 2018 8:45 pm
by harpy eagle
zolobolo wrote:
harpy eagle wrote: So, I guess the real problem here is that they researched torpedoes at all?
That is fine... you need some variation within the same empire a well...

The issue rather seems to be that there is no "primary" weapon in the top 5 priorities
Can you alter the logic in way that at least one such weapon (heavy_laser, torpedo, ion or kinetics) is always in the top 5? This is to make sure that they will always have something modern to mount on Heavy hardpoints
I could do something like that. Though the AI doesn't use heavy weapons at the moment, even if it researches them and has designs that have heavy hardpoints.

This is because the AI always uses 'balanced' autogeneration, which usually puts medium weapons into heavy hardpoints. It's a valid option, since I believe you get twice the shots so putting a medium weapon there actually often provides a higher damage output, with less range of course.

I'd like to find a way to get the AI to build a mix of 'balanced' and 'siege' autodesign configurations. But while using a mix of 'balanced' and 'escort' configuration for things like escort crusiers.

Re: More Varied AI Research Paths

Posted: Fri Apr 27, 2018 5:31 am
by harpy eagle
Research path tweaks (fece529):
  • Split the research path for carriers into one path for carriers and another for bombers (carrier+warhead techs). This way, like lasers and heavy lasers, if the AI decides to research carriers it may also research bomber tech (i.e warheads) as well, but is not forced to.
  • Rapid Fire Lasers is now considered a core laser tech. It doubles your damage output, so it's pretty essential if you want lasers.

Re: More Varied AI Research Paths

Posted: Fri Apr 27, 2018 9:19 am
by zolobolo
Did you take into account that the AI might buy tech otherwise not available from the Herald?
I would test this, but the Herald does not show any willingness to crop up in the last two games

Re: More Varied AI Research Paths

Posted: Fri Apr 27, 2018 8:05 pm
by harpy eagle
zolobolo wrote:Did you take into account that the AI might buy tech otherwise not available from the Herald?
I would test this, but the Herald does not show any willingness to crop up in the last two games
No, but I don't think it should be hard. I'll have to take a look at what techs the AI can buy from the herald.

In the meantime, I've made some significant improvements to how the AI chooses to spread it's science income into different research paths.

I think these improvements will allow the AI to more clearly express it's strongest research desires, as well as help the AI make better choices by taking into account research paths that may have many techs in common.

The AI no longer randomly distributes it's science income. While the AI's research desires are still randomized, this randomization is only used to rank the different possible research paths from most desired to least desired.

Once it has this ranking, the actual spread is determined by how much commitment each research path demands, as well as which techs the path shares with any of the paths above it in the ranking.

Re: More Varied AI Research Paths

Posted: Fri Apr 27, 2018 9:09 pm
by sven
harpy eagle wrote: In the meantime, I've made some significant improvements to how the AI chooses to spread it's science income into different research paths.
Looking over your diff set now... line 8 of choose_research.lua should probably use a weak_memoizeNN, rather than strong_memoizeNN. The empire data behind a given empire reference can change after a new game is loaded, so using a strong cache here isn't save. (The herald, or other in-game events can also change the return value of candidate_tech_sets by unlocking certain techs that used to be hidden for a given player, so technically, even without the game load issue, a weak_memoize is probably the right way to go here).

edit: Ditto for mem_research_cost.

Re: More Varied AI Research Paths

Posted: Fri Apr 27, 2018 9:47 pm
by harpy eagle
sven wrote:Looking over your diff set now... line 8 of choose_research.lua should probably use a weak_memoizeNN, rather than strong_memoizeNN. The empire data behind a given empire reference can change after a new game is loaded, so using a strong cache here isn't save. (The herald, or other in-game events can also change the return value of candidate_tech_sets by unlocking certain techs that used to be hidden for a given player, so technically, even without the game load issue, a weak_memoize is probably the right way to go here).

edit: Ditto for mem_research_cost.
Hmm. I was hoping that by using AIContext in that file that using strong memoization would be okay. But I guess it's probably better just to stick with weak memoization then.

But yeah, the intent was only to memorize those just for that turn, since like you said the results depend on the state inside empire.tech.

Edit: now updated (e7c41a4).

Re: More Varied AI Research Paths

Posted: Fri Apr 27, 2018 9:54 pm
by sven
harpy eagle wrote: Hmm. I was hoping that by using AIContext in that file that using strong memoization would be okay. But I guess it's probably better just to stick with weak memoization then.
If you're going to use strong memoization pattern to create temporaries for an ai_context call, you need to put the actual function definition inside the execution chunk of the ai callback. (Tricks like the one in init_production_desire.ships() rely on the fact that _ENV behaves differently when an ai_context call is executing than then it does during file-load.) In this case, you could just move the helper function definitions down so that they appear at the top of function_choose_next_research(). (Also, because they're locals, if you restructured the code like that, you wouldn't even need to rely on ai_context magic -- the fact that the definitions left scope with the end of the function call would be sufficient to flush them.)