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

@davidrjonas
davidrjonas / flatmap.php
Last active May 3, 2024 21:29
Simple flatmap() or mapcat() for PHP 7
<?php
/**
* If you need something safer or more complete see https://github.com/lstrojny/functional-php,
* in particular, https://github.com/lstrojny/functional-php/blob/master/src/Functional/FlatMap.php
*
* @param Callable $fn Mapping function that returns an array
* @param array $array Data over which $fn will be mapped
* @return array
*/
@pgaskin
pgaskin / PrintRevealNotes.js
Last active May 3, 2024 21:23
Prints speaker notes for a reveal.js presentation.
/*
Prints speaker notes for a reveal.js presentation.
To print the notes, run the js function PrintRevealNotes()
You need to disable the pop-up blocker
Copyright 2016 Patrick G
http://geek1011.github.io
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@Softwave
Softwave / README.md
Last active May 3, 2024 21:22
Fibonacci Program

Fib

Simple fibonacci number calculator.

Usage: fib nth Fibonacci number

@astrojuanlu
astrojuanlu / navier_plate_fenics.py
Last active May 3, 2024 21:21
Navier plate in Python with FEniCS
# coding: utf-8
"""Simply supported rectangular plate on its four edges with FEniCS
Author: Juan Luis Cano Rodríguez <juanlu@pybonacci.org>
References
----------
* Timoshenko, Stephen, and S. Woinowsky-Krieger. "Theory of Plates and Shells".
New York: McGraw-Hill, 1959.
@insdavm
insdavm / WireGuard-site-to-site.md
Last active May 3, 2024 21:19
Accessing a subnet that is behind a WireGuard client using a site-to-site setup

WireGuard Site-to-Site

Accessing a subnet that is behind a WireGuard client using a site-to-site setup

Problem Summary

We want to access a local subnet remotely, but it is behind a NAT firewall and we can't setup port forwarding. Outgoing connections work, but all incoming connections get DROPPED by the ISP's routing policy.

Solution Summary

@xen
xen / check_hash.py
Last active May 3, 2024 21:19
telegram site auth
# implementation of Telegram site authorization checking algorithm
# for more information https://core.telegram.org/widgets/login#checking-authorization
import collections
import hmac
import hashlib
def check_string(d, token):
secret = hashlib.sha256()
secret.update(token.encode('utf-8'))

TL;DR

When Riot Games introduces the Vanguard anti-cheat to League of Legends, you should STOP playing and you should not install the anti-cheat when you get the pop-up. Vanguard is a kernel-level anticheat and these anticheats operate at a privilege level HIGHER THAN YOUR OWN. The anti-cheat can do things that even you can't do, without asking or letting you know. It's like Riot installing a camera in every room of your house and getting a copy of every key inside.

Here is just one example of what they can do: https://www.theregister.com/2013/11/20/esea_gaming_bitcoin_fine/

https://www.wired.com/2013/11/e-sports/

Who am I?

@nessex
nessex / upgrade-qidi-x-plusmax3.sh
Last active May 3, 2024 21:17
Script for updating a QIDI X-Plus3 / X-Max3 to latest Klipper, Moonraker, Fluidd etc.
#!/bin/bash
## upgrade-qidi-x-plusmax3.sh
##
## Usage:
##
## ssh -u mks {printer_ip}
## curl https://gist.githubusercontent.com/nessex/7b574fbe6d965439b773d922ca1b9e05/raw -sSF | bash
##
## OR:
##
@miguelmota
miguelmota / i3-cheat-sheet.md
Last active May 3, 2024 21:16 — forked from JeffPaine/i3-cheat-sheet.md
i3 Window Manager Cheat Sheet

i3 Window Manager Cheat Sheet

$mod refers to the modifier key (window/command or alt by default depending on config)

General

  • startx i3 start i3 from command line
  • $mod+<Enter> open a terminal
  • $mod+d open dmenu (text based program launcher)
  • $mod+r resize mode ( or to leave resize mode)
  • $mod+shift+e exit i3