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

    Creating a (hopefully) competitive bot using Claude Code.

    Scheduled Pinned Locked Moved AI
    14 Posts 6 Posters 83 Views 5 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
      last edited by

      Re: AI Development Discussion and Feedback

      I am a regular player of Axis and Allies 1942 online, and just got a Claude subscription. My perhaps naive idea for a first project in Claude Code is to create a bot that can competently play the Larry Harris Gencon map that is used in AA1942 online.

      So far I have been able to set up self play between my bot and the Hard AI in Triple A (my bot loses badly when paying both sides). I have also been able to set up self play between the Hard AI in order to create a database of games.

      My current goal is to create a heuristic function that will look at the board state, position, income, units, turn number, ect. and attempt to predict the eventual winner. Initially I will use the games generated through automated self play as my data set, however I would ideally like to get my hands on some saved games from strong human players. I have found that the AI within triple a is not quite up to a human standard, and also that it plays the Axis considerably better than it plays as allies.

      I am also interested in whether anyone has developed other ai's aside from the ones that ship with triple a (hard, easy, fast does nothing)

      Anyway, if anyone has some saved games that may be useful, that would be great, also if anyone has interest in the project let me know.

      B X 2 Replies Last reply
      Reply Quote 3
      • B
        beelee @husky81
        last edited by

        @husky81

        Hi husky

        Welcome to the site. You may want to check the A&A site https://www.axisandallies.org/forums/. They have specific threads for each game or most anyway.

        Might find some saves there. Could also go to the lobby and ask the guys that play there if you could use some of their saves. I forget which one 42 online is but Revised gets played a lot in the lobby.

        Good Luck

        PantherP H 2 Replies Last reply
        Reply Quote 2
        • PantherP
          Panther Admin Moderators Lobby Moderators @beelee
          last edited by Panther

          @beelee said:

          which one 42 online is

          It's Beamdog's software variant of the '1942 2nd Edition' boardgame. 'Variant' because the software does not include all of the boardgame's rules.

          Don't always trust TripleA when it comes to rules questions. Know the rules before you start … and better check what TripleA has done.

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

            @beelee Thank you for your reply. I have also crossposted on AxisandAllies.org, as you've suggested, although I might not have posted in the right place for maximum visibility. The setup I'm workign it is the tournament setup for 1942 2nd edition, the one that starts the German bomber in Ukraine rather than Germany where it is in out of box. As Panther says, there are some rule discrepancies, like carriers not being able to hold allied fighters.

            At the present level that bots play, those aren't so relevant. We are at the point where we are trying to get the program to not hang important units without good reason, and to not play either over aggressive or over passive.

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

              I ran a bot vs bot tournament on 1942 2nd edition, Larry Harris Gencon (Bomber in Ukraine) setup, giving Russia a heavy bid (+45) here are the results from Claude.

              Note my AI is "Naval Agent" and was capable of beating the easy AI, but lost badly to hard and fast.

              Fast and hard are nearly equal strength, with hard using about 1/6th the compute.

              Tournament results.JPG

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

                Can you please just use names of games which can be found in TripleA, adding information on what you changed if anything? You mean that you are playing "World War II v5 1942 SE TR" with a bid for Russians or also some other changes?

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

                  @husky81
                  What is your approach doing it?

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

                    @xxXEddieXxx well there's lots of ideas that I have and it's early stages at the moment.

                    The thing is entirely vibe coded, using Claude code Opus. I have the 200$/year plan so no Fable access.

                    I am not a software developer at all, so everything software related in entirely up to ai. I have read 0 lines of code so far, and couldn't understand most of them if I did. I studied math in undergrad, so i am used to logical thinking though.

                    I (meaning Opus) have built a python engine that implements the map and game's ruleset. It is also bridged to a local copy of triple A. Claude can simulate tournaments between my bots in the python engine, or use the bridge to triple a to match my bots vs the pre-exising bots in the game.

                    I have told Claude that I want my bot to be constructed in a modular fashion, so that modules can be swapped out or changed individually, changes can them be A/B tested by running tournaments pitting various versions of my bots against each other. I get Claude to track various statistics form these tournaments. For example, when I was building the naval logic, I had tournaments where i tracked number of amphibious assaults, ships lost, transports lost, units delivered, and a few other things. trying to get the logic right so that transports get defended, enemy fleets get zoned out and attacked, and lots of units get delivered to combat theatres.

                    The most important component i have not is the threat map. It uses Combat power, which is currently dice pips+2.6 times hit points, maintains an updated defense value for each territory on the board, and also maintains an overlapping projected combat power of each nation onto each territory, tracking the maximum combat power that can be brought to bear against any target, or potential target.

                    I started off with just a basic attack planner that takes every attack over 70% given that it doesn't leave the capital vulnerable . My next step is to try and build a competent attack planner that take other factors like stack survival into consideration in its planning. My main ideas are to go for a combination of positive TUV exchange, and restriction of the enemy's projected combat power. so for example the bot will try to block tank blitzes, because doing so reduces the enemy's projected combat power, restricting the tanks attack to fewer territories.

                    I will keep working and iterating through conversations with Opus. I do most of the things on my phone using Cowork. Claude code runs on my desktop building and testing the bot modules. I ask it questions, and give it information and instructions by talking into my phone.

                    So far i haven't actually watched any games that it plays, all of them are simulated, and only statistics are reported. This is quite fast and efficient, but once the core of my bot is built I'll see if i can look at some games to see if i detect problems that escape the q and a format i currently use. I'll at least need to finish the ground attack module, purchasing, and give it the ability to think more than one turn ahead before it's worth looking at what the bot is actually doing.

                    X TheDogT 2 Replies Last reply
                    Reply Quote 1
                    • X
                      xxXEddieXxx @husky81
                      last edited by

                      @husky81 hey that sounds ambitious. I don't know how deep you are in terms of how these ai models work. But I had some ideas regarding an AI aswell and made a little map of it :

                                      │ Strategic Planner     │
                                      │ LLM / learned policy  │
                                                  │
                                      strategic objectives
                                                  │
                                    "Pressure Moscow"
                                    "Hold India"
                                    "Build naval superiority"
                                    "Trade Ukraine cheaply"
                                                  │
                                                  ▼
                                   │ Candidate Plan Generator │
                                   │ deterministic algorithms │
                                   
                                                 │
                                       20-100 plans
                                                 │
                                                 ▼
                                   
                                    │ Simulation / Search    │
                                    │ MCTS / rollouts        │
                                   
                                                 │
                                           expected values
                                                 │
                                                 ▼
                      
                                       │ Value Function  │
                                       │ NN + heuristics │
                                                │
                                                ▼
                                             ACTION
                      

                      There is also a paper on something that might help.
                      https://repository.gatech.edu/server/api/core/bitstreams/a1b58887-d7df-48ee-a412-b13b3e236983/content

                      In terms of models opus 5.5 should be enough.

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

                        @husky81
                        TripleA AI uses some of these values, its just a list to be used as a guide. It is more complicated than listed, but it gives you a start point for your AI.

                        2x TT/SZ PU value +
                        10x if isFactory (personally should consider canProduceXUnits value) +
                        11x if TT is also MyCapital +
                        5x if it is isEnemyOrAlliedCapital) (personally Allied Capital should be 6x)

                        Victory Centre does not appear to be taken into the AI calucation, but in the xml you can have
                        "victoryCity" value="1" so this should be a multiplier.

                        Keep up the good work!

                        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 @xxXEddieXxx
                          last edited by

                          @xxXEddieXxx I spent most of the day building logic for combat moves. once I finish purchases and non combat moves i'll have an alpha version of my bot. To clarify, it had purchases and non combat moves before, but just something simple that opus cooked up, like everything to the nearest front, buy inf and arty plus transports if not mainland factories.

                          really simple stuff. I'm trying to build more thoughtful versions of those modules. Once that's done I'll pit it against triple a's fast ai and see how it does. I did this once before, beat easy, but lost badly to fast and hard. For sake of time i won't play hard again until I can beat fast. I have no idea how long that will take, but this vibe coding allows such quick and easy iteration that it's incredible. The most time consuming aspect is running simulations, as I only have 1 old ish pc with an 8 core cpu doing the work, i asked it about trying to use my GPU, But Claude said it wasnt't powerful enough to be useful, and it would require rewriting alot of the game software.

                          When i'm done with the modules i talked about above I'll post tournament results and a Claude writeup about how it works. Eddie, I'm not sure your schematic would be compatible with what i've built so far. But after the build I'm working on now, i'll feed it into claude code and see what it thinks. I may end up adding features from your outline, or building a competing bot around your model, recusing existing components where I can.

                          Currently my GitHub repo is set to private, but I am willing to open it up and share it once I'm somewhat happy with where the project is. I would want it to be a personal project, so wouldn't be looking for collaborators, at least at the moment, but of course people could fork it if they wanted, and no doubt someone would advance leaps and bounds beyond me.

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

                            @TheDog Thanks! I am trying to get claude to work things out from first principles to the extent possible. It's really amazing what can be done and the conversations that can be had. iteration is also extremely fast. It can write code in seconds that I couldn't in months, test and refine, all just by asking it questions and providing human information.

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

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

                              The results above are from a tournament I simulated between an early version of my bot and Triple A's Bots. For that tournament I used a bid of Russia +45!!, because based on simulations, that's what is required to equalize the Axis and the Allies on that map when played by the standard Triple A bots.

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

                                @husky81
                                Does Claude know the importance of a victoryCity and the loss of a Capital ?

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