Skip to content

i-am-neon/fe-map-diffusion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fe-map-diffusion

Generating Fire Emblem GBA-style tactical maps with masked discrete diffusion.

Instead of placing tiles one-by-one, the model generates the entire map at once — starting from a fully masked grid and iteratively unmasking tiles over ~20 denoising steps, the same coarse-to-fine paradigm behind image diffusion models, adapted for small discrete grids.

Approach

Masked discrete diffusion (MDLM-style). Terrain tiles are categorical (plains, forest, mountain, water, wall, etc.), so continuous Gaussian noise doesn't apply. Instead:

  1. Forward process: Randomly replace tiles with [MASK] tokens according to a cosine noise schedule
  2. Reverse process: A Transformer encoder predicts what each [MASK] should be; unmask the most confident predictions and repeat

The denoiser is a standard Transformer encoder (4 layers, dim 128, 4 heads) operating over the flattened H×W grid. Each tile gets a summed embedding of its token ID, 2D positional encoding (row + col), and diffusion timestep.

Dataset: 78 maps extracted from Fire Emblem GBA ROMs, each a 2D grid of ~29 terrain types, padded to 42×43. No augmentation yet.

Project Structure

src/model.py       Transformer denoiser
src/diffusion.py   Cosine noise schedule, forward masking, iterative sampling
src/train.py       Training loop with W&B logging and sample visualization
src/generate.py    Standalone generation with temperature sampling
src/data.py        Dataset loading, padding, batching
viz/render.py      Terrain grid → color-coded image
configs/            Hyperparameters (YAML)

Status

Early stage — pipeline is end-to-end functional (train → generate → render). The model trains and produces samples, but with only 78 maps and no augmentation, outputs are not yet diverse. Next steps: data augmentation (rotations, flips, random crops), architecture tuning, and longer training.

Built With

PyTorch, Weights & Biases, Matplotlib

About

Masked discrete diffusion model for generating 2d game maps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors