Skip to content

A backend for hosting a neural cellular automata (NCA) model for generating Zelda levels.

Notifications You must be signed in to change notification settings

Interactive-NCA/nca-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎮 Neural Cellular Automata Zelda Level Generator 🧩

Status Last commit

This repository contains a backend for hosting a neural cellular automata (NCA) model for generating Zelda levels. The model is built using PyTorch and is hosted using FastAPI and Google Cloud ☁️.

The NCA model uses a grid-based approach, where each cell in the grid represents a tile in the level. The model generates levels by updating each cell in the grid based on its neighboring cells, and then repeating this process for a set number of iterations. The output of the model is a 2D grid of tiles that represents a generated Zelda level.

🧑‍🔬 Currently we are hosting experiments: 16, 38, 27, 28, 29. The endpoints usually require you to choose which experiment you want the NCA models from.

🛡️ Zelda level generation

The interactive web app that utilizes this backend can be seen here

⚙️ Tech Stack

  • FastAPI
  • PyTorch
  • Google Cloud

🚀 Getting Started

To get started with this project, you will need to clone the repository to your local machine:

git clone --recurse-submodules -j8 [email protected]:Interactive-NCA/nca-backend.git

Then, make a copy of the submodule:

cp -r app/ext/control-pcgnca app/ext/pcgnca

Next, you will need to install the dependencies using pip:

pip install -r requirements.txt

If you wish to use experiments, that we conducted in our research, you need to set the LOCAL variable in main.py to False.

If you want to load your own custom experiments locally. You need to load them in app/models by creating a folder that is named expEXP_ID where EXP_ID is the experiment's number that you choose, then in this folder, upload there the experiment's settings.json and the trained_archive.csv of trained NCA models. Don't forget to set the LOCAL variable to True.

⚠️ Note: The LOCAL=True setup has not been tested exhaustively, so please submit an issue if you have troubles running your own custom experiments.

Finally, you can run the backend using the following command:

uvicorn app.main:app --reload

This will start the FastAPI server, which you can access by navigating to http://localhost:8000 in your web browser.

📝 Usage

The backend provides a simple API for generating Zelda levels using an archive of trained NCA models. To check all the endpoints in a swagger UI you can navigate to http://localhost:8000/docs. The main endpoint is /generate

🌐 Deployment

This repository is configured for deployment using Google Cloud️ ☁️. The application is re-deployed as a container on every push to the main branch.

🤝 Contributing

Contributions are always welcome! If you have any ideas or suggestions for the project, please create an issue or submit a pull request. Please follow these conventions for commit messages.

About

A backend for hosting a neural cellular automata (NCA) model for generating Zelda levels.

Resources

Stars

Watchers

Forks

Languages