Skip to content

Instantly share code, notes, and snippets.

View samclane's full-sized avatar

Sawyer McLane samclane

View GitHub Profile
# based on https://github.com/margonaut/CMU-to-IPA-Converter/tree/master
CMU_IPA_MAPPING = {
"B": "b",
"CH": "ʧ",
"D": "d",
"DH": "ð",
"F": "f",
"G": "g",
"HH": "h",
"JH": "ʤ",
@samclane
samclane / lorenz.py
Created April 18, 2023 13:38
Simple gui for visualizing the lorenz attractor
import tkinter as tk
from tkinter import ttk
import numpy as np
from scipy.integrate import solve_ivp
# Lorenz system equations
def lorenz_system(t, xyz, sigma, rho, beta):
x, y, z = xyz
return [sigma * (y - x), x * (rho - z) - y, x * y - beta * z]
import sys
import random
import time
import string
class AsciiCanvas:
width: int
height: int
fill_char: str
canvas: list[list[str]]
@samclane
samclane / charged_particle_sim.py
Created April 4, 2023 20:31
Another codon experiment. Made with help from GPT-4
import math
import time
import sys
import random
class AsciiCanvas:
width: int
height: int
fill_char: str
canvas: list[list[str]]
@samclane
samclane / simulation.py
Created April 3, 2023 17:32
Codon bouncing ball simulation
import sys
import time
import math
import random
class AsciiCanvas:
width: int
height: int
fill_char: str
@samclane
samclane / alpaca.Docker
Created March 20, 2023 15:42
Docker to run alpaca.cpp (hopefully)
# Use Ubuntu as the base image
FROM ubuntu:20.04
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
# Update and install dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
@samclane
samclane / ooda_loop.py
Created March 19, 2023 12:56
Implementation of OODA Loop (https://en.wikipedia.org/wiki/OODA_loop) in Langchain
from langchain import PromptTemplate
from langchain.llms import OpenAIChat
from langchain.chains import LLMChain, SequentialChain
from langchain.memory import ConversationSummaryMemory
import os
from config import openai_key
os.environ["OPENAI_API_KEY"] = openai_key
observe = """What are the current conditions or factors that are affecting Assistant? What data or information do we need to collect to understand them better?
History: {history}
@samclane
samclane / tkenstein.py
Created March 12, 2023 15:39
Wolfenstein-esque raycasting on a tkinter canvas
"""
First person shooter game in python using just tkinter canavas
Based on https://github.com/jdah/doomenstein-3d/blob/main/src/main_wolf.c
"""
import tkinter as tk
import math
SCREEN_WIDTH = 72
SCREEN_HEIGHT = 40
@samclane
samclane / chatgpt-firefighter-ca.py
Created December 6, 2022 14:09
An attempt at creating the "firefighter cellular automata" as described by ChatGPT
"""
Sure, here is a ruleset for a 2d cellular automaton with 6 states that can be used to simulate fire:
Each cell in the grid is in one of six states: "empty", "tree", "burning", "ash", "smoke", and "firefighter".
At each step in the simulation, the state of each cell is updated based on the states of its neighbors according to the following rules:
If a cell is empty and has exactly 3 tree neighbors, it becomes a tree. Otherwise, it remains empty.
If a cell is a tree and has 2 or more burning neighbors, it becomes burning. Otherwise, it remains a tree.
If a cell is burning and has 1 or more firefighter neighbors, it becomes ash. Otherwise, it becomes smoke.
@samclane
samclane / gol.js
Last active November 16, 2022 12:28
Attempt at game of life using Habitat
Habitat.registerEverything();
const pointer = getPointer();
defineGetter(pointer, "x", () => pointer.position[0]);
defineGetter(pointer, "y", () => pointer.position[1]);
const stage = new Stage();
const Square = struct({ x: 0, y: 0, width: 2, height: 2, color: GREY, isAlive: false, needsRedraw: true });