AI for Vassal

Hi all!

Just started using Vassal last night for the first time. My two kids and I put together a game in one night with help of photoshop and I was quite impressed.

It made me wonder if it was possible to code an AI through the Vassal engine.

I could see 2 ways of doing it:

  1. Directly modifying the Vassal Code with module specific AI code.
  2. By creating a virtual PBEM opponent that could ingest the log file and build the position in its own memory, plan a move, render the move to the log file and send it back to the human player.

Just wondering if anyone has gone down either of these roads (or other) and what they have learned.

FYI, I’m a professional programmer with experience writing game software so I understand the complexity of writing an AI (I know what I’m getting into here), I’m just not clear on the difficulty of interfacing with Vassal or which (if either) of the above approaches would work best.

I kind of lean towards (2) because it means I only have to learn the logfile language not the whole Vassal source tree and it also means I can use any language I want and host the solution on my own remote server or running locally on my machine.

Anyway, just wondering what other developer’s thoughts are on this.


It would need to be heavily scripted and have two pieces given additional Markers or properties describing who or what is controlling them, then a ‘turn’ variable…

Use of zones and proximity (not so straight forward) could be used to trigger certain moves in the correct turn; but not actual AI. It would be a script with very limited options…

If in this zone stay still, if that zone move over there…

If in this other zone and an enemy within (X, Y) range then trigger this set of moves… etc

Nothing that you would perhaps consider true AI…

Anyone else see this differently… its not something I ever really thought to do… I guess the best ‘AI’ (sic) is always a live opponent…

Well see that was my thought in regards to the second option:

Instead of directly trying to do this through the vassal engine itself, use the log file as a communication mechanism between the player and the ai.

So the AI in this case would be a stand alone server that waits for its log file to be updated. When it is, it reads it in and uses it to assemble its own representation of the game. Then it generates its list of moves and creates its own log file which is sent back to the human and read back into Vassal.

This could also be used for move validation. Since the AI program would have to understand the rules in order to make informed decisions, it could validate the human’s moves on receipt and reject them with a meaningful error message and send it back to the human to correct.

“Invalid move, battleships can not go on land hexes.”

for example…

Well, you could show a message like that in ‘real time’, why send it somewhere to ave a message sent back when you could have a either tiles (using grid) or zones for telling ships they can’t sail around the city centre…

And why not just hit an end turn button and the ‘AI’ take over rather than send it… somewhere…

Perhaps I don’t fully follow your ideas though, so feel free to explain if you like…

You’d almost certainly want to do a combination of 1) and 2). That is, create a virtual PBEM opponent that was built by extending the VASSAL code. In principle, you could parse the logfiles without using the VASSAL code, but given that parsing logfiles and module data is the bulk of what the VASSAL code does, you’d be crazy to throw all that work away and re-write it from scratch in a different language. If you were dying to use a different language, you could always use another JVM-compatible language like Jython or Scala.


Post generated using Mail2Forum (

I wrote a version of Ogre in Java (long before VASSAL was at 2.0) following a published STRATEGIC SUGGESTIONS FOR OGRE PROGRAMMERS (about halfway down in that document). Despite the info on how to write an Ogre AI, I don’t think Steve Jackson Games has ever allowed anyone a way to do this without violating copyright.

But now, I’m thinking, since the VASSAL module exists for Ogre (and respects the Steve Jackson Games copyright conditions), what would be the problem with me implementing my AI using an API to VASSAL?

Is there an API to VASSAL useful to developing an AI module?

Thus spake “fuhrmanator”:

Huh. That article brings back memories. I had the computer game
published by Origin which had that text in one of its manuals.

I don’t see any reason why there would be copyright issues associated with
writing AI. You can’t copyright game rules, and an AI shouldn’t need any
game art.

BTW, I suspect that you could do a lot better than the AI they describe
by binning strategically-similar board positions and calculating game
trees out to some depth. Computers are lot faster now than they were when
I played Ogre on an IBM PCjr in 1987.

That depends on what exactly you need. If you could describe what
the API you want to use is like, I can tell you whether we have it
already. Alternatively, if you’re interested in going through the
work to write AI, then you might be interested in helping us add
whatever is lacking in API if we don’t already have it.


Messages mailing list …

Post generated using Mail2Forum (

I’m pretty familiar with module development, so I assume that all info (traits, properties, pieces, etc.) would be available to an AI module. I was imagining an AI for Ogre to be a “side” in the VASSAL terminology.

In the VASSAL architecture with a server, where would such an AI module “run”? Would it just be another client?

Before I go on, I should point out I’m not familiar with the details of the existing Ogre module for VASSAL. But it shouldn’t matter for my questions.

There would have to be a synchronization mechanism for an AI. For example, the phases of a turn in Ogre are 1) player moves (possibly rams the Ogre), 2) player fires (affecting the Ogre’s stats), 3) Ogre moves (possibly overruns player’s pieces), 4) Ogre fires (affecting the player’s stats), and 5) player moves GEVs (possibly rams Ogre).

Since the AI would “take over” on phases 3 and 4, there needs to be a way to signal that to the AI (and stop the players from doing anything while that’s going on?). I’m assuming that the other capabilities (e.g., moving its own piece, interacting with the player’s pieces, etc.) would be automatable? I am guessing we’re talking about something more sophisticated than defining GKCs for synchronization. That is not what I would call an API.

As for AI support, I only recall needing pathfinding (used an A* algorithm) in my Ogre AI, but that was easy enough to find on the web. If VASSAL had path-finding stuff as a support, as well as a hex functions (e.g. facing, neighbors), that would be cool. I would have to look again at my code to see what other stuff I used. It’s been 5 years or so…

Thus spake “fuhrmanator”:

Since Ogre is a 2-player game, I was thinking that the AI player would
run on the same machine that the human player is using. We don’t want AI
running on the game server, as that’s going to be potentially processor
and memory intensive. Having it be another client would make sense.

The simplest thing would be to have a button which the user clicks to
signal that he’s finished with his phase. (That’s the way the computer
version I played many years ago was. There’s no way for the AI to tell
whether you’ve finished moving or you’re just thinking when you have
units which could still move or shoot.)

Pathfinding is something you’d want to build into your AI client. I’m not
sure what we have for hex functions right now. If we don’t have those, we
should. Maybe Brent can comment on this?


Messages mailing list …

Post generated using Mail2Forum (