Creating a (hopefully) competitive bot using Claude Code.
-
@husky81
How goes your quest ? -
@TheDog Thanks for the Inquiry. I am still working on the project, but was out of the country last week and only had my phone, so was unable to send updates here.
I was stuck for a while since there were too many problems to solve on the larger 1942 map. Thankfully, someone had suggested working on a map called "Minimap" which has a simplified version of the game. Only 2 factions, 2 capitals with the only factories, connected by 3 ground lanes.
I fed Claude some games that I played against fast and hard ai's, and talked Claude through extracting some principles that could be coded into the bot.
The bot can currently win about 2 out of 3 games against either hard or fast ai's. I will ask Claude to explain how the bot works, it's performance, and details about failed improvements that are not currently in the best version of the bot.
Prompt to Opus 5.5 (High): Claude, could you write a post about how our current best minimap bot works. Include basic details about how it plans turns, its performance in games on the minimap vs. the easy and hard ais (no need to run additional tests, use our most recent completed testing). please also detail the failed ideas we tried via a brief list, saying whether each was neutral or detrimental. There is no need to disguise that you are writing this report. I will include both my prompt and your reply in my post.
Reply:
How the Minimap bot works, and how it’s doing (written by Claude, the AI that has been building and testing it with the owner)
The setting. The tests are on TripleA’s Minimap with Axis & Allies 1942 Second Edition unit rules. It’s a small two-player board, Russians against Italians. Each side has a capital (worth 10), three inner squares (5 each) and three front squares (2 each), arranged in three lanes: north, middle and south. The bot is written in Python and plays inside TripleA through a bridge, so its opponents are TripleA’s own AIs.
How it plans a turn
Buying. It values each possible purchase against a target army mix (about 60% infantry, 15% artillery, 25% tanks), buys at least nine units, and some turns adds a fighter or extra tanks on a random roll. It shifts toward defence when its capital is in danger, and late in the game it favours units that will arrive in time to matter. Its anti-aircraft gun stays home; it only buys more against a large enemy air force.
Attacks. For every enemy square it builds an attacking force unit by unit. Each force is valued by its exact expected unit-value swing, plus the worth of the square, minus its exposure to a counter-attack and any wasted overkill. It then assembles candidate turns: the full plan, the plan minus each battle, no attacks at all, and a few additions. Each candidate is played out on a copy of the game, through the battles, the non-combat move and placement, and then the enemy’s best combined reply. Candidates are scored by unit value left, plus twice the income difference, with a heavy penalty for any chance of losing the capital. The best-scoring turn is the one it plays.
Positioning (non-combat). This is built from principles the owner took from his own winning Minimap games:
Main stack: it stands on the centre front square, where its planes can reach, as long as it can be made to hold there.
Infantry stream: new infantry flows to every lane, sized to the enemy’s attack strength in that lane.
Front squares: each one is either made to hold (with about 7 or more units) or left with a single infantry as a blocker. Nothing in between, because small stacks just feed the enemy.
Tanks: they wait one step behind a safe front, where they can strike more squares.
Capital: it keeps no garrison unless the capital is actually threatened.It tries several variants of this layout and keeps the one the enemy’s best reply hurts least. The newest rule: a front stack that is at least 90% likely to be destroyed where it stands backs up as a block, leaving one blocker.
Retreats. After a round of a big battle that went worse than planned, it retreats only if playing the battle out looks worse than leaving.
Measurement. All odds are exact (computed, not simulated), for battles of any size. There are no caps on battle size or search breadth, by the owner’s rule. Every change goes in as a switch and is tested in paired games: the same seed gives both versions identical dice, so the comparison measures the change, not the luck.Performance (60-round cap; a game counts as unfinished if neither capital has fallen by then)
Against TripleA’s Fast AI, current version, 100 games (both sides, two seeds): 65 wins, 25 losses, 10 unfinished. The version before the newest rule scored 69–23–8, the same within noise.
Against TripleA’s Hard AI, 50 games (one seed, before the newest rule): 34 wins, 12 losses, 4 unfinished. The Hard AI wins the trading, but the bot out-earns it from about round 15.
A note on “easy”: we haven’t tested TripleA’s Easy AI. The weaker AI above is the Fast AI.What we’ve learned from the games:
The bot’s attack odds are honest. Big attacks it rated about 74% won 70% of the time, ~87% won 86%, and near-certain ones won 99%.
Luck still decides a lot. With neutral or good dice through round 20 it won 45 of 50 games; with bad dice, 24 of 50.
The main addressable weakness: in most of the losses that weren’t down to dice, the Fast AI won the race for our centre front square. It concentrates there while we spread across three lanes, plants its main stack on that square around rounds 5–7, and slowly out-earns us. A fix (the infantry stream follows the enemy’s strength per lane) is being tested now.Ideas we tried that didn’t make it (neutral = no measurable change; detrimental = clearly worse)
Random ~8-unit buy (the owner’s buying style, imitated): detrimental.
Buying more fighters: detrimental.
Probing attacks: neutral.
Only attacking when the square is sure to be taken: neutral.
Keeping the main-stack square longer before falling back: neutral.
Judging positions with an emulator of the Fast AI instead of the enemy’s best reply: detrimental.
Holding the main stack forward as long as the Fast AI’s own estimate wouldn’t attack it: neutral on the original Minimap rules, detrimental with 1942 rules.
Combining several individually neutral ideas: detrimental.
A separate “decisive battle” candidate: neutral.
Simulating both outcomes of big battles, and penalising risk: neutral.
An end-game mode (pressing harder when well ahead, aiming at victory and capital strikes): neutral.
Staging tanks to strike the enemy capital two turns ahead: neutral.
Strategic bombing raids with idle bombers: neutral.
Buying more anti-aircraft guns against big air forces: neutral (positive on one seed, not on the second).
Buying more artillery and tanks when the two main stacks face off: neutral.
A desperation gambit (an all-in attack when the game is slipping away): neutral, with no rescues.
Sending more of the infantry stream to the main stack’s lane: neutral.
Keeping tanks inside the main stack instead of one step behind: detrimental (a nice confirmation of the owner’s principle).
Two-turn look-ahead by sampled play-outs: detrimental when it replaced the one-turn reply, neutral when blended with it, and about 3Ă— slower.
Moving the main stack onto just-captured squares: neutral overall (helped as Russians, hurt as Italians).
Letting any front stack back up across lanes: detrimental (stacks retreated where holding was right, and fewer games were finished). The narrow version, which only backs up stacks at least 90% doomed, is neutral and is now on: it halves the crushed-stack disasters.What did move it, for context:
Removing all caps on battle and search size: the biggest single gain.
Choosing the positioning by the enemy’s best reply (the variants above).
Holding front squares properly (the hold-or-blocker rule).
Keeping the anti-aircraft gun at home: the largest gain of all on the original Minimap rules.
I am currently still refining work on the minimap version of the bot, while simultaneously trying to build it out to play on the 1942 map. The current full game bot is being built one power at a time, with Germany and Russia implemented, UK, Japan and USA still to go.
-
If you manage to create an AI which plays V5 better than Hard AI, that would be awesome. I would definitely try it out! Let us non-developers know when and how we can eventually test it.
I'm wondering if using V6 might help you fine tuning V5 even more than using V5 itself. V6 is a very unforgiving map since the start, and I believe it is much easier to beat Hard AI on V6 than on V5.
Minor note, there is the problem that the current best TripleA AI is called "Hard". If you make a better AI, how is TripleA going to inform users to use that as the first choice? Calling your AI "Very Hard AI" or changing the name of "Hard AI" to "Medium AI" something else? I wonder.
-
lf. V6 is a very unforgiving map since the start, and I believe it is much easier to
I am not a developer, except vibecoding. But In order to actually play against the ai that I'm making, I think I would have to build a version that could be packaged into Triple A itself. Now it is a Python program that can only play automated games against other bots.
Well i guess it could play by email or by using save files, but that would be quite cumbersome.
If i ever get it "good enough" I will try to figure out if it can be integrated into Triple A, but for now that's a future step.
I have taken a look at V6, and I like your idea of using that simplified map if I stall out in terms of progress again. For now I will build on V5 since I still have ideas that I have not finished.
One thing that worked well on the minimap, was showing it examples of "Good" play, and having it try to extract rules from what it saw. If you have any save files of completed games on world_war_ii_v5_1942, they could be useful.
I can of course play vs the fast bot myself, but that will take time, and it would be better to have multiple examples form different players. Even better if we had an example or a few of 2 strong human players playing.
-
@husky81
You and Claude have been busy! 🤯So much info to absorb.
So tempting to customise just for one map and very hard to keep it generic like the TripleA AIs.
The list of tried and tested tactics is awesome.
Having a list like that allows the Claude AI to 'try' the neutral tactics and for it to learn if they work on its new current map.For me a standout is
Keeping tanks inside the main stack instead of one step behind: detrimental (a nice confirmation of the owner’s principle).
On maps like 1941GCD, this is a valid Russian tactic. But for Germany , I cannot afford not to keep the German tanks out of the Attack stack. I guess its map dependant?
Its fab to see the win ratio has increased, well done!
-
If you manage to create an AI which plays V5 better than Hard AI, that would be awesome. I would definitely try it out! Let us non-developers know when and how we can eventually test it.
I'm wondering if using V6 might help you fine tuning V5 even more than using V5 itself. V6 is a very unforgiving map since the start, and I believe it is much easier to beat Hard AI on V6 than on V5.
Minor note, there is the problem that the current best TripleA AI is called "Hard". If you make a better AI, how is TripleA going to inform users to use that as the first choice? Calling your AI "Very Hard AI" or changing the name of "Hard AI" to "Medium AI" something else? I wonder.
It could be called the HuskyAI.
-
Yea "Husky and Claude"

-
One thing that worked well on the minimap, was showing it examples of "Good" play, and having it try to extract rules from what it saw. If you have any save files of completed games on world_war_ii_v5_1942, they could be useful.
That's a great idea! Unfortunately, I've never played that map beside maybe once against the AI when @zjelcop was doing those AI challenges many years ago (and I don't kown anyone who plays it). I remember that it was one rare map which the Hard AI was playing quite well, whereas the same AI was much worse at playing V6 (which is the closest map to V5 by rules).
To be clear, "world_war_ii_v5_1942" is a map, so you cannot play it unless in the sense of playing either of its games, but I know that you mean the "World War II v5 1942 SE TR" game of that map (not the other one) unless maybe you actually meant that you are interested in game-saves of either "World War II v5 1942 SE TR" or "World War II v5 1942 Second Edition" (probably not)?
On a second thought, if this AI is optimized on V5, maybe it will be better to call it "WW2v5 AI" or something like that. Anyway, I'm overreaching.
-
optimized on V5, maybe it will be better to call it "WW2v5 AI" or something like that. Anyway, I'm overreaching.
yes, you're right. I would be looking for games using the TR setup. However, at the level that I am working at now, examples of "good" play on either setup would be useful as data points.
The way I am programming the bot is map and rules agnostic, so it can read in the rule set and territories from the triple A map file, then use its logic to play the given map. It values territories by: Capital status, IPC value, connectedness to other territories, factory slots. I do not tell it that India is valuable, it should find that out by looking at its central location and its 3 production slots.
One caveat being that the bot is currently quite slow on WW2v5, so any larger map would really slow it down. Once I get it to be good, I will try to optimize more for speed, hopefully allowing for play on larger maps.
-
@husky81
You and Claude have been busy! 🤯So much info to absorb.
So tempting to customise just for one map and very hard to keep it generic like the TripleA AIs.
The list of tried and tested tactics is awesome.
Having a list like that allows the Claude AI to 'try' the neutral tactics and for it to learn if they work on its new current map.For me a standout is
Keeping tanks inside the main stack instead of one step behind: detrimental (a nice confirmation of the owner’s principle).
On maps like 1941GCD, this is a valid Russian tactic. But for Germany , I cannot afford not to keep the German tanks out of the Attack stack. I guess its map dependant?
Its fab to see the win ratio has increased, well done!
To clarify, it only keeps the tanks outside the main stack when safe (at least that's the intended behaviour), it may still mess up. That's trickier in the mid and late game as Germany on a normal map, because the rear tank stack has to contend with air plus naval units coming in. I still play like that in some positions though, a stack of tanks and new infantry in Baltics connecting Germany to Karelia, the Baltic tanks defend both landings in France and put pressure on Arch, Finland and West Russia. Of course once the Allies have enough Units in Finland, this becomes unenable.
-
@husky81
For future maps. The current TripleA AI is poor at Naval strategy.In particular one very big improvement would be the reuse of transports in Global maps.
In detail, this is the USA returning empty Transports from Europe/Normandy/Torch back to the USA for a refill, to be reused again.
-
e current TripleA AI is poor at Naval strategy.
In particular one very big improvement would be the reuse of transports in Global maps.
In detail, this is the USA returnin
Transport logic is an active area that I'm working on, though it is far from solved. The challenge is to keep transports moving to useful squares, while remaining protected.
-
@husky81
Well
Another biggy is picket fodder/Destroyers.
Meaning that they screen Transports or a Carrier/battleship strike stack.
Placed 1 Sea Zone away from from the above so Surface fleets cannot easily attack the above. -
I only play my own global map 1941GCD, as Britain/USA I line my Transport route with Destroyers, meaning they dont have to move .
This tactic should work for most global maps?
Maybe this is a valid option for HuskyAI ?
-
@husky81
Another Triple-AI failing is Naval blockades, in PvP they can be used to cripple an enemy economy.HuskyAI could be used to add up valid ships that Blockade and be sent to camp on certain Sea Zones and used as a valid tactic.
In 1941GCD submarines cause 2 Blockade vs certain ships that cause 1 Blockade, so if HuskyAI knew this it could use submarines more efectively.
-
@husky81
HuskyAI could do the following;Shucking, sending Transports back and forth for reinforcements.
How to define a Shucking unit?In most A&A maps a Transport 0-0-2 with 7 Transport Capacity is a Shucking unit.
But not every unit with a Transport Capacity is a Shucking unit, they need splitting out by function, as below.
In 1941GCD it has 3 Transport Capacity units with transportCapacity
Battleship 3 TC, transport Inf-Trained, xml has isCombatTransport
Cruiser 2 TC, transport Inf-Elite, xml has isCombatTransport
Convoy 14TC, a mix of units, this is a Shucking unitAir-Transport, an isAir unit, 0-0-4 with 8 transportCapacity is an air transport unit.
It has 2 roles,- Dropping paratroopers into enemy territory in Combat move
- Reinforcing into an owned territory in non-Combat move
Food for HuskyAI
-
optimized on V5, maybe it will be better to call it "WW2v5 AI" or something like that. Anyway, I'm overreaching.
yes, you're right. I would be looking for games using the TR setup. However, at the level that I am working at now, examples of "good" play on either setup would be useful as data points.
What's your knowledge of the balance of "World War II v5 1942 SE TR" from anywhere? Is this game considered very well balanced or not? If it favours one or the other side, what are the common ways of rebalancing it if any?
-
m anywhere? Is this game considered ve
I would say that it is exceptionally well balanced, when played without turn limits (played until one side concedes or looses on victory cities.
It is the only map that is played on "Axis and Allies 1942 Online". it has been played there for years, including discord leagues and tournaments. Many formats such as league have players play a double round robin with no bids, each player playing a game as each side. At the highest level (Generals), both sides play pretty even. last season (20) each faction earned 30 out of 60 points, and the current season is trending in the same direction.
This is the league Google Sheet with records from this and the previous season.
https://docs.google.com/spreadsheets/d/1vojmhuMfHiYwAVa6xj_9EQuH8Eyc-nF-7YzeeKCbZHo/edit?gid=259980370#gid=259980370 -
I would say that it is exceptionally well balanced, when played without turn limits (played until one side concedes or looses on victory cities.
It is the only map that is played on "Axis and Allies 1942 Online". it has been played there for years, including discord leagues and tournaments. Many formats such as league have players play a double round robin with no bids, each player playing a game as each side. At the highest level (Generals), both sides play pretty even. last season (20) each faction earned 30 out of 60 points, and the current season is trending in the same direction.
This is the league Google Sheet with records from this and the previous season.
https://docs.google.com/spreadsheets/d/1vojmhuMfHiYwAVa6xj_9EQuH8Eyc-nF-7YzeeKCbZHo/edit?gid=259980370#gid=259980370Cool. Not sure why it was so ignored by the TripleA community then. When v3 came out, there was a lot of interest around it, whereas v5 was practically completely ignored when it came out.
Personally, I've never played it because I always felt uncomfortable with the Indian factory and with the extremely swingy 63% win chance battle in 37 Sea Zone. What the hell is that for?
Quick questions.
Does Russia always attempt to conquer Ukraine SSR (at 89% Win) and to kill the German bomber on round 1, and does Germany usually take it first as casualty? Was the bomber put there just to get it killed by Russia on round 1?
Does the British fighter in Egypt always survive, and then British attack 37 Sea Zone with everything they can bring (taking the 63% win at -1 TUV swing)?
Is this game perfectly balanced with regular dice? If so, I guess it is slightly unbalanced in favour of Allies with Low Luck because Low Luck favours the opening of Russia to be much safer (especially in Ukraine SSR).
-
Cool. Not sure why it was so ignored by the TripleA community then. When v3 came out, there was a lot of interest around it, whereas v5 was practically completely ignored when it came out.
This would be a bit of speculation, but I guess it comes down to having many more options. If you want an "Official" game, there's classic, anniversary and global. Then there are other custom games as well. The original out of box setup is quite imbalanced. I believe almost all of the changes in TR are allied favoured.
Personally, I've never played it because I always felt uncomfortable with the Indian factory and with the extremely swingy 63% win chance battle in 37 Sea Zone. What the hell is that for?
Quick questions.
Does Russia always attempt to conquer Ukraine SSR (at 89% Win) and to kill the German bomber on round 1, and does Germany usually take it first as casualty? Was the bomber put there just to get it killed by Russia on round 1?
Basically yes, there are some alternatives, the "West Russia Jam" where Russia just overstacks WR and sends a fighter to Egypt to save Uk's fighter. But 99% of games begin with 9-12, all available Russian units to Ukraine, and the remainder used in West Russia. The bomber is basically there to die. Germany starting with one in Germany proper as in out of box is simply too strong, Allies would need some compensation elsewhere if Germany started with that.
In "Online" you must set up your loss order for each power "profile", prior to finishing your turn, and it's fixed until your next turn as that power. Germany 1 is often bomber first, but I use bomber after artillery, because that's good enough that I don't really need to change my profile. I would forget and it would cost games if I had bomber first later on. Some people actually play bomber last, because although it gets fewer hitbacks and wins Ukraine less often, it makes it impossible for Russia to strafe Ukraine and also kill the bomber. If Russia can bring 3 tanks back to Caucuses while leaving only the fighter in Ukraine, that's very Allied favoured provided West Russia was also average or better.Does the British fighter in Egypt always survive, and then British attack 37 Sea Zone with everything they can bring (taking the 63% win at -1 TUV swing)?
The Egypt fighter generally always survives until UK1. Germany has no good way to kill it unless their bomber is still on board. In the current meta, SZ 37 is rarely played though probably under 10% of games. It is viewed as more risk than allies want at that point in the game. It's an asymmetric risk, because it if fails, allies are in really rough shape. Japan starts with 2 transports vs the normal 1 (sz61 is usually cleared) and all of the UK fleet and air is gone from the pacific. India is very tough to hold. If the battle is won, the axis can still win if Germany can get Moscow fast enough. So it's not a "free 68% win" card for Allies. It is a resource to try and stage a comeback if you're off to a bad start though.
Is this game perfectly balanced with regular dice? If so, I guess it is slightly unbalanced in favour of Allies with Low Luck because Low Luck favours the opening of Russia to be much safer (especially in Ukraine SSR).
I can't really comment on Low Luck. I personally don't like it. I thin thinking about how much risk you want or don't want at various points in the game is part of what makes it fun and challenging. I'm not aware of much competitive play on low luck mode on "Online". It's in the game, but not played much since you can't play that way in ladder games. It may well be quite imbalanced and allied favoured since it makes Ukraine safer as you mentioned, as well as what it does to SZ37. you could even take East indies with relatively little risk as Allies.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register Login