A.I. for solitary play?

Just found Vassal a few days ago, still overwhelmed and greatly impressed by it all…

Are there modules for solitary play with built-in A.I.?
(Please stop laughing if this question seems absurd for the software.)

I’d like to play TBS games online in single-player / solitary mode. I’m wondering if there is a way to filter through / search the modules without having to open and read each of the hundreds of descriptions.

Thank you.

It’s a semi-frequent question, no harm in asking. I’m not aware of any modules that include AI for an automated opponent. This would definitely be the realm of bespoke custom programming, if anyone even attempted it.

Thank you for the info.

The main issue is that the current software was never engineered to support an add-on AI making it extremely difficult to shoe-horn one in. There is a long-running project underway to design and build a new version of Vassal that will support (among other things) add-on AI’s. The actual writing of an AI will still be a large and complex task, but that is outside the scope of Vassal. i.e. That’s your problem:)

Thank you much Brent.

I am very much interested in automated opponents. I say automated because I am happy with simpler rule-based opponents (“You have 5 units in these hexes, I go to that hex”) as well as true AI learning and inferring opponents (“Opponents tend to use this technique, I will counter it with this.”)

I will enjoy making automated opponents more once the game play is decoupled from the server code and there is a client API to query the game state. Then it becomes simpler to build a client (in any language) that can query the game state, and provide a move to the server. As mentioned, currently there are not a lot of entry points to put an automated client into the game.

I can’t program so this is beyond my understanding, but I’m glad you want to help automate/A.I. the Vassal Engine games.

Vassal is for playing Board Games on your PC so if you want Solitaire then look for Vassal modules which are adaptions for Solitaire Games. You still need to know the game rules but you can Automate the response to die rolls so that pieces can move/change etc. based on the result. I am in the process of figuring out how to do that now.

Regards;
Darren

That’s good news. I wish you success.

Hi,

To expand a bit on what @Brent_Easton said. I will be thinking of a traditional Hex’n’Counter wargame.

For an automated opponent (I’ll use AI as a short-hand), a great deal of information need to be available to it.

  • The map coordinate system - which a VASSAL module somewhat has.
  • Terrain and other features of the map - which a VASSAL module could have though it quickly becomes cumbersome.
  • Pieces at all map locations - which can be done, but again quickly becomes cumbersome
  • Piece factors - which can be done via Marker traits and similar
  • … and many other things I cannot begin to think of

The AI also needs to know how to move pieces. This could be done via an A* algorithm implemented in VASSAL. This algorithm would then make appropriate call-backs to the module to gain information about movement costs. These callbacks need to provide a fair bit of information to the module, such as

  • which location is the piece moving from
  • which location is the piece moving to
  • which piece is moving
  • which units are present in the location moved to

The module must then also be able to resolve combats. This is doable in the current VASSAL, but does require a bit of coding.

To do all this, it would make sense if VASSAL exposed a lot of scripting capabilities. E.g., when a user selects a piece, a script would be called to calculate possible moves, and VASSAL would then display that to the user. Or when a battle is declared and resolved, then a (set of) scripts would be called with all the relevant information, and VASSAL would then display the results. I could imagine that each module would be implemented as a class a la (in Python)

class MyModule(BaseModule):
    def __init__(self):
         # Set up the module 
         self.buildPieces()
         self.buildBoard()
         self.registerTerrain()
         ...

    def piecesSelected(self,locatedPieces,when):
          # Calculate possible moves when when=movement, attacks when when=combat
          for location,pieces in locatedPieces.items():
               # ...
           if 'movement' in when:
              displayPossibleMoves(moves)
           if 'combat' in when:
              displayPossibleAttacks(moves)

    def declareCombat(self,locatedPieces,when):
         # Calculate combat 'odds'
         attackerCF = 0
         defenderCF = 0
         for location,pieces in locatedPieces.items()
              isWoods = self.isWoods(location)
              for piece in pieces:
                    if self.isAttacker(piece,when):
                        attackerCF += piece.AF()
                    else:
                        defenderCF += piece.DF() * (2 if isWoods else 1)

          odds = self.calculateOdds(attackerCF,defenderCF)

Clearly, this would make VASSAL modules much more programming-heavy to do, and there could be options to have “dump” modules too (predefined base modules and so on).

An example of a module with a somewhat automated opponent is One-Minute Bulge (GitLab snippet, VASSAL module

  • The player selects which kind of surprise attack to do
  • The module then calculates the results
  • Depending on the result of the surprise attack and following automated actions, the player then has the option to attack again, or to trust in its oratory skills in the a Führer conference.
  • The module than determines the result of either, calculates victory points, and displays the result

It takes as long to play as it takes to load the module, if not shorter :slight_smile: To make this requires 474+13+542=1029 lines of LaTeX code, and 637 lines of Python code.

Yours,
Christian

1 Like

It’s exciting for me to see such interest in automated opponents for Vassal. I understand that there is much coding to be done (and much play-testing), but I imagine that working toward this goal is productive and educational for computer professionals. Perhaps some Vassal enthusiasts will join together and work together as a team? Good luck to you.

The sort of interface you’d need for AI isn’t there in V3. It would be a massive effort to add that, and one I think you’ll find no one is willing to undertake. A direct interface to game state will be available in V4, which should leave no impediments for writing bots from our side. It sill won’t be easy, but it will entirely down to writing good AI, not the interface.

2 Likes

Hi, Darren!

Any update on this? I’m pretty green, but am trying to work out how to play a random card from a deck, then target players based on the card’s traits. The second half seems easy enough, but I’m drawing a blank on triggering the flipping of the card!

@WannaBe

My reply may have mislead you. I meant that a solitaire game with Automated dice rolls etc. is sort of like AI. A useless comment from me, perhaps I should remove it.

If you are having trouble with something, more detail about you want to do and what you have tried would be good then one of the experts might answer it for you.

Regards;
Darren