Skip to content

Instantly share code, notes, and snippets.

@Putnam3145
Putnam3145 / life.d
Last active March 15, 2019 10:54
Generic programming lifelike cellular automata in D
private struct LifeLikeRule
{
ubyte notZero;
bool zero;
this(ushort initializer)
{
notZero=cast(ubyte)(initializer>>1);
zero=initializer&1;
}
pure ushort fullRule()
@Putnam3145
Putnam3145 / sorting.d
Created June 7, 2020 20:39
Some programming junk food. Felt like implementing a parallel quicksort and was baffled at how fast it is.
import std.stdio;
import std.traits : isOrderingComparable;
import std.range;
import std.algorithm.sorting;
import std.algorithm.mutation;
@Putnam3145
Putnam3145 / Dialogue Box.tscn
Created July 28, 2020 05:49
A dialogue box for Godot.
[gd_scene load_steps=2 format=2]
[sub_resource type="GDScript" id=1]
script/source = "extends PopupPanel
\"\"\"
The run function expects an array, containing a series of strings or modifiers.
A string will be displayed one letter at a time, with the current delay,
using the current talk sound.
@Putnam3145
Putnam3145 / maxagecheck.lua
Last active July 28, 2021 01:45
gives you the normalized death-by-max-age times in buckets for every hist fig in the world in DF, to test the distribution thereof (it's linear)
utils = require('utils')
local validArgs = utils.invert({
'printAll',
'bucketSize'
})
local args = utils.processArgs({...}, validArgs)
local bucketSize = args.bucketSize or 0.125
@Putnam3145
Putnam3145 / gaystats.lua
Created April 15, 2022 01:18
Gives statistics regarding relationships in worldgen (how many people had relationships at all, how many are hetero, how many are homo, and so on)
-- Gives statistical info on the prevalence of homosexual relationships
local help = [====[
gaystats
======
Shows the sexual orientation of all historical figures, as well as whether they took lovers of the same or opposite sex.
Options:
:-allowAllRaces: Checks races with modded orientations, too (by default, it only checks races with default orientation)