Skip to content

Instantly share code, notes, and snippets.

Generating Procedural Game Worlds with Wave Function Collapse

Wave Function Collapse (WFC) by @exutumno is a new algorithm that can generate procedural patterns from a sample image. It's especially exciting for game designers, letting us draw our ideas instead of hand coding them. We'll take a look at the kinds of output WFC can produce and the meaning of the algorithm's parameters. Then we'll walk through setting up WFC in javascript and the Unity game engine.

sprites

The traditional approach to this sort of output is to hand code algorithms that generate features, and combine them to alter your game map. For example you could sprinkle some trees at random coordinates, draw roads with a brownian motion, and add rooms with a Binary Space Partition. This is powerful but time consuming, and your original vision can someti

@behrtam
behrtam / app.py
Created August 19, 2017 09:43
Flask Injecting Request Information – still uses old format
import logging
from flask import Flask, request
from flask.logging import default_handler
class RequestFormatter(logging.Formatter):
def format(self, record):
record.url = request.url
record.remote_addr = request.remote_addr
@NaveenDA
NaveenDA / List-of-search-engine.json
Created July 5, 2017 05:47
List of Search Engine in Json Format
[
{
"name": "Google",
"url": "http:\/\/www.google.com"
},
{
"name": "Bing",
"url": "http:\/\/www.bing.com"
},
{
@Vexs
Vexs / quickpoll.py
Created July 4, 2017 21:08
Simple polling function for a discord.py discord bot
import discord
from discord.ext import commands
class QuickPoll:
""""""
def __init__(self, bot):
self.bot = bot
casey:~/ $ cat .zshenv .zshrc
# zshenv
if [ -d "/usr/local/go" ]; then
export PATH=/usr/local/go/bin:$PATH
fi
if which go &> /dev/null; then
export GOPATH=$(go env GOPATH)
fi
@linw1995
linw1995 / gif2png.go
Last active July 17, 2018 02:00
Golang pkg "image/gif" cookbook.
package main
import (
"fmt"
"image"
"image/draw"
"image/gif"
"image/png"
"os"
"strings"
global:
scrape_interval: 60s
external_labels:
monitor: 'example'
rule_files:
- /etc/prometheus/config/*.rules
scrape_configs:
@jacoby
jacoby / coffee.R
Created May 8, 2017 15:51
R program that generates a calendar heatmap of my coffee intake over several years
#!/usr/bin/Rscript
# Cairo - for creating images outside of X
# ggplot2 - the MAGIC
# RMySQL - for interacting with the MySQL database
# yaml - for storing database credentials
suppressPackageStartupMessages( require( "Cairo" , quietly=TRUE ) )
suppressPackageStartupMessages( require( "ggplot2" , quietly=TRUE ) )
suppressPackageStartupMessages( require( "RMySQL" , quietly=TRUE ) )
@wiredprairie
wiredprairie / golang_contextWithTimeout.go
Last active September 29, 2020 13:26
Golang context.WithTimeout Demo
package main
import (
"context"
"fmt"
"time"
)
func main() {
wait := make(chan bool)
@jgamblin
jgamblin / slackspotify.sh
Created April 19, 2017 01:10
A Script To Set Current Spotify Song As Slack Status
#!/bin/bash
APIKEY="From Here https://api.slack.com/custom-integrations/legacy-tokens"
SONG=$(osascript -e 'tell application "Spotify" to name of current track as string')
URLSONG=$(echo "$SONG" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"')
while true
do
curl -s -d "payload=$json" "https://slack.com/api/users.profile.set?token="$APIKEY"&profile=%7B%22status_text%22%3A%22"$URLSONG"%22%2C%22status_emoji%22%3A%22%3Amusical_note%3A%22%7D" > /dev/null
sleep 60
done