Skip to content

Instantly share code, notes, and snippets.

@5cover
Created August 28, 2025 14:01
Show Gist options
  • Select an option

  • Save 5cover/a2cba4ca5dd8ca7b0c06419448f4316d to your computer and use it in GitHub Desktop.

Select an option

Save 5cover/a2cba4ca5dd8ca7b0c06419448f4316d to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
int randexp() {
double lambda = 0.05;
double u = (double)rand() / RAND_MAX;
int sign = rand() % 2 == 0 ? 1 : -1;
int val = (int)(sign * log(1 - u) / -lambda);
if (val == 0) return sign; // force at least ±1
return val;
}
bool diesOfOldAge(int age) {
// check randomly against pool of common natural cause death ages.
// not systematic: the older, the likelier to return true, but in theory could live forever.
// also simulate healthcare by reducing risk the older you are, simulating eldercare/aging tech improvements
if (age < 50) return false;
if (age >= 130) return true;
// gentler logistic curve
double steepness = 0.20;
double midpoint = 90.0; // most people die around here
double prob = 1.0 / (1.0 + exp(-steepness * (age - midpoint)));
double roll = (double)rand() / RAND_MAX;
return roll < prob;
}
int notice(int value) {
// you can notice anything. most stuff is close to netral. some stuff is very good or bad. todo: exponential distribution
// if the current value is extreme, it amplifies itself. if the current value is mild, it neutralizes itself.
int fact = randexp();
return value + fact / 5; // smaller swings
}
int sit(int value) {
// sometimes it normalizes. sometimes it amplifies. todo:
double roll = (double)rand() / RAND_MAX;
if (roll < 0.1) {
return abs(value) > 10 ? -value/2 : -value; // big normalization event
}
else if (roll < 0.3) {
return -value / 4; // soft normalization: life catches up
} else if (roll < 0.6) {
return 0; // nothing changes
} else {
return randexp() / 2; // mild unexpected lurch
}
}
int create(int value) {
double roll = (double)rand() / RAND_MAX;
if (value == 0) {
// numb: nothing sticks
return 0;
}
if (roll < 0.2) {
// failure: effort drains you, the more invested you were, the more it hurts
return -(abs(randexp()) / 3); // fail hurts, but not catastrophically
} else if (roll < 0.6) {
// neutral: you made something, but it didn’t change you
return 0;
} else {
// success: amplifies your current trajectory
int boost = randexp();
return (value > 0) ? abs(boost) : -abs(boost);
}
}
int main() {
srand(time(NULL));
int age = 0;
int value = 1000; // initial value so it doesn't fail immediately
do {
// notice
value = notice(value);
// sit
value += sit(value);
// create
value += create(value);
// print artifact
printf("%d;%d\n", age, value);
} while (value > 0 && !diesOfOldAge(age++));
if (value > 0) {
puts("died of natural causes");
return 0;
} else {
puts("switched to residual prefrontal cortex activity early");
return 137;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment