Examples or guidance on a headless VASSAL load?

Hello, I am a long time Java developer, and I have no problem with the GIT repos or running the VASSAL Java code in Eclipse.

My goal is to build a computer opponent, so I would like to be able to read the vmod file, or one of the vsav scenario files, build a valid GameModule and GameState, and then add my code to analyze the board and make an action. However I am having trouble loading a vsav module (from Commands and Colors Ancients).

I’ve seen this pattern in one of the unit test files:

final GameModule module = new GameModule( new DataArchive(Path.of(modFile).toString()));
module.build();

However, when I attempt to load a vmod file with this pattern, there is an error in GameModule before the module is read or built.

Exception in thread "main" java.lang.IllegalStateException
	at VASSAL.tools.menu.MenuManager.getInstance(MenuManager.java:38)
	at VASSAL.launch.PlayerWindow.setupMenubarAndActions(PlayerWindow.java:78)
	at VASSAL.launch.PlayerWindow.<init>(PlayerWindow.java:70)
	at VASSAL.build.GameModule.<init>(GameModule.java:298)
	at VASSAL.build.module.GameState.main(GameState.java:1317)

Can anyone point me to how to read vmod or vsav files, with the goal of building a GameState object so that I can query the pieces and the cards? Ideally no connected GUI, It is ok if a GUI is instantiated and remains hidden.

Thanks, Dan Becker

Where in particular? I don’t find anything like that when I search.

It is commented out, but it is in VASSAL.configure.ColorConfigurerTest.

Any pointers to proper loading patterns (not necessarily with a GUI launcher) are appreciated.

Thanks, Dan Becker

The reason that’s commented out is that it can’t possibly work.

The GUI for Vassal is hopelessly intertwined with the business logic due to some poor design choices made at the beginning, in the early 90s. You will find that there is no way to run the components you need (with a reasonable amount of effort) in a headless JVM.

We’re at the start of a complete rewrite presently, V4. If you’re interested in writing AI, I suggest waiting for V4 (or at least some usable demos of it). With V3, you will spend more time fighting with it instead of writing AI.

If you’re intent on trying this with V3, you’ll almost certainly need the GUI to run.

Thanks for the info, and I read your comments for V4. Any way to view, read code, or join V4 development? Or is it still in the requirements and design phase?

Jump into the Discord and visit the #version_4 channel

1 Like