Skip to content

Instantly share code, notes, and snippets.

View lardratboy's full-sized avatar

Brad P. Taylor lardratboy

View GitHub Profile
@lardratboy
lardratboy / mosprite.hpp
Created August 9, 2026 21:28
mosprites at compile time
// mosprite.hpp — compile-time sprite synthesis and n-dimensional rasterisation.
//
// A C++20 transcription of the MoSprites NG pipeline (mosprites-ng.md) in which
// every stage parameter is a type. That is not decoration. Three things follow
// from moving the policy into the type system, and only the first is about speed:
//
// 1. The inner loop contains no branch on operator, order, or colour space.
// `if constexpr` deletes the untaken paths outright.
//
// 2. Dimension is a template parameter. ng §9 argues that the whole apparatus
@lardratboy
lardratboy / latticerules.js
Last active July 1, 2026 01:45
RulesEngine, templates and game variations, v 0.1.0
"use strict";
// ████ MATH EASING CURVES — intrinsically invertible pure functions ████
const EASE = {
cubicInOut: t => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2,
cubicOut: t => 1 - Math.pow(1 - t, 3),
backOut: t => {
const c1 = 1.70158;
const c3 = c1 + 1;
return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
@lardratboy
lardratboy / retro_sfx_manager.js
Created June 16, 2026 20:32
retro sound manager
// --- RETRO SOUND MANAGER ---
class RetroSoundManager {
constructor() {
this.audioContext = null;
this.masterGain = null;
this.enabled = true;
this.initAudio();
}
initAudio() {
@lardratboy
lardratboy / polyomino.js
Created June 8, 2026 23:36
D4 canonicalization and orientation analysis for polyominoes
/*
* polyomino.js — D4 canonicalization and orientation analysis for polyominoes.
*
* A polyomino is represented as an array of [row, col] integer pairs.
* No assumption about the grid it came from; coordinates can be any integers.
*
* Signatures are strings like "0,0|0,1|1,0" (an L-tromino), produced by
* normalizing cells to origin and sorting them lexicographically. Two shapes
* have the same signature iff they have the same cell layout at the same
* translation; they have the same CANONICAL signature iff they are related
@lardratboy
lardratboy / gendemodata.js
Created March 27, 2026 03:41
demo data generator scratchpad
// =============================================================================
// ENCODERS (CPU — for demo generation)
// =============================================================================
function fp16ToF32(u16){let s=(u16>>15)&1,e=(u16>>10)&0x1F,m=u16&0x3FF;if(e===0)return(s?-1:1)*Math.pow(2,-14)*(m/1024);if(e===31)return m?NaN:(s?-Infinity:Infinity);return(s?-1:1)*Math.pow(2,e-15)*(1+m/1024);}
function bf16ToF32(u16){let s=(u16>>15)&1,e=(u16>>7)&0xFF,m=u16&0x7F;if(e===0)return(s?-1:1)*Math.pow(2,-126)*(m/128);if(e===255)return m?NaN:(s?-Infinity:Infinity);return(s?-1:1)*Math.pow(2,e-127)*(1+m/128);}
function fp8E4M3ToF32(u8){let s=(u8>>7)&1,e=(u8>>3)&0xF,m=u8&0x7;if(e===0)return(s?-1:1)*Math.pow(2,-6)*(m/8);return(s?-1:1)*Math.pow(2,e-7)*(1+m/8);}
function fp8E5M2ToF32(u8){let s=(u8>>7)&1,e=(u8>>2)&0x1F,m=u8&0x3;if(e===0)return(s?-1:1)*Math.pow(2,-14)*(m/4);return(s?-1:1)*Math.pow(2,e-15)*(1+m/4);}
function fp4ToF32(u8){let s=(u8>>3)&1,e=(u8>>1)&0x3,m=u8&1;if(e===0)return(s?-1:1)*0.5*(m/2);r
/**
* Variable Bit-Depth Generator
* @param {string} shape - 'lorenz', 'thomas', 'noise'
* @param {number} depth - 8, 16, 32
* @param {num} number of points
* @param {littleEndian} true or false
*/
function uintShapeGenerator(shape, depth, num, littleEndian ) {
const compSize = depth / 8;
const buf = new ArrayBuffer(num * compSize * 3);
async function generateArtifactImage(signature) {
// Convert signature (e.g. "0101-1110-...") into a more descriptive prompt
const complexity = (signature.match(/1/g) || []).length;
const prompt = `A mystical cosmic artifact, a geometric totem floating in space.
The artifact has a ${complexity > 5 ? 'complex' : 'simple'} crystalline structure
inspired by the pattern: ${signature}. Neon bioluminescent colors,
ethereal nebula background, 8k, digital art, sci-fi relic.`;
try {
const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent?key=${apiKey}`, {
@lardratboy
lardratboy / quantize10_DataAs.js
Created December 22, 2025 22:50
quantized integer point cloud helper
// Data type configuration constants
const DATA_TYPES = {
int8: { size: 1, min: -128, max: 127, method: 'getInt8' },
uint8: { size: 1, min: 0, max: 255, method: 'getUint8' },
int16: { size: 2, min: -32768, max: 32767, method: 'getInt16' },
uint16: { size: 2, min: 0, max: 65535, method: 'getUint16' },
int32: { size: 4, min: -2147483648, max: 2147483647, method: 'getInt32' },
uint32: { size: 4, min: 0, max: 4294967295, method: 'getUint32' }
};
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>🎰 LATTICE SLOTS</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;600&display=swap');
* { box-sizing: border-box; margin: 0; padding: 0; }
@lardratboy
lardratboy / boxed-in.html
Last active December 22, 2025 22:38
boxed in game
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>BOXED IN - Instanced & Pooled</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;600&display=swap');
* { box-sizing: border-box; }