TripleA Logo TripleA Forum
    • TripleA Website
    • Recent
    • Popular
    • Register
    • Login

    Creating a (hopefully) competitive bot using Claude Code.

    Scheduled Pinned Locked Moved AI
    40 Posts 7 Posters 195 Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      husky81 @beelee
      last edited by

      @beelee said:

      s and there counters and then do the same from there. Can see that exploding quite quickly

      But instead of just choose between these 3 and 5 ch

      I can see the interest in making it do some weird plays, like going for fancy VC play, or doing different versions of KJF. I would definetly be interested in doing that. but currently I'm at the stage of trying to get it to stop doing ridiculous and stupid things like buying all infantry and turtling in moscow, or throwing it's Luftwaffe away trying to kill a naval stack that doesn't even had a single tt under it.

      I'm very much at the walk before you can fly stage.

      TheDogT 1 Reply Last reply
      Reply Quote 1
      • TheDogT
        TheDog @husky81
        last edited by

        @husky81
        Does the Claude bot have some simple stacking rules like the following?
        Infantry > Artillery
        Infantry > Armor
        Destroyer > Cruisier
        Destroyer > Battleship
        Destroyer > Carrier
        Destroyer = Transport
        As this determines what to buy/place and then move.

        If attacking it should have Armor in the stack
        If attacking 66%+ chance of success, otherwise don't attack.

        Also if Defending 50%+ chance of success, otherwise retreat

        Just so you know , this is not a clone of what the TripleA AI does. It just me putting stuff on the page, for a starting point.

        https://forums.triplea-game.org/tags/thedog
        https://forums.triplea-game.org/topic/3741/curated-best-top-maps-triplea-guides

        TheDogT H 2 Replies Last reply
        Reply Quote 3
        • TheDogT
          TheDog @TheDog
          last edited by

          The above is only for that map.
          It should be based on the units xml contents, not their unit names.

          So like
          Infantry 1-2-1, 3pu as cheapest land unit
          Artillery 2-2-1 with artillery" value="true as support/mixed unit
          Armour 3-3-1 with Blitz, so an Attack/mixed Unit
          Destroyer 2-2-2 8pu as cheap surface sea unit

          https://forums.triplea-game.org/tags/thedog
          https://forums.triplea-game.org/topic/3741/curated-best-top-maps-triplea-guides

          1 Reply Last reply
          Reply Quote 2
          • H
            husky81 @TheDog
            last edited by

            @TheDog Currently it a values units by TUV (so cost), but also by "combat power" which is pips + 2.6* hit points, so an infantry is worth 2+2.6=4.6 in a defensive stack, 1 +2.6=3.6 in an attacking stack.

            BB's are 4+2*2.6=9.2. This formula was arrived upon by simulating thousands of medium sized (6-12) unit per side land battles, and fitting the value of m in the equation pips + m * hitpoints that best predicted the favorite in the most circumstances. The simulation said that m was pretty flat between 2 and 4, so you could multiply hit points by anything from 2 to 4, then add pips to get a units approximate combat power when in a medium sized stack. (according to Claude)

            the attack threshold is 70% to win I believe. Eventually, I want to have this become adjustable by the current board state. Every turn there is a function that the bot runs to test which side is winning, %to win estimate. (currently this function is not great since my training games only involve weak players). but my idea is that the bot will look for trends in the % to win, and if it notices that it's trending downward, or is really low, the bot will lower it's % to win threshold for attacks, choosing the most impactful ones.

            So if I can ever get it to work right, it will 1-2 yolo on berlin or Karelia if it thinks it's getting close to the point of no return.

            TheDogT 1 Reply Last reply
            Reply Quote 0
            • TheDogT
              TheDog @husky81
              last edited by

              @husky81
              What do think of having temporary hard ratios for Land, Sea, Air for each nation?
              Losses are replaced in these ratios.
              For example
              Germany Land:80%, Sea:0% Air:20%
              Russia Land:80%, Sea:0% Air:20%
              Italy Land:50%, Sea:30% Air:20%
              You get the idea.

              This is to see if you can beat your current scores, as maybe your bots focus is too wide?

              Ideally these ratios should be dynamic, perhaps based on the nearest VC objectives.

              https://forums.triplea-game.org/tags/thedog
              https://forums.triplea-game.org/topic/3741/curated-best-top-maps-triplea-guides

              H 1 Reply Last reply
              Reply Quote 1
              • H
                husky81 @TheDog
                last edited by

                @TheDog said:

                n these ratios.
                For example
                Germany Land:80%, Sea:0% Air:20%
                Russia Land:80%, Sea:0% Air:20%
                Italy Land:50%, Sea:30% Air:20%
                You get the idea.

                This is to see if you can b

                I am not completely opposed to this, but currently the buys don't see to be the problem so much. I think the main issue is having it not leave exposed forces that then get cleaned up cheaply. so the biggest gap is on move planning.

                I suppose hard coding objectives could get there, like Japan Maximize pressure on india round 3, Germany take West Russia Round 4. but I would like to not do that if it can be avoided.

                TheDogT 1 Reply Last reply
                Reply Quote 2
                • TheDogT
                  TheDog @husky81
                  last edited by

                  @husky81 said

                  like buying all infantry and turtling in moscow,

                  As Moscow (A capital and VC) has been secured, its 'objective' value should be reduced(halved) , so that the bot AI gives priorities to adjacent TT to secure it even further so it cannot be directly threatened.

                  the attack threshold is 70% to win I believe

                  Maybe I'm too aggressive/optimistic, I would reduce this to 66% to see if this is affecting the win ratio.
                  In the past, this is one of the TripleA improvements I have asked for. In simple terms Germany/Japan is more aggressive than USA/Britain, so a map maker could pick a nations Aggression level to simulate this.

                  https://forums.triplea-game.org/tags/thedog
                  https://forums.triplea-game.org/topic/3741/curated-best-top-maps-triplea-guides

                  B 1 Reply Last reply
                  Reply Quote 3
                  • B
                    beelee @TheDog
                    last edited by

                    @TheDog said:

                    o a map maker could pick a nations Aggression level to simulate this.

                    rightarm.png

                    H 1 Reply Last reply
                    Reply Quote 2
                    • H
                      husky81 @beelee
                      last edited by

                      @beelee Yes, Ideally it will be customizable, but all current bots that I am aware of are pretty stupid, mine included.
                      The developers of tripleA did a great job coding a bot that can play reasonable games (better than mine) without benefit of AI tools, and one that can work on a wide variety of maps. Impressive.

                      But let's face it, at the end of the day, the bot plays some stupid moves. My goal is first to make it play less stupid. At some point it will have tunable agression.

                      If I ever distribute it, I could look into having some settings that users could control. As is, there are lots of settings in the code that Claude tries to optimize, so I think it would be easy ish to make some of them user facing in a public version.

                      B 1 Reply Last reply
                      Reply Quote 1
                      • B
                        beelee @husky81
                        last edited by

                        @husky81

                        Yea I believe @redrum created Hard AI but then his day job was creating AI 🙂

                        1 Reply Last reply
                        Reply Quote 2
                        • C
                          Cernel Moderators Lobby Moderators @husky81
                          last edited by

                          @husky81 said:

                          @Cernel said:

                          World War II v5 1942 SE TR

                          Sorry, I didn't see this. Yes, my bot plays 'World War II v5 1942 SE TR'

                          For development and testing I play in a Python engine that Claude built for that purpose. In those cases I played without bids. The only major rule difference is no landing on allied carriers, since that's not in the Beamdog game. Claude also built a bridge that allows my bot to play the bots that ship with Triple A. I've not changed the rules in Triple A, just my own engine and my bot's logic, so for the games played through the bridge, the Triple A AI could use allied carriers, but mine never will.

                          Guessing that you have the skills, I guess that, if you push a program update so to have a property to forbid landing on allied carriers (and maybe also loading onto allied transports) and then add that property (false as preset but of course editable via Game Options) to the game in question, everything will be accepted by the developers (I certainly do not speak for them, so CC @lafayette). Done that, you would just be able to put that property as true before starting the game (so to enforce it for all players, human and AI). This seems to me to be a lot better than enforcing it on the AI itself. (I do think that this property would be valuable in itself.)

                          Of course, it's your project (and I have no idea how much work would be to do that): just suggesting, not saying you are doing it wrong.

                          TheDogT 1 Reply Last reply
                          Reply Quote 2
                          • TheDogT
                            TheDog @Cernel
                            last edited by

                            @husky81
                            Does Claude-AI/NavalAgent know the order of importance of, for eample the following order;
                            Own Capital> VC> Allied Capital> Enemy Capital> Factory> High TT/SZ PUs
                            Perhaps assign numeric values to these to resolve overall importance for a TT/SZ ?

                            I still think Claude-AI/NavalAgent needs guidances (helping hand) as to what is important to players. Then once it has decided that the order/values are invalid it can replace it with its own.

                            https://forums.triplea-game.org/tags/thedog
                            https://forums.triplea-game.org/topic/3741/curated-best-top-maps-triplea-guides

                            H 1 Reply Last reply
                            Reply Quote 2
                            • H
                              husky81 @TheDog
                              last edited by

                              @TheDog said:

                              Claude-AI/NavalAgent needs guidances (helping hand) as to what is important to players. Then o

                              It knows the value of capitals, and of production points per territory (it uses 1 inf per pu). it doesn't really concider vc's yet. those are tricky, because they aren't worth anything until a VC snipe is on the cards. for example, if I'm Germany and besieging moscow, on pace to take in say 2 turns turns. I don't care if USA can trade Italy, France and Karelia, unless they also have a bunch of VC's on the other side of the map.

                              The bot does check the win condition ahead of its turn so it will try to retake a VC if it is about to lose, but will not plan around VC Play.

                              TheDogT 1 Reply Last reply
                              Reply Quote 1
                              • TheDogT
                                TheDog @husky81
                                last edited by

                                @husky81 said
                                will not plan around VC Play.

                                I think this should be a major part of your Executive planning that you are talking about in the other thread, owning the 13 VCs should be a major part of the "eyes on the prize" .

                                A human player always has the VCs as part of their planning, so should Claude-AI.

                                they aren't worth anything until a VC snipe is on the cards

                                Totally disagree, from the start they should form part of the Claude-AI opening play, otherwise how will the Claude-AI ever win?

                                https://forums.triplea-game.org/tags/thedog
                                https://forums.triplea-game.org/topic/3741/curated-best-top-maps-triplea-guides

                                H 1 Reply Last reply
                                Reply Quote 0
                                • H
                                  husky81 @TheDog
                                  last edited by

                                  @TheDog said:

                                  the start they should form part of th

                                  For me, most of my games when playing humans end with economic victories, where one side has enough excess material and income that the other side resigns. There are exceptions, but generally economy ends up being more important than VC's. Of course many territories are important for multiple reasons, like Karelia, which blocks the western allies and the russians from linking up.

                                  I think they are important of course, but for now it's a later thing once the basics are covered.

                                  TheDogT 1 Reply Last reply
                                  Reply Quote 0
                                  • TheDogT
                                    TheDog @husky81
                                    last edited by

                                    @husky81
                                    So now you have your initial baseline results, Im hoping for now, that you stop using your Tokens verses Hard-AI, Easy-AI and Does Nothing, and just concentrate on using them, against Fast-AI ?

                                    What are your plans for testing for improvements to Claude-AI ?

                                    https://forums.triplea-game.org/tags/thedog
                                    https://forums.triplea-game.org/topic/3741/curated-best-top-maps-triplea-guides

                                    TheDogT 1 Reply Last reply
                                    Reply Quote 0
                                    • TheDogT
                                      TheDog @TheDog
                                      last edited by

                                      @husky81
                                      How goes your quest ?

                                      https://forums.triplea-game.org/tags/thedog
                                      https://forums.triplea-game.org/topic/3741/curated-best-top-maps-triplea-guides

                                      H 1 Reply Last reply
                                      Reply Quote 1
                                      • H
                                        husky81 @TheDog
                                        last edited by

                                        @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.

                                        1 Reply Last reply
                                        Reply Quote 0
                                        • C
                                          Cernel Moderators Lobby Moderators
                                          last edited by

                                          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.

                                          H 1 Reply Last reply
                                          Reply Quote 1
                                          • H
                                            husky81 @Cernel
                                            last edited by

                                            @Cernel said:

                                            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.

                                            1 Reply Last reply
                                            Reply Quote 0

                                            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
                                            • 1
                                            • 2
                                            • 2 / 2
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums