Some ideas for the future...

We could also start doing doxygen comments in front of functions

I recommend doxygen comments. They're where the comments are needed, and in my experience they have been better than external documents from both writing and reading points of view.
 
When tech trading is not available, I don't think the AI would benefit much from a more random research choice. If beelining Bronze Working is the best opening option, it should go do that.
I do not agree entirely with this, given that, unless you are also playing with the no Espionage option on, you can steal techs... obviously , you gain zero in teching what everyone is teching if you want to steal techs. Not that the current AI will steal techs with something that resembles a coherent plan ;) , but that is a concern for other thread :p But I agree with the general thought: as less possibilities you have of accessing other players technologies, more self centered should be your research.
 
While you're rewriting the tech valuation function, perhaps you could allow weaker nations to band together to share techs in order to catch up? I know tech diffusion helps somewhat, but that's a more passive stance. Weaker nations should be encouraged to share technologies with each other and not the stronger players.
 
I know the AI takes into account the value of a technology for permitting exploiting of a resource, but does the AI actually take into account whether it has any of it? In other words, if the AI has no happiness resources requiring Plantations in its borders, it probably shouldn't consider Calendar a big priority. But if it does, it should consider it more important. Particularly if it has many unhappy cities (which I think it doesn't take into consideration).

Similarly, Horseback Riding should get a lower priority if you have no supply of Horses to make Horse Archers.
 
I know the AI takes into account the value of a technology for permitting exploiting of a resource, but does the AI actually take into account whether it has any of it? In other words, if the AI has no happiness resources requiring Plantations in its borders, it probably shouldn't consider Calendar a big priority. But if it does, it should consider it more important. Particularly if it has many unhappy cities (which I think it doesn't take into consideration).

Similarly, Horseback Riding should get a lower priority if you have no supply of Horses to make Horse Archers.
And you need to factor in "can I see the resource yet". Iron Working is key even if you don't have any iron (for obvious reasons).
 
And you need to factor in "can I see the resource yet". Iron Working is key even if you don't have any iron (for obvious reasons).

I think it already takes into account if a tech reveals a resource. But if you mean to make sure that it doesn't undervalue a tech because there's no visible supply of a resource in their borders, then you're absolutely right. You don't want to inadvertently reduce the value of techs that reveal the particular resource.

Also, I was thinking that most of these things are only really relevant to the early game, and the early game is when processing time tends to be less precious. So for the sake of performance, it might be good to pick certain checks that might only be performed in the early game when tech research order is much more crucial. Then you could have the AI be much more thorough in its tech decision-making in the early game without sacrificing processing time in the later game.

I would recommend adding some kind of era limit for the most hoggish loops, and then make the era limit moddable in the XML so other people can change it if they want the AI to continue calculating those lesser values for a larger portion of the game.
 
I agree that elements like going for the 'going for a technology that no-one has' should be dependent on the condition that tech trading or brokering is enabled. So the extra value given to a technology because no-one has researched it yet should be dependent on the condition that tech trading or brokering is enabled.

However, there is still lots of value in being unpredictable in your technology path even when tech trading is disabled. For instance, if a player would know that the AI would value two non-military technologies higher than feudalism (even when at war), then the player could declare war on the AI knowing that the defenders won't quickly transform into longbowmen shortly after the war has started. And if a player knows exactly the path that the AI takes to technologies like liberalism and other technologies that give direct benefits like free Great Persons, then the player can plan his research to be just a little faster to these one-time bonus technologies. It's extremely beneficial for the player to know the AI technology path whether technology trading is enabled or not.

That being said, I think that the odds to choose the best option shouldn't be too random.

Instead, I intend to switch to a model where a non-random value is computed for each tech and these values are then used as weightings to pick a tech randomly. In essence, if there are three possible techs with weightings A, B, and C, then the AI would pick the first tech with probability A / (A + B + C).

There are of course many ways to very this ... only consider techs which are at least 1/X as valued as the most valued, subtract 1/X of the highest value from each value before doing the weightings, etc. The exact formula will need to be setup to get the right balance between going for higher value techs and being non-predictable, but I think this randomness model will produce results that are easier to understand and tweak.

I like this basic setup and I would to suggest a modification to the basic A / (A + B + C) that you suggested. It will make the AI behaviour unpredictable, but a bit too unpredictable. You already suggested yourself that some modification to this basic idea might be a good idea.

For instance, take a hypothetical situation where the AI can choose between 8 technologies, 1 technology with value 3 and 7 with value 1. Then the odds to choose the one which is clearly the best, 3 times as good as all of the others is only 30%. Those odds to choose the best option are a bit too low in my opinion. However, I still want to keep the ability for the AI to choose one of the 7 lesser options. These unpredictable less optimal routes need to be taken sometimes so that the AI tech path doesn't become too predictable and exploitable.

I suggest taking the third power of the value before using the same weighting mechanism. So, the weights become 3^3=27, 1^3, 1^3,1^3, 1^3,1^3, 1^3 and 1^3 and the odds to pick the best option are 27/34 = 79.5% while each of the less optimal options have odds 2.9% to be picked.

I also think that the AI should sometimes shut down the randomisation of picking a technology. For instance, when at war and the value of a military technology is considered higher than all other options, then the AI should just pick that technology. We could discuss in which situations, the AI should just pick the best option. War is a good reason in my opinion, but maybe getting first to some technology that gives a bonus to the one that gets there first could also be a good reason. In some cases, being predictable is worth it.

Also, the valuations will definitely consider both the benefit and the cost of the tech, Firaxis has this in their mechanism already. Good of you to make sure this is in there Roland!

Good to hear that. I of course didn't expect this to be overlooked.


Could the AI also be thought to look a bit ahead in the tech tree? For instance, when researching technology A would open up the research of technologies B and C, we could add 20% of the value of these 2 technologies to the value of technology A. In that way, when for instance Liberalism is valued highly (which it is by some human players), then being 1 tech away from it will increase the value of the technology that allows the research of Liberalism with 20% of the value of the Liberalism technology.
 
You might as well just factor that into how we calculate tech values.

Ie, instead of saying value 3, the value of that tech is 27.
 
You might as well just factor that into how we calculate tech values.

Ie, instead of saying value 3, the value of that tech is 27.

People instinctively think linearly, but these linear values aren't used when making the choice.

For instance: technology A gives the first civilisation who invents it a single great scientist, technology B gives the first civilisation who invents it 2 great scientists. No other differences exist between these 2 technologies. Most players will say that technology B is twice as good, twice as valuable as technology A. I would also expect jdog to implement a valuation algorithm of technologies that gives technology B twice as high a value as technology A.

But most players will also say that you should always pick technology B (when you have no other knowledge of other civilisations researching one of them). So a valuation algorithm should clearly favour B more than 2 to 1 over A. In my adjustment it would become 8 to 1, the odds would increase from 2/3 = 66.7% to 8/9 = 88.9%.

The AI however shouldn't always pick technology B. If the AI would do that, then it could easily result in a situation where the human player can safely pick technology A in a tight technology race for A or B as the player would know that all the AI's were going for B.

It of course doesn't matter a lot where in the algorithm, you implement my suggested third power formula. It doesn't really matter whether you name the original valuation the value of a technology or the third power of it the value of a technology. That's just a name and doesn't effect the decision making process of the AI.

Taking the third power of the valuations has the biggest effect in cases like my example in the previous post: lots of technologies to choose between with one or two having a much better value. In those cases, the original valuation will make the AI's behaviour very random with little regard for the best technologies.

(Of course other information can affect the choice to go for technology A or B like extra knowledge about research speed and position of the opponents in the technology tree. I was just using a basic situation where every civilisation could only choose between A and B to simplify things a bit and get a basic feeling for how a valuation algorithm could work.)
 
The AI however shouldn't always pick technology B. If the AI would do that, then it could easily result in a situation where the human player can safely pick technology A in a tight technology race for A or B as the player would know that all the AI's were going for B.

Maybe this is obvious, but shouldn't this be where espionage plays a role (Assuming it's enabled, of course.) I use passive espionage all the time to see what my allies and enemies are researching, and choose paths accordingly. The AI should do that too. If it's best friends already have Tech A covered, and will get it in a reasonable amount of time, the AI should know to go for tech B or C, and trade it to the other AI for tech A, getting an advantage.
 
Maybe this is obvious, but shouldn't this be where espionage plays a role (Assuming it's enabled, of course.) I use passive espionage all the time to see what my allies and enemies are researching, and choose paths accordingly. The AI should do that too. If it's best friends already have Tech A covered, and will get it in a reasonable amount of time, the AI should know to go for tech B or C, and trade it to the other AI for tech A, getting an advantage.

Of course, espionage can help make technology choices easier. By the way, it's unlikely that everyone can see everyone else's research plans because the cost of seeing the others technology is related to their investment in espionage. So if someone makes a serious investment in espionage, then others aren't likely to see the research plans of this player.

But even espionage cannot tell you what the AI's next choice will be, so it's still important that that next choice isn't too predictable. If everyone is a few techs away from certain one-time bonus technologies, then it is still very valuable to know what research choices the AI will make on the way to these one-time bonus technologies in order to plan your own choices. Espionage can't help you predict these future choices, so it's important that the AI isn't too predictable.
 
If the tech valuation function becomes more sophisticated, then it may well be unpredictable without being random. For example, suppose that Feudalism is valued more highly for civs with many archers. Since a human player will not know precisely how many archers each opposing civ has, the human will not know which will research Feudalism, if any.
 
If the tech valuation function becomes more sophisticated, then it may well be unpredictable without being random. For example, suppose that Feudalism is valued more highly for civs with many archers. Since a human player will not know precisely how many archers each opposing civ has, the human will not know which will research Feudalism, if any.
I agree completely with this. If the AI takes more of its current circumstances into account, it will make the AI sufficiently unpredictable while still having them do what's in their best interests.
 
One of the things I was noticing as I looked at the code this morning is that the AI doesn't seem to take into consideration the deals it currently has with a player it's thinking about going to war with. This means that the AI could very well hurt itself by declaring war on someone they're getting a useful resource or gold per turn from instead of someone who might be a somewhat less desirable war target for some other reason, but who they have no trade deal with. I mean, generally the AI is going to have the most on-going deals with the people they like the best anyway, but this is not always the case. It seems like some kind of evaluation of existing trade deals would be good. Of course, it should not make a huge difference, but it should be a factor I think.
 
If the tech valuation function becomes more sophisticated, then it may well be unpredictable without being random. For example, suppose that Feudalism is valued more highly for civs with many archers. Since a human player will not know precisely how many archers each opposing civ has, the human will not know which will research Feudalism, if any.

While this may work with some evaluations, the archer example is a bad one. The AI will always build a large number of archers. So the various AI's will value feudalism similar in various games. But with some other significantly complicated elements, there could be some unpredictability. But with the present evaluation, the AI is far too predictable which is hurting them in competition with the human player and making their gameplay worse.
 
Back
Top Bottom