How to improve the AI without the Devs doing too much testing?
-
Here is one option;
The Devs can put in a 'feature flag', so it is turned on by beta testers, which keeps existing code intact.The Devs could then turn the current fixed values in the AI into variables that we as beta testers could change and experiment with in a new ai.properties file that could look like this;
NonCombatMove phase
ProNonCombatMoveAi.production=2
ProNonCombatMoveAi.isFactory=10
ProNonCombatMoveAi.cantMoveUnitValue=0.5
ProNonCombatMoveAi.neighborValue=10Purchase phase
ProPurchaseAi.production=2
ProPurchaseAi.isFactory=10There could be more sections and more variables, but these need to be identified.
As its a properties file this is per map.
The current idea is that we test the above parameters with our own values and report back our findings to hopefully improve the AI.
Thoughts?
A note of caution, dont think the above will become a feature of Triplea as it will have unintended consequences in the future, for now its just for testing.
-
I like the idea. I'm actually working on a new AI using the diffusion idea. It will require territories to be given values. I hope to work on it over the winter break and have something working by next year. I'll see about adding a way to allow the map to set the various weights.
-
@Trevan How do you testing AI? Do you temporarly change codes to measure AI behaviours or there are another methods?
-
@Schulz I haven't done much testing of the triplea AI. I've been focusing on the battle code. But when I do testing, I generally try to write test cases so that I can understand what is happening. Once I have test cases and I understand what is happening, I next try to work on test cases that describe the behavior I want. Those test cases will fail initially since the code probably won't work but I can then change the code so that the tests finally pass. This is basically "Test Driven Development" (https://en.wikipedia.org/wiki/Test-driven_development).
-
@Schulz , a way to test the AI without changing anything in the engine is to create specially crafted maps.
As an example, let's say you think that the AI is incorrectly using transports. You've noticed on several of the maps that the AI is only using half the capacity of the transport.
You could build a small map that basically forces the AI to use transports. Set up the initial units with a transport and units to be transported and then let the AI play one round and see what it does with the transports. And that small map and test might show that even though there is plenty of people to be put on the transport, it really is only filling it half way.
Once you have that small map that obviously shows the issue, you can post that map in a bug report to show what is happening.
Another example is your comment from https://forums.triplea-game.org/topic/2482/ai-reports-based-on-aggression-1941 on how Germany never uses the starting subs. You could create a small map that gives a player some starting subs and put some obvious targets near the subs. Give the player several choices, one sub vs one target, 20 subs vs one target, one sub vs 20 targets, sub vs destroyer, etc. Then let the AI play one round of that player and see what it does with the subs. If it never attacks, even in the case where it is an obvious win (20 subs vs one target), that would indicate that the AI doesn't know how to use subs. If it does do attacks, the selection of attacks could tell you how the AI is doing sub battles (only does overwhelming odds, only does attacks against ships in the open water, etc). Having that small map that shows the wrong behavior in an obvious manner makes debugging and fixing things a lot easier. Because in Domination 1941, there might be lots of reasons why Germany isn't using the subs. It could be that AI does know how to use subs but just doesn't see any value with using it. But in a small map where the subs are the only thing the AI can work with, we can see what the AI really does think about subs.
-
Should I build a small map from the stratch or is there any good available map for this purpose? Is it wrong to test AI behaviours in normal maps even if we can guess the reasons of bad AI decisions?
I would rather try to solve the issues by myself also wondering if it is appropriate to report all bad AI decisions in github separately.
Later I solved this sub issue by increasing sub attack to 3. But other major issues are still present unfortunately.
Also wondering if normal players are not permitted to change the codes could I just customize AI and keep it in my engine while leaving the current one as it is?
-
@Schulz @RogerCooper linked to a small map at one point. you could search through his posts, or maybe he will show up and can link it again, or at least say exactly what the name was.
Normal players are permitted to make changes. All changes go through an approval process in Github. But you would want to make the changes locally anyway, to make sure they work. If you want your changes to be incorporated into the main engine, you will want to read through the documentation and directions.
https://github.com/triplea-game/triplea/tree/master/docs/development -
@Schulz said in How to improve the AI without the Devs doing too much testing?:
Should I build a small map from the stratch or is there any good available map for this purpose? Is it wrong to test AI behaviours in normal maps even if we can guess the reasons of bad AI decisions?
It isn't wrong to test the AI behaviors in the normal maps, but when you are trying to fix things, it is better to have a small test case where you absolutely know what should happen. In the normal maps, there's a lot of possibilities and so you might think you know the AI reasoning but you might not. An example is the canal change I made because of the Warcraft map. Looking at the AI behavior, it appeared as if the AI wasn't taking canals into account. But going through the code, it turned out it was except for in a few places. Having a map that had the canals and one that didn't allowed me to figure out exactly where the problem is.
I would rather try to solve the issues by myself also wondering if it is appropriate to report all bad AI decisions in github separately.
The more details that you can find about the issue, the better. Writing an issue that says "AI ignores initial subs in Dominion 1941" is ok, but I, personally, wouldn't be able to do much with that. But if there was a small map that showed the AI ignoring subs in a specific manner, then I could do something with that. The former has too many possible reasons why it is ignoring it. The later has removed a lot of the possibilities and narrows the scope of the issue.
Later I solved this sub issue by increasing sub attack to 3. But other major issues are still present unfortunately.
Also wondering if normal players are not permitted to change the codes could I just customize AI and keep it in my engine while leaving the current one as it is?
Just like @ff03k64 said, anyone can submit changes through Github.
-
@Trevan said in How to improve the AI without the Devs doing too much testing?:
Just like @ff03k64 said, anyone can submit changes through Github.
They even let me submit some changes!!
-
@ff03k64 Mini-map is a good one for testing issues involving land combat, Capture the Flag is another good small one. Both in the experimental area of the repository.
World War II v6 is a small version of the regular games, which could be a good place to look at naval and complicated issues. It is in the high quality area.
-
But even if the changes makes AI better in certain maps, couldn't they also effect negatively for other maps since maps don't have their own AI? For example my map has no A&A capital rule, I mean nations do not lose their remaining incomes and production abilities if they lost their capitals and because of that I would want AI less protective of their capitals but this could make AI worse in A&A games since losing capital is huge deal in this games.
Should I open different topics for every flawed AI behaviours if I can guess the reason or its better to collect all of them in a post in the forum?
I would rather want all maps have their customizable AI could it be possible in the near future?
-
@Schulz
I can tell you that the current AI is heavily weighted in defending Capitals and if there is no Capital it is still capable of defending factories, but you are correct the AI will not defend factories with same logic/determination as a Capital.As you probably know Trevan will be working on a variant AI over the winter break, it sounds very ambitious, so I would not post anything as individual issues yet, but do keep a log, thats what Im doing, as the Devs dont currently have the time to look at old AI issues.
Trevan also said
I'll see about adding a way to allow the map to set the various weights.So lets hope he does.
When we get the new AI it will generate its own AI weakness and that's the one to concentrate on.
-
@LaFayette , would you prefer having custom AI weights to be written in the map xml? Or as a separate file in the game directory? The weights would control how important a capital, factory, resource, etc should be considered when building out the diffused field. There will also be a diffuse rate that can be controlled.
-
@Trevan Would either make it more compatible with current maps?
-
I don't think either will affect current maps. There'll be default weights that maps will automatically have. Maps will have the opportunity to override the defaults. I think putting it in the map xml might be better because then a single zip file might have multiple xmls that need different custom weights.
-
@Trevan The other option would be to do it like objectives are done.
-
@ff03k64 Objectives aren't quite the same thing. The AI should actually utilize objectives in giving values of territories.
The weights are more on how should parts of the game be valued. Say the game has IPCs and Oil. All territories produce IPCs but only a few produce oil. If the AI values IPCs and Oil identically, then a territory with 3 IPCs will always be more important than a territory with 2 Oil. But, most likely, 2 Oil is better than 3 IPCs. The AI might be able to learn that but to give it a hint, the map maker could say that each Oil is worth 3x. Now, the territory with 2 Oil is actually worth 6 instead of 2 and the AI will go for that.
-
redrum has done an excellent job with the AI! It has improved at least 10 fold since I first tested it so gg
I will battle and test the current AI again when I'm in the mood but I will say again this game and its' engine and the Ai will always be elite and maybe the greatest RTS of all time!
By the way, I'm busy with physics theories and doing a math paper that is a million dollar challenge through an institute and also I'm a researcher for a famous night time radio show host and I've been followed by famous authors for my history theories and discoveries that you know nothing of yet but will tell yous eventually
-
@Trevan i just meant you could do an AI properties file like how there is an objectives property file for multiple xmls.
-
@ff03k64 oh, I didn't know about that. How does that file work?