Page 1 of 1

Running AI vs AI matches headless (without gui)

PostPosted: 07 Mar 2017, 14:14
by errevs
Hi! I am doing my master thesis on evolutionary deckbuilding in MTG and I am trying to figure out how to calculate the strength of a deck in a population (known as a "fitness function"). Is it possible to run AI vs AI matches in forge from the command line or through an API without the need to interact with the GUI?

All other insights into this are also very welcome.

Re: Running AI vs AI matches headless (without gui)

PostPosted: 08 Mar 2017, 00:14
by friarsol
Yep Forge definitely has that capability. We had a pretty big discussion about it last year

viewtopic.php?f=26&t=18446

I can help with any details you can't figure out.

Re: Running AI vs AI matches headless (without gui)

PostPosted: 08 Mar 2017, 09:14
by errevs
Thanks! I am currently trying to run the sim with the .jar file, as I am developing on a Mac. I cannot seem to get the decks loaded. I am testing with the burn deck and the goblins deck from the thread you linked. The error I get is:
Code: Select all
could not load deck - Burn.dck, match cannot start
I have tried to specify the path to load decks form with
Code: Select all
-D /absolute/path/to/decks
to no avail. Any advice?

Re: Running AI vs AI matches headless (without gui)

PostPosted: 09 Mar 2017, 00:52
by friarsol
What's the exact command line you are running? And can you give me an 'ls' of that decks folder?

Re: Running AI vs AI matches headless (without gui)

PostPosted: 09 Mar 2017, 16:56
by errevs
The exact command I use is
Code: Select all
java -Xmx1024m -jar forge-gui-desktop-1.5.61-SNAPSHOT-jar-with-dependencies.jar sim -D /Users/my_username/testdecks -d Jund.dck enchantress.dck -q -n 10
I also tried
Code: Select all
java -Xmx1024m -jar forge-gui-desktop-1.5.61-SNAPSHOT-jar-with-dependencies.jar sim -d Jund.dck enchantress.dck -q -n 10 -D  /Users/my_username/testdecks
and variants with or without quotes around the path.

ls of that folder:
Code: Select all
Jund.dck
enchantress.dck
I looked a bit at the source code and it seems that the test to check if -D argument is present is not reached, but I can't be sure as I haven't had the time to dig too deep yet.

By placing the decks I want to check in /Users/my_username/Library/Application Support/Forge/decks/constructed/ I was able to test them, but ideally I would like to use a folder structure for the experiment.

Re: Running AI vs AI matches headless (without gui)

PostPosted: 11 Mar 2017, 01:48
by friarsol
Ah I haven't looked at this code in a while. The directory parameter is only if you are using the tournament flag. Soo.. you could either run a two deck tournament with (-t Bracket), which might not make as much sense for your setup.

It looks like the -d parameter isn't working because you just have the .dck files at a random location, and the simulator tries to infer the deck directory for you. So by saying
Code: Select all
-d Jund.dck enchantress.dck
it expects Jund.dck and enchantress.dck to be saved within the Forge structure. Most specifically, this would be inside Forge's User directory, which on a Mac should be something like => <your home directory>/Library/Application Support/Forge/

Once you have your Forge user directory, your decks should be either in decks/constructed or decks/commander as appropriate.

You can use a folder structure for the experiment as long as that folder lives within that root directory. I bet you could even just have a softlink from your existing location inside Forge's constructed folder

Code: Select all
ln -s <your home directory>/Library/Application Support/Forge/decks/constructed/testdecks <your home directory>/testdecks/
and then look for testdecks/Jund.dck

Re: Running AI vs AI matches headless (without gui)

PostPosted: 14 Mar 2017, 10:19
by errevs
Cheers, that works! Thanks a lot for your help!