Skip to content

Instantly share code, notes, and snippets.

View Teggy's full-sized avatar
💯
100% busy shooting lecture videos...

Torsten Grust Teggy

💯
100% busy shooting lecture videos...
View GitHub Profile
@Teggy
Teggy / NaSchl.sql
Last active February 18, 2019 14:20
Traffic flow simulation based on a simple cellular automaton
-- Traffic flow simulation based on a simple cellular automaton
--
-- Based on a 1992 model by Kai Nagel and Michael Schreckenberg (NaSch),
-- also see:
-- http://www.christophschuette.com/blog/?p=50
-- http://www.thp.uni-koeln.de/~as/Mypage/traffic.html
-- Car model:
-- - ID: c
-- - position: x
@Teggy
Teggy / bricks.alg
Last active January 17, 2020 16:35
U Tübingen LEGO database in RelaX format
group: LEGO database
description[[The U Tübingen LEGO database]]
bricks = { piece:string, type:string, name:string, cat:number, weight:number, img:string, x:number, y:number, z:number
"87749","B","Lower Body with Tentacles","20","4.07","http://www.bricklink.com/PL/87749",NULL,NULL,NULL
"wampa","B","Wampa, Complete Assembly","147","31.33","http://www.bricklink.com/PL/wampa",NULL,NULL,NULL
"90981","B","Spider Web, Hanging","86","1.51","http://www.bricklink.com/PL/90981",NULL,NULL,NULL
}
-- A custom base type 'wildcard' that returns true on < comparisons,
-- no matter what. Otherwise acts like a 4-byte integer.
DROP TYPE IF EXISTS wildcard CASCADE;
CREATE TYPE wildcard;
CREATE FUNCTION wildcard_in(s cstring) RETURNS wildcard
LANGUAGE internal IMMUTABLE AS 'int4in';
CREATE FUNCTION wildcard_out(d wildcard) RETURNS cstring
LANGUAGE internal IMMUTABLE AS 'int4out';
@Teggy
Teggy / README.md
Last active November 21, 2022 21:30
Simple cellular-automata-based liquid flow simulation, implemented in SQL

Simple cellular-automata-based liquid flow simulation, implemented in SQL

Loosely based on https://www.reddit.com/r/cellular_automata/comments/6jhdfw/i_used_1dimensional_cellular_automata_to_make_a/. The SQL code in fluid.sql should work with any contemporary version of PostgreSQL.

  1. In fluid.sql, uncomment one of the few initial fluid container scenarios (they start with \COPY input(cells) FROM stdin). A sample container has already been uncommented for you. Feel free to create your own.

  2. Run the SQL code, e.g., via