Skip to content

Instantly share code, notes, and snippets.

View magicoal-nerb's full-sized avatar
💭
leelee,e

magical_noob magicoal-nerb

💭
leelee,e
View GitHub Profile
@magicoal-nerb
magicoal-nerb / bktree.luau
Last active November 12, 2025 09:02
burkhard keller tree
--!strict
-- BK trees are used for fast string lookup queries
-- And yea u have to use levenshtein
-- Basically, I just knocked down a few constants
-- so it is marginally faster than most implementations.
-- But, asymptotic performance is basically the same so yeah
-- https://gist.github.com/magicoal-nerb/6c91120e671d557de59e6d87e6617868
--!strict
-- yet another queue implementation :P
-- magicoal_nerb
local Queue = {}
Queue.__index = Queue
export type Queue<T> = typeof(setmetatable({} :: {
data: { T },
--!strict
local Set = {}
Set.__index = Set
export type Set<T> = typeof(setmetatable({} :: {
data: { [T]: boolean },
}, Set))
function Set.new()
@magicoal-nerb
magicoal-nerb / Bvh.luau
Created October 15, 2025 05:45
very basic bvh
--!strict
-- yet another bvh implementation :P
-- magicoal_nerb
local Queue = require("./Queue")
local Bvh = {}
Bvh.__index = Bvh
@magicoal-nerb
magicoal-nerb / PriorityQueue.luau
Created July 25, 2025 06:31
priority queue i guess
--!strict
-- PriorityQueue.lua
-- me when the queue is my priority
-- also made with lectures from mit ocw
-- magicoal_nerb/poopbarrel
local PriorityQueue = {}
PriorityQueue.__index = PriorityQueue
@magicoal-nerb
magicoal-nerb / Avl.luau
Last active November 13, 2025 00:39
avl tree
--!strict
-- AVL Tree implementations based on the mit ocw lecture videos
-- poopbarrel/magicoal_nerb :^)
local Queue = require("./Queue")
local Avl = {}
Avl.__index = Avl
@magicoal-nerb
magicoal-nerb / Stack.lua
Created July 21, 2025 03:39
stack in luajit
-- Stack.lua
-- Last in, first out
-- poopbarrel/magicoal_nerb :^)
local Stack = {}
Stack.__index = Stack;
function Stack.new(capacityPow)
local mask = bit.lshift(1, capacityPow) - 1
-- create an array beforehand so lua doesn't
@magicoal-nerb
magicoal-nerb / Xml.lua
Last active July 21, 2025 03:42
xml parser in luajit
-- Xml.lua
-- Parses xml files
-- poopbarrel/magicoal_nerb :^)
-- This parser makes a few assumptions about our data:
-- * element tags are not separated by whitespace
-- * no comments
local Stack = require("Stack")
local ffi = require("ffi")
@magicoal-nerb
magicoal-nerb / Chunk.luau
Created July 21, 2025 03:20
binary greedy mesher in luau
--!strict
--!native
-- Chunk.luau
-- Uses a binary greedy mesher to chunk
-- everything together.
-- poopbarrel/magicoal_nerb
local CHUNK_FACES: { Vector3 } = {
Vector3.xAxis,
@magicoal-nerb
magicoal-nerb / quakec-bhop-rbx.luau
Last active November 3, 2025 19:44
really simple quake movement in roblox
--!strict
-- another quake movement reimplementation i suppose
-- magicoal_nerb :P
-- Physics
local XZ: Vector3 = Vector3.new(1.0, 0.0, 1.0)
local CAPSULE_FLOOR_ANGLE: number = 0.7
-- Convars