Skip to content
Generating 2D map tiles with Generative Adversarial Network (GAN)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Generating 2D map tiles with Generative Adversarial Network (GAN)


This repository contains all the source code used to generate small 2D tiles commonly used in video games for building maps. Generating tiles was achieved using a Deep Convolutional Generative Adversarial Network (DCGAN). This code uses PyTorch as backend.

This is an example of what it can generate:

And when interpolating in its latent space:

You can find more information and details about this source code in this article:


There are few dependencies:

How to use it

1. Create your own dataset:

  • You can use the simple Processing ( script provided in this repository to convert downloaded tilesets into individual tiles
  • All tilesets must be in a folder with no other file, and tiles should be of the same size in all tilesets (here 32x32)
  • Tiles will be saved as individual PNG files. Empty tiles will be omitted.

Here are some samples of tiles I used for my dataset:

2. Train your model:

  • Edit so that the paths match that of your dataset (images have to be power of 2)
  • Also adjust any settings as you want. The settings are detailed in the file
  • run using "python"

You should be patient as etting the first results can take some time. Here are some results during training:

3. Test your model:

  • Edit to match the path where you saved your model
  • Also adjust latent space dimension if required
  • run using "python" to generate some test images in your output folder
  • images will be saved to the same path as your model


You can’t perform that action at this time.