Version 0.60 Discussion Thread

PieceOfMind said:
If the result of the AI picking techs one at a time is that if often doesn't see a really great tech 2 techs away because it's blocked by a poorer tech, then it'd be a problem.

I reckon averaging the value of two or three techs ahead could be worth it (or some more appropirate way to weight them). This would require the AI to be able to value techs that it cannot currently research though. Beelining too far down the tree is probably not a good idea by the way, especially if it is not flexible to shift strategy along the way.
Dom Pedro II said:
But I don't think all hope is lost though... I think that one of the major faults of the AI is that it doesn't retain any knowledge from game to game. Having played over and over again, we develop a list of techs that we think are particularly useful and become "must-have" techs.

It would make sense to me to have the AI compile at the outset of each game a list of must-have techs (let's say 5) based on that AI's particular strategy. Then it would be a lot easier for the AI to cycle through that short list of techs and work its way backward to a preferable path to that tech than to start from where the AI is now and work forward with an increasingly wider set of branches on the tech tree. We could also make it so that the AI would periodically reevaluate the top-five techs it wants cycling out already researched ones, or ones that have dropped in value from a shift in strategy.

This reminds me of the problem of writing AI for FPS games. Pathways for the AI have to be seeded so it: 1. knows where key points on the map are, & 2. the best way to travel between them. Totally analogous to the AI pursuing a tech tree strategy in Civ, I think. Except the 'map' would be the specific set of techs the particular civ should strategize for it's particular situation. And of course, don't have computing power to do a Deep Blue intensive search.

I think in interest of speed though, it'd be better to pre-compile lists of techs for specific 'modes', with the modes being mid-term goals---e.g. Happiness, War, Culture, Health, Gold, Research, Sea power, and DiploVictory---to suggest a modest list.
A quick situational estimation would determine which mode would best suit the AI for a couple of turns (e.g. next 10 turns). The mode would determine the list, and the list would have appropriate target techs listed, queued for the more immediate paying techs (quickest to research). The AI would then still do a 1-tech depth, 'next tech to research' decision, but if those techs were pre-reqs for tech on the mode list, then they would have extra weight in the 'next tech' decision process. It'd even be possible for the AI to pursue a 'shades of grey' approach, with it deciding it was fractionally in multiple modes (e.g. say fractionally both in Culture and War mode) so that the final weights used in the 'next tech' decisioning could be complex (but it'd still be a quick system ;) ).

The main tweaking would be: how does the AI efficiently determine what its mode is, and are the techs listed in the mode list in the most optimal/expert fashion?

And with complex mode tallying (e.g. where the AI says its .40 in one mode, .20 in another mode, .30 in another mode, and .10 in a final mode) the weighting of target techs could be dynamic---turn to turn if there were system resources---since it would use fractional weights which respond to subtle situational changes. Though there might be an issue of getting stuck in an oscillation between two specific tech choices, turn to turn, I guess.
 
I have been using beeline paths with Rands to force individual leaders, civs, and everyone to go after techs that just make sense. The Rands allow the Tech system to run occasionally, and give variation in strategy.

The techs are nested in a way to allow different strategies, and go after techs further down the tree that they should/can/would beeline as a human player.

It's been brilliant, at least when my code is running. When the AI has to decide again, it's really spotty.

Like getting horseback riding with no horses available, and other crap.
 
Though there might be an issue of getting stuck in an oscillation between two specific tech choices, turn to turn, I guess.

Couldn't that be fairly easily countered by a simple bias given to the tech being researched currently? If there was such a bias, then switching techs mid-research would be a big change and the reason to do so (ie. the weights) would be big enough to ensure there is not switching back on the next turn). That would be unless there was some empire-wide situation causing the oscillation - maybe a barb galley that blockades your one seafood resource every second turn... I think you'd just need to be careful to make the influencing factors not too sensitive to things that can change rapidly from turn to turn.
 
Many of these ideas are specific to the core civilization game and too inflexible to be transferred to mods. The ideas are using the technologies as they are in the core civilization game. I would prefer a system based on the elements that are gained by the technologies (as it is now, for example ability to build unit/building/wonder, + 1 trade route, great person, free technology, etc.) and that might look ahead one technology in the technology tree. The value of the elements gained by a technology of course depends on the empire wide situation.

By the way, the less efficient research choices hinder the AI far less than its limitations in correctly improving specialised cities and its limitations in war situations where it cannot estimate correctly whether an attack with a stack of units is a good choice and whether its defencive and offencive units are 'good enough'.
 
By the way, the less efficient research choices hinder the AI far less than its limitations in correctly improving specialised cities and its limitations in war situations where it cannot estimate correctly whether an attack with a stack of units is a good choice and whether its defencive and offencive units are 'good enough'.

I agree. But what about the huge benefit to the human player who understands the AIs will typically go for the same bunches of techs every game? I like to think of Better AI as not just improving the AI directly but also changing the AI to be less exploitable by crafty human players. Perhaps you could even encourage the AIs to research techs that have not yet been researched. As far as I know they do not yet do this except for techs that grant once-off bonuses to the first person to research it (eg. CoL). If good human players pick techs that will be traded to most or all of the AIs, good AIs should probably also put greater value on techs that are undiscovered so it can trade itself up the tech tree. This would of course be very mod independent.
 
I agree. But what about the huge benefit to the human player who understands the AIs will typically go for the same bunches of techs every game? I like to think of Better AI as not just improving the AI directly but also changing the AI to be less exploitable by crafty human players. Perhaps you could even encourage the AIs to research techs that have not yet been researched. As far as I know they do not yet do this except for techs that grant once-off bonuses to the first person to research it (eg. CoL). If good human players pick techs that will be traded to most or all of the AIs, good AIs should probably also put greater value on techs that are undiscovered so it can trade itself up the tech tree. This would of course be very mod independent.

I mentioned the researching unknown technologies earlier in this thread. I thought to have read that the AI already does this, but maybe not enough. Of course, it is only interesting in games that allow tech trading. In non-tech trading games it should not be a factor.

A bit more randomness in the AI tech priorities might also be valuable, allthough I regularly see the AI's researching different technologies than they researched another game. I'm not sure whether they're really that predictable. Some players also discover patterns in things that happen twice in a row. ;)
There are at least a few rather predictable choices/non-choices from the AI.
 
I mentioned the researching unknown technologies earlier in this thread.
lol I have a bad memory. ;)
I thought to have read that the AI already does this, but maybe not enough. Of course, it is only interesting in games that allow tech trading. In non-tech trading games it should not be a factor.

A bit more randomness in the AI tech priorities might also be valuable, allthough I regularly see the AI's researching different technologies than they researched another game. I'm not sure whether they're really that predictable. Some players also discover patterns in things that happen twice in a row. ;)

The main thing going for the human at the moment is that as unpredictable as the AIs might be they often all seem to be getting much the same techs... though maybe this is due to their obsessive trading?

There are at least a few rather predictable choices/non-choices from the AI.
Wait. What do you mean by choices/non-choices?
 
good AIs should probably also put greater value on techs that are undiscovered so it can trade itself up the tech tree. This would of course be very mod independent.

The AI's love their monopolies...
 
The main thing going for the human at the moment is that as unpredictable as the AIs might be they often all seem to be getting much the same techs... though maybe this is due to their obsessive trading?

It might be. I regularly play a game without tech trading. It's a bit easier to see which technologies are avoided and which are typically chosen early.

Wait. What do you mean by choices/non-choices?

Yes, I was a bit vague there. I mean technologies they typically choose early and technologies they typically don't choose until very late in the game.
 
Many of these ideas are specific to the core civilization game and too inflexible to be transferred to mods. The ideas are using the technologies as they are in the core civilization game. I would prefer a system based on the elements that are gained by the technologies (as it is now, for example ability to build unit/building/wonder, + 1 trade route, great person, free technology, etc.) and that might look ahead one technology in the technology tree. The value of the elements gained by a technology of course depends on the empire wide situation.
I haven't seen any of these ideas dependent on using core game techs... One uses the AI weights that's moddable in the XML, and mine is a list generated at the start of the game based on whatever techs are in the XML. Both of these strategies would work quite comfortably with mods.
 
Player Interface
- Holding down SHIFT+ALT and clicking on a leader in the scoreboard now sets your civ's warplan to WARPLAN_PREPARING_TOTAL, like the AI does when beginning war preparations and can be used to signal to Vassals that they should begin preparing for war (not multiplayer compatible)
- Modified CvMainInterface.py to show on scoreboard when player is set to planning a war against another player using WAR in yellow instead of red
Will this work if I'm using BUG mod? I don't think it says WAR anymore and has an icon instead.
 
I haven't seen any of these ideas dependent on using core game techs... One uses the AI weights that's moddable in the XML, and mine is a list generated at the start of the game based on whatever techs are in the XML. Both of these strategies would work quite comfortably with mods.

From what I've seen, the ideas presented here value technologies while it would be more mod friendly to value the elements that are offered by technologies. If a mod changes the elements that are offered by the technologies, then the logic of the BetterAI coding would still work if the valuation of the basic elements was correct.

So add a value to the buildings and wonders and free technologies, religions and great persons, trade routes etcetera instead of the technologies. As far as I know, that is what the basic game already does. It just doesn't look ahead further than one technology and that's not that hard to do (in theory).

Example ingame situation:

Technology A and B can be researched directly. Assume technology A allows technologies A1 and A2, technology B allows technology B1.

Present coding: valuation of technologies is based on the valuation of the elements that are offered by these technologies and this valuation of the elements is summed. Then this is compared to the cost of researching the technology. Then value(A)/techcost(A) and value(B)/techcost(B) are compared and the best one is chosen.

A proposed new method would calculate the value of technology combinations and compare those with the value of single technologies, both weighted to the cost of researching them.

For instance:
value(A)/techcost (A)
value(A + 0,8 A1)/techcost (A + A1)
value(A + 0,8 A2)/techcost (A + A2)
value(A + 0,8 A1 + 0,8 A2)/techcost (A + A1 + A2)
value(B)/techcost (B)
value(B + 0,8 B1) / techcost (B + B1)

And then pick the best one. The 0,8 is there to add a cost to researching deeper into the tree. It takes a while to get the advantages of technologies further into the tree and thus their advantages shouldn't be valued fully.
 
Roland:

I think we might have a little miscommunication here. Right now, the function that determines the "best tech" runs through all of the different elements that you specified. What I would want to do is modify this a bit so that all of the evaluation of the elements would be in a new function like AI_techValue(...) or something. The besttech function would simply cycle through all researchable techs calling the tech value function and returning whatever tech had the highest value.

This would be useful because you could have the game run through these techs at the start of the game, and create a list of techs the most useful techs based on the AI's strategy. When the AI later evaluates what techs to research, one of the criteria they'll use in judging the value of a tech will be whether or not it is a stepping stone to one of those beeline techs. But the beeline techs list will be determined based on the individual benefits the tech gives (just like any other tech) it will be just as friendly to mods.

On top of that, an additional modifier could be added to the XML that will could be changed by modders to determine how valuable a tech's "stepping-stone" potential is. A high value would mean that the AI will pick techs almost exclusively on which techs get you to the good techs. A low value would mean the AI would evaluate each tech individually without regard to what it leads to.
 
Maybe we should make a new thread that focuses on just tech discussion, and start building out what we think would work?

This, and building production are the two biggest problems for me.

Right now, the AI if at war will focus on things like wonders, and not switch back to units after their units die. That's an issue.

And the Tech decision process is horrible, and has no long term strategies.
 
Roland:

I think we might have a little miscommunication here. Right now, the function that determines the "best tech" runs through all of the different elements that you specified. What I would want to do is modify this a bit so that all of the evaluation of the elements would be in a new function like AI_techValue(...) or something. The besttech function would simply cycle through all researchable techs calling the tech value function and returning whatever tech had the highest value.

This would be useful because you could have the game run through these techs at the start of the game, and create a list of techs the most useful techs based on the AI's strategy. When the AI later evaluates what techs to research, one of the criteria they'll use in judging the value of a tech will be whether or not it is a stepping stone to one of those beeline techs. But the beeline techs list will be determined based on the individual benefits the tech gives (just like any other tech) it will be just as friendly to mods.

On top of that, an additional modifier could be added to the XML that will could be changed by modders to determine how valuable a tech's "stepping-stone" potential is. A high value would mean that the AI will pick techs almost exclusively on which techs get you to the good techs. A low value would mean the AI would evaluate each tech individually without regard to what it leads to.

Ok, what you describe and what I describe is very similar (I guess?). When I first read your post (some 20 posts ago), I thought you were adding a different individual technology valuation unrelated to the already present valuation that would create the list you were talking about. Now, it's clear that it's the original valuation algorithm that will create the list.

Note however that the original valuation algorithm also compares the value of the technology to its cost which is of course necessary to estimate the relative efficiency of technologies. A 2000 cost technology needs to be more than 40 times as efficient as a 50 cost technology to be preferable to a civilisation. However, this means that any pregame evaluation of the best technologies in the game will create a list of some ancient age technologies as they are soooo much cheaper. That cannot be your goal.

Am I misunderstanding you again?
 
Note however that the original valuation algorithm also compares the value of the technology to its cost which is of course necessary to estimate the relative efficiency of technologies. A 2000 cost technology needs to be more than 40 times as efficient as a 50 cost technology to be preferable to a civilisation. However, this means that any pregame evaluation of the best technologies in the game will create a list of some ancient age technologies as they are soooo much cheaper. That cannot be your goal.

Am I misunderstanding you again?

No, you're not. This is a valid point. There's a couple of things that could help with this problem. One is that as you discover the techs on the list, the list update to catch new techs. This will also be useful if the computer researches all of the techs on the list so that there's always something the AI is striving for.

Another thing would be to reduce the weight of the tech cost when evaluating the techs for this beeline list.
 
No, you're not. This is a valid point. There's a couple of things that could help with this problem. One is that as you discover the techs on the list, the list update to catch new techs. This will also be useful if the computer researches all of the techs on the list so that there's always something the AI is striving for.

Another thing would be to reduce the weight of the tech cost when evaluating the techs for this beeline list.

Hey, if it would be easy to program the AI to look ahead, then it would have already been done. ;)
With the idea of your first paragraph, you're a lot closer to what PieceofMind and I tried to describe. Not the same, but pretty similar. So in the end, we kind of agree I guess. And it was a useful discussion.
 
The AI now has two main flaws left in Better BtS AI. You've highlighed one there Turkey. The worker AI is still very bad, it breaks the AI right now. In fact it's worse then you make it out to be, since the AI cycles out Towns and Villages, destroying it's economy when it does that.

Related to that is the other main weakness of the AI city specialization. Of course city specialization could not be tackled until worker AI is fixed so that the AI doesn't continualy replace it's improvements around a city.

The third main flaw is that it doesn't know the value of Mining Inc and Sid's Sushi.
 
After having focused on a different hobby for a while, I took a look into Civ4 mods yesterday and found that Better BtS AI has become even better. Thanks for all your work on it! It's also amazing to see how many of the issues that I mentioned in my game report (in the "War strategies" thread) have been addressed, good work! :)

One question though: I usually customize the DLL a bit. Should I use the current SVN version or the current stable version as a base? Does the stable version have bugs which are fixed in SVN already? Does the SVN version have experimental and/or untested features?

Thanks again. :)
 
The final versions are stable. The SVN are experimental, which may mean they are superior, or may mean there is a hidden bug lurking inside. Of course using the SVN and leaving python exceptions on is a good way to identify problems and speed the release of the next final version :) Version .60h was incorporated into the official Revolutions updated though, which means it is stable.
 
Back
Top Bottom