Package: mario-gpt
MarioGPT: Open-Ended Text2Level Generation through Large Language ModelsPlaying Generated LevelGenerated LevelHow does it work?ArchitectureExample Prompt GenerationsMarioGPT is a finetuned GPT2 model (specifically,distilgpt2), that is trained on a subset Super Mario Bros and Super Mario Bros: The Lost Levels levels, provided byThe Video Game Level Corpus. MarioGPT is able to generate levels, guided by a simple text prompt. This generation is not perfect, but we believe this is a great first step more controllable and diverse level / environment generation. Forward generation:Requirementspython3.8+Installationfrom pypipip install mario-gptor from sourcegit clone git@github.com:shyamsn97/mario-gpt.git
python setup.py installGenerating LevelsSince our models are built off of the amazingtransformerslibrary, we host our model inhttps://huggingface.co/shyamsn97/Mario-GPT2-700-context-lengthThis code snippet is the minimal code you need to generate a mario level!frommario_gptimportMarioLM,SampleOutput# pretrained_model = shyamsn97/Mario-GPT2-700-context-lengthmario_lm=MarioLM()# use cuda to speed stuff up# import torch# device = torch.device('cuda')# mario_lm = mario_lm.to(device)prompts=["many pipes, many enemies, some blocks, high elevation"]# generate level of size 1400, pump temperature up to ~2.4 for more stochastic but playable levelsgenerated_level=mario_lm.sample(prompts=prompts,num_steps=1400,temperature=2.0,use_tqdm=True)# show string listgenerated_level.level# show PIL imagegenerated_level.img# save imagegenerated_level.img.save("generated_level.png")# save text level to filegenerated_level.save("generated_level.txt")# play in interactivegenerated_level.play()# run Astar agentgenerated_level.run_astar()# Continue generationgenerated_level_continued=mario_lm.sample(seed=generated_level,prompts=prompts,num_steps=1400,temperature=2.0,use_tqdm=True)# load from text fileloaded_level=SampleOutput.load("generated_level.txt")# play from loaded (should be the same level that we generated)loaded_level.play()...Seenotebookfor a more in depth tutorial to generate levelsInteracting with LevelsRight now there are two ways to interact with generated levels:Huggingface demo-- Thanks to the amazing work bymultimodalart, you can generate and play levels interactively in the browser! In addition, gpus are provided so you don't have to own one yourself.Using theplay and astar methods. These require you to have java installed on your computer (Java 8+ tested). For interactive, use theplay()method and for astar use therun_astarmethod. Example:frommario_gptimportMarioLMmario_lm=MarioLM()prompts=["many pipes, many enemies, some blocks, high elevation"]generated_level=mario_lm.sample(prompts=prompts,num_steps=1400,temperature=2.0,use_tqdm=True)# play in interactivegenerated_level.play()# run Astar agentgenerated_level.run_astar()Future PlansHere's a list of some stuff that will be added to the codebase!Basic inference codeAdd MarioBert ModelAdd Interactive simulatorInpainting functionality from paperOpen-ended level generation codeTraining code from paperDifferent generation methods (eg. constrained beam search, etc.)AuthorsShyam Sudhakaranshyamsnair@protonmail.com,https://github.com/shyamsn97Miguel González-Duquemigd@itu.dk,https://github.com/miguelgonduClaire Glanoisclgl@itu.dk,https://github.com/claireaoiMatthias Freibergermatfr@itu.dk,https://github.com/matfreiElias Najarroenaj@itu.dk,https://github.com/enajxSebastian Risisebr@itu.dk,https://github.com/sebastianrisiCitationIf you use the code for academic or commecial use, please cite the associated paper:@misc{https://doi.org/10.48550/arxiv.2302.05981,
  doi = {10.48550/ARXIV.2302.05981},
  
  url = {https://arxiv.org/abs/2302.05981},
  
  author = {Sudhakaran, Shyam and González-Duque, Miguel and Glanois, Claire and Freiberger, Matthias and Najarro, Elias and Risi, Sebastian},
  
  keywords = {Artificial Intelligence (cs.AI), Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
  
  title = {MarioGPT: Open-Ended Text2Level Generation through Large Language Models},
  
  publisher = {arXiv},
  
  year = {2023},
  
  copyright = {arXiv.org perpetual, non-exclusive license}
}