@RogerCooper - Very good points. I mostly care about case #2 with 2 alliances. I'll add a few things:
1. The chance to declare war on members of the opposing alliance should increase as the game goes on. Example: turn 1 50% chance to declare war, turn 2 66% chance to declare war, turn 3 75% chance to declare war, etc
2. The chance to declare war on neutrals should increase as the game goes on. Example: turn 1 1% chance to declare war, turn 2 2% chance to declare war, turn 3 3% chance to declare war
3. Try to factor in distance from enemy as well. Example: Global 1940 Germany has a greater chance to declare war on Russia then USA or China
4. Add some map specific options for mapmakers to specify average turn war declaration should occur. Example: XML specifies Germany should declare war on Russia turn 3 on average then reduce chance in turns prior to that turn for example in #1: turn 1 25% (50% / 2) chance to declare war, turn 2 33% (66% / 2) chance to declare war, turn 3 75% chance to declare war, etc
#2 is tricky, i'd say leave it at 1% all game, especially for a game like global
For non-neutrals, it would be nice if the AI maybe came up with the strategy first, and then started purchasing and moving into better positions, then declare war 1-2 turns later.
Because without planning, and often 1-2 turns delay after deciding what to do before you actually declare war, you will often result in not being able to take advantage of the new war.
Like, all your units are sitting in France defending against the UK and you just declared war on Russia (who proceeds to conquer all your undefended border states).
@Veqryn - A strategy would be great but then we get into needing to persist AI data in the save game since it would be across multiple turns. So maybe eventually but that's probably a long ways off.
I think the best way to address it now would be to make the AI treat countries it 'can be at war with' similar to if they were already at war. This would cause the Germans to move towards the Russia border even if they don't declare war on them turn 1. This also helps so that the AI defends against countries that can declare war on it and not get caught in bad positions.
Let me generalize the concepts of when to declare war. They are 2 reasons to declare war in the game.
1. Aggressive. You attack a weak nation to increase your income or VC's. This only makes sense if you (and your potential allies) are stronger than your current foes, we still be stronger after declaring war and your has something worth taking. If you have no current foes, declaring war makes sense if you and your potential allies have more TUV than your enemy.
2. Balance of Power. You attack a strong nation because it is too close to victory. You best make peace with weak nations.
These are quantifiable concepts, so they can be incorporated into the AI.
So in a typical WW2, it makes sense for Germany to attack Russia after defeating France because it would have a TUV advantage over Russia & Britain combined. Similarly the Japanese should attack the US only after it defeats China. However it would make sense for Japan to attack Britain, because it gains Germany as an ally. Russia might declare war for balance of power reasons, or to gain Britain as an ally.
@RogerCooper - From a high level that is correct but actually doesn't matter much in 2 team games. The more important factor in my mind is proximity and whether you can make gains. If you wait as Japan until China is completely wiped out to declare war on the UK then you've lost the opportunity cost of taking lots of British territory several turns earlier.
Really the only reason Japan doesn't always declare turn 1 in global 1940 is that it allows the USA to to get +20 in NO and Japan -10 in NO. The opportunity cost of taking all the nearby rich allied land is the big reason to declare war not anything about having more TUV than the enemy alliance as most of the USA/UK units are far away.
This is also the reason that Germany declares war on Russia and not China. It is much closer and can make gains sooner even though China is much weaker.
There appears to be 6 declare war options for Japan:
1. True neutrals
6. USA and UK/ANZAC/Dutch
Why does the last option exist since isn't it covered by #4 and #5? And in the rules it states that declaring war on USA is separate from UK/ANZAC/Dutch:
" Japan may declare war on the United Kingdom, ANZAC, the United States, France, or the Soviet Union at the beginning of the Combat Move phase of any of its turns. A declaration of war by Japan against either the United Kingdom or ANZAC will immediately result in a state of war between Japan and both of those powers. A state of war between Japan and France or between Japan and the Soviet Union will not affect relations between Japan and the United States, and vice versa. Japan may attack Dutch territories only if a state of war exists between it and the United Kingdom and ANZAC."
@beelee - Yeah, it seems like just an unnecessary combination of #4&5.
@all - So Sourceforge SVN repos and file uploads are still down otherwise I'd upload the latest pre-release :/
To answer my own question: What is the best way to determine if a player is a 'neutral'?
- I decided the best way was to check if a player has any game steps assigned to them (purchase, combat movement, etc) and if they don't then I consider them a 'neutral' player
- This makes it so Dutch, Mongolia, Neutral_Axis, Neutral_Allies, Neutral_True are all treated as neutral players in G40
I've implemented the initial AI politics and it appears to work pretty well on Global 1940 (it should at least be playable now). Essentially, it supports 2 team maps right now where all non-neutral players should end up at war with each other eventually (all axis and allied power in G40). It determines war declaration chance by considering what it can gain the current turn and how many rounds the game has gone. Its pretty basic but in my opinion a significant improvement over the completely random politics the AI used previously.
Hopefully Sourceforge is back up soon so everyone can help test it :)
interesting that you are discussing politics and reminds me of that old Nintendo game Genghis Khan and the kind of logic they used with that games' AI. I'm sure this games' AI is way more complex but anyways I will give this new AI .jar update a go when I can and get back to yous!
Once again the politics hydra rears its ugly heads hehe. the 1940 DoW stuff is a definite drag, and sure to present us with some tricky dilemmas from the AI perspective. Right now the 1940 games are the basis for the feature existing, so I'd just shoot for something that can mimic the first three rounds of a standard Human vs Human match up.
In general I'd say that Global 1940 is designed such that "Total War" conditions should be achieved for everyone by the end of the 4th round, meaning that all Nations are at war with all nations (with the exception of true neutrals.) True Neutrals are weird in G40, compared to the way neutrality was approached in some earlier tripleA scenarios like those that feature "attackable neutrals", true neutrals in G40 when attacked all go to "Pro-(Opponents Side)" which makes them more complicated and less desirable to attack.
Classic neutrals (pay to take) and Attackable neutrals (with defensive units in place) are a lot more straightforward than the G40 "True Neutrals." I think the true neutrals in G40 should have like their own category, and that its probably best if the AI just avoids declaring on them altogether. Otherwise you open a Spanish pandora's box hehe. I suppose if you do want this, then like Veq said maybe make it just a narrow possibility.
If the goal is for the AI to emulate normal human play then maybe something like...
G1: Germany probably should not declare against Russia in round 1. Usually the DoW against Russia is delayed by at least a round, giving Germany time to first take France and then consolidate before redirecting against the East. But given the way the AI approaches things, I think there is a strong reason for them to start moving against Russia sooner rather than later, so they can get their ground stacks pushing in the right direction.
R1: Russia should declare war on Japan immediately, since there are no practical consequences or penalties for doing so.
J1: This is the big one. The whole Politics system in G40, with all its annoying complexity, is really just a way to control/time-out Japanese entry into the war.
There is a strong J1DoW opener that has been well outlined on the boards by Cow and others, but it involves a pretty specific set of objectives that the JapanAI would need to "know" in order for the play to be effective enough to overcome the income penalties. Basically these involve snatching up the money islands asap, and then smashing India as quickly as possible. Otherwise I think it might be more effective from an AI standpoint, if Japan also delays their DoW by at least one round.
There are narrative reasons for doing this as well as gameplay ones, since Barbarossa and the War in the Pacific didn't start in 1940 after all, but 1941! haha. The human player might want to accelerate the timeline, with a bold rewriting of history, but I think the AI should probably adopt a more conservative/historical approach. Waiting 1 round, gives a kind of abstract nod to the the historical reality. Basically waiting until the second, third, or fourth round to declare war, each with a different "style" of opening to match the delay would be optimal.
A round 1 DoW by Axis would be fun to see, but then we'd probably want a bit more scripting for the opening attacks. Otherwise round round 2/3 would likely be optimal, even if human players can manage the round1 or round4 DoW, I'm not sure about the work involved to give the AI a fighting chance with it. Round 1 DoW is all for speed and the AI might have hang ups, on the other hand waiting till round 4, gives the Human Allies a pretty decent leg up vs the Machine. You know unless London is just being smashed for some kind of hail Mary longshot (not something the AI should probably be doing anyway) then Axis don't really need wait so long. Round 2 would probably be my preference, for a more agressive game.
Back to 1942.2 though...
I got in a few more games while sourceforge was down...
Not sure if I'm able to attach, so I'll just pick one that was kind of notable.
Here the AI played me to a near stalemate. Up late and a few key blunders by the Human, that the AI was able to exploit with ruthless efficiency after wearing me down in the endurance slog haha. Some nice clean air wipes by AI Axis with their bombers. The reach of that unit, and sneaky positioning "just out of the field of view" from the map zoom, has been my downfall more than once when playing the AI. I think its bomber game is quite strong, but SBR would still be nice to see for the clincher.
This time the Human Allies threw in the towel after 18 rounds, with the Americans eager to negotiate some kind of separate peace with Germany, the Allied fleets just got worked ;)
Redrum: Here are three save games from the Napoleonic Empires map. AI vs AI games. Played until total victory achived.
All three games ended with victory for the Carolingians team. So did three other games played with the second-latest release (not uploaded). Just to watch any effect: latest game started with a 10 bid to Prussia.
Some things to mention:
- I think more emphasis on capturing convoy zones is needed.
- Uk purchases many Marine units. Not a bad thing since it is a naval nation. But maybe a tweak is needed, for the balance between purchase of "special attack" units (marines, paratroops, mechanized infanttry etc.) and the amount of special attacks that the nation can actually do.
If at all possible: consider the reuse of the special units, much like the reuse of transports, rather than purchasing new units.
As long as FFA are concerned, both for deciding what is a neutral and what not and how to handle Politics I highly suggest the referring point being the Feudal Japan map by RolfLarsson.
It has the minor clan thing, that it is pushing about to the sensible extreme the concept of having an in-game player that it is an active neutral and the Politics is very clean and intuitive (only 3 relationshis: War - Neutral - Allied), and the map design is overall quite basic and intuitive, thus ideal for starting having the AI thinking about Politics in a FFA game.
I noticed that the Hard AI got this upgrade one or two months ago:
”Enhanced strategic territory value to value territories towards middle of map higher”
After playing around a bit with some of my own made maps, and while working on a new map of mine, I noticed this behavior from the AI’s side (or I imagine that it is this behavior I see). It seems like the AI masses its units towards the center of the map, towards a fictional none existing “Berlin” or something. Maybe it is a good AI behavior on a standard A&A map, but I would guess that there are some maps that would work better without this AI map center focus.
So I was thinking if this feature could be made into an editable XML setting. Like if the degree of center focus could be adjusted or turned on/off via the XML code? If it is a good AI feature on most standard A&A maps, then it could very well be “on” as standard, but it would be nice if it could be turned off on maps where the AI was better off spreading landgrabing on the maps outer edges a bit.
(Or alternatively just turn the feature down a bit … but of course only if the map center focus has proven a bit too much on the normal A&A maps as well)
@Black Elk - Nice save game. For politics, I don't plan to implement any 'map specific' logic. So everything has to be somewhat general. In other words, no checks saying if country = 'Germany', etc. I think my first pass on it is actually pretty decent with <50% turn 1 war declaration chances besides Japan which ends up having around 60-70% chance to declare war turn 1 (this is actually skewed because for some reason there is a political option that isn't in the rules to declare war on all allies which causes the chances to declare war considered twice). Japan war options:
- USA and UK/ANZAC/Dutch (this is a combination of the above 2 which causes the AI to double war chance percentage since it checks declaring war on these nations again)
@Lasse i Gatan - Agree that convoy zones are supported but the AI doesn't put that much focus on them. I just haven't put a lot of time into writing that logic since they aren't used in that many maps (and if they are they tend not to be as strong as they are in Napoleonic).
@Cernel - Probably a good tip though I'm going to hold off on implementing FFA politics for now and just focus on 2 team politics.
@Frostion - So I'd need to see some save games to determine if that is having any affect on your maps.
To explain that enhancement in more depth, the AI does a calculation on how many nearby land territories a territory has when determining its strategic value. This means territories that have lots of territories nearby such as Russia, Middle East, etc in WW2 maps get extra value while territories near the edges such as South Africa, Western Europe, East Asia, etc get less value. This is so units tend to prefer to move towards areas where they can project power to lots of other territories not to dead ends.
Eventually, I plan to allow lots of various map specific AI settings so map creators can improve the AI per map. This is on the TODO list but is a very large change so is lower priority for now.
I have yet to read through this entire thread; as I simply skipped to this newest post. However, I did notice the following comment (from @Black Elk):
"...(this is actually skewed because for some reason there is a political option that isn't in the rules to declare war on all allies which causes the chances to declare war considered twice). Japan war options:
- USA and UK/ANZAC/Dutch (this is a combination of the above 2 which causes the AI to double war chance percentage since it checks declaring war on these nations again)..."
It would seem to me that the logic for the third option should not come into play unless (and only if) one of the first two options became true. At that point, there would indeed be a second roll to decide if whether to go against all or just the one.
I'm sure that's self evident; but it did help me to become involved in the conversation.
PS. That's simple logic; you should see what I can do with complex "fuzzy" logic.
@Stohrm - That's correct but my point is that the option should just be removed as it adds no value and just leads to confusion for players and the AI. Removing it would make it so I don't need to write a bunch of logic to see if political options are subsets of each other.
@redrum, would you be able to upload/post the new jar file, that way people could test out the new politics code in the AI before we do the release?
If sourceforge still isn't up, put it on sendspace or another file hosting site for now.