Page 1 of 1

API or otherwise automating AI v AI game play

PostPosted: 14 Apr 2019, 06:02
by bigchase
Does an interface exist with which Forge can be operated problematically to, for instance, launch the application with a link to a text file that defines two decks and directs the application to play a certain number AI v AI games with the decks and report the results. Does not appear such an interface via command line parameters or some other form of API exists.

Any devs interested in adding this capability?

Re: API or otherwise automating AI v AI game play

PostPosted: 14 Apr 2019, 13:06
by friarsol
It exists. Search the forums for headless mode

Re: API or otherwise automating AI v AI game play

PostPosted: 15 Apr 2019, 00:39
by bigchase
Thanks for your reply. Actually few directly applicable results from search for "headless mode", but following a link from a link, found your post linked below which appears to be the most complete documentation for "headless model" (passing start-up parameters from command line):

http://www.slightlymagic.net/forum/view ... 15#p196569
along with tips on locating deck files:
http://www.slightlymagic.net/forum/view ... 3&p=210601

I wish to have custom puzzles solved through simulation (in other words, initiate AI vs AI games from prescribed game states). Essentially want to start AI vs AI simulations from the command line that initiate games from a game state file. So wish to combine headless mode with puzzle mode. But a puzzle mode that:

1. Executes a simulated AI vs AI game starting from the defined game state.
2. Can accommodate multiple turns including card draw from libraries defined in game state.
3. Removes milling as a game loss condition (not have a game be lost/ended when no card can be drawn from an empty library). I can not find the "Lose by Decking" checkbox that the Wiki indicates should be visible in DevMode? Is it possible to disable "Lose by Decking" by setting a flag in the game state file?
4. Have Unlimited mana available to both AI players every turn. Can do so by including many lands in the battlefields defined in the game state, but wondering if it is possible to set unlimited mana for every turn for both AI players?

Reading documentation for puzzle mode on the following thread, but have yet to see anything about combining puzzle mode and simulation mode (initiating a simulation from a game state defined by a puzzle configuration). Feasible to do so?

http://www.slightlymagic.net/forum/view ... 52&t=20332

Thanks again.

Re: API or otherwise automating AI v AI game play

PostPosted: 15 Apr 2019, 16:43
by Xitax
Somebody correct me if I'm wrong, but I don't think Forge's AI is capable of doing what I think you are getting at.

Forge's AI will not "find all solutions" to any given game state, but simply pick one that it likes best. This means that the AI will approach a puzzle in one way only and won't try other ways of playing. This probably (especially in the case of puzzles that are designed to be complicated or abuse odd rules) won't result in any meaningful results. It definitely won't help you determine if a puzzle is solvable or not, or if it has multiple solutions.

Re: API or otherwise automating AI v AI game play

PostPosted: 15 Apr 2019, 18:06
by bigchase
I should have been more clear. Not looking for a puzzle solution. Looking to play out a game from a given initial game state. And looking to do so without a lose by decking condition and unlimited mana. Operatively, the questions are:

1. How to execute a sim game from command line in which game starts from a specified game state file?

2. How to execute a sim game with "lose by decking" deactivated?

3. How to execute a sim game with unlimited mana? (The answer to this question is probably simply to include many land cards in the game state file's battlefield data.)

Thanks

Re: API or otherwise automating AI v AI game play

PostPosted: 16 Apr 2019, 01:30
by friarsol
bigchase wrote:I should have been more clear. Not looking for a puzzle solution. Looking to play out a game from a given initial game state. And looking to do so without a lose by decking condition and unlimited mana. Operatively, the questions are:

1. How to execute a sim game from command line in which game starts from a specified game state file?

2. How to execute a sim game with "lose by decking" deactivated?

3. How to execute a sim game with unlimited mana? (The answer to this question is probably simply to include many land cards in the game state file's battlefield data.)

Thanks
None of that exists currently. Loading a Game State file (what powers Puzzles) shouldn't be that difficult although it might be a little tricky to both load deck files and load game states. Typically game states have everything you need but I'd imagine that's awkward to setup.

Infinite mana isn't really a thing that exists in forge. So sure, adding lots of land could accomplish that.

Re: API or otherwise automating AI v AI game play

PostPosted: 16 Apr 2019, 02:43
by bigchase
1. I believe game state configuration flexibility will indeed enable everything I need from that perspective. Auto loading the game state files is the missing feature. What source files need to be modified in order to load games states problematically (based on command line parameters)? (My java is not strong so will likely be reliant on recruiting a better coder to assist.)

2. What about the "lose by decking" issue? Appears the checkbox mentioned in the below linked wiki page is no longer visible in DevMode? Is there a game state file flag that toggles "lose by decking"?

http://www.slightlymagic.net/wiki/Forge ... By_Decking

Summary: Simple need is to initiate simulations starting with: a) a small number of specified cards in libraries (far less than 40; may not even need to provide non-empty decks since libraries can be specified in game state file), b) specified cards in each hand, c) specified starting life counts (starting life counts != 20), and d) no lose by decking. Can be thought of as simulating the finish of a previously played game from some midpoint of that game, though my particular interest in no lose by decking differs a bit from that use case. (The similarity with puzzle mode is in the unique starting game state, but differs from puzzles in that intended to be AI vs. AI game played to completion and needs to be initiated by command line specification of initial game state.)

Thnx again

Re: API or otherwise automating AI v AI game play

PostPosted: 19 Apr 2019, 07:17
by bigchase
The "Lose Game by Decking" modal seems to be missing from dev mode options? The wiki page describes it as a simple checkbox form element, but I can't find it anywhere in the desktop application. Anyone know where to find it and/or how to change mode in game state file?

Re: API or otherwise automating AI v AI game play

PostPosted: 19 Apr 2019, 20:40
by friarsol
I don't think that option exists when dev mode was rewritten. I'm sure the wiki is just out of date. Probably the best options are filling the decks with lots of useless cards (how long do you want the AI to play for?) the other option is maybe we can build an effect like Laboratory Maniac that just stops you from losing in this case.

R:Event$ Draw | ActiveZones$ Battlefield | ValidPlayer$ You | IsPresent$ Card.YouOwn | PresentZone$ Library | PresentCompare$ EQ0 | ReplaceWith$ Win | Description$ If you would draw a card while your library has no cards in it, you win the game instead.

Re: API or otherwise automating AI v AI game play

PostPosted: 28 Apr 2019, 20:15
by bigchase
1. I want the AI to play as long as both opponent's have life-- want it to finish the game. Laboratory Maniac is interesting suggestion. Might work if I configure game state file to place card equipped with Darksteel Plate and Luminous Bonds on the battlefield (though haven't found a card that can protect the enchantments)? Believe game state file can be configured to enchant Laboratory Maniac on the battlefield with these two cards?


2. What does"Correcting zone for ______ (x)" in .log file output of simulated run mean?