A Frankensteins monster of a script, gluing different APIs and programs together. It's purpose? To generate completely new Magic: The Gathering cards from user prompts and make playable decks out of these. Does it work? Kinda. Is it fun? Definitely!
The script uses OpenAI GPT Chat api to generate cards and Dalle or Stable Diffusion for "art". These a given to Magic Set Editor which renders them into bona fide magic cards. With another prompt to the Chat api, a deck is build which output a "playable" deck in Tabletop Simulators Save format.
Example outputs:
Theme prompt | Generated cards |
---|---|
Cheese | |
cow | |
Shrek |
- Download Magic Set Editor (Lite is fine) and put it in a folder named "mse" https://magicseteditor.boards.net/page/downloads
- Add your OpenAI API key as an environment variable named "OPENAI_API_KEY" - guide. Make sure the enviroment variable is available by restarting any open terminal sessions (including VS Code)
- Install
openai
python package - pip - conda - Run
main.py
It's possible to use stable diffusion instead of Dalle for art generation.
- Install a stable diffusion webUI - I used AUTOMATIC1111's project
- Add
--api
to theCOMMANDLINE_ARGS
line inwebui-user.bat
so it readsset COMMANDLINE_ARGS=--api
- Start the webui using the startup script
- Change the
render_card
backend parameter tostablediffusion
- Enchantments sometimes have effects with no trigger.
- Better checking of missing fields
- Better deck generation
Output from this program is unofficial Fan Content permitted under the Fan Content Policy. Not approved/endorsed by Wizards. Portions of the materials used are property of Wizards of the Coast. ©Wizards of the Coast LLC.
Copyright 2023 Mikkel Pilegaard
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.