Tip
Everything here is browsable as a site: tewf.github.io/after-hours Every project on one page, with the animations and charts at full size, and the tax report readable in the browser rather than downloadable as a PDF.
What I build when I am bored. Nobody assigned any of it and none of it is coursework: it is what I do with a free evening, in machine learning, computer algebra and applied mathematics.
Each folder stands alone, with its own README and its own dependencies. Every number below is produced by code in this repository, and CI reruns the checks on every push.
| Flappy Bird from raw pixels A DQN and a REINFORCE agent that see nothing but the rendered frame. No position, no velocity, no pipe coordinates. 12.21 pipes per episode over 100 greedy episodes, best 61, trained in 23 minutes on one RTX 4060. PyTorch, Gymnasium, Pygame |
|
| A 3-SAT solver over GF(2) Clauses become polynomials, triangular Gröbner-style elimination propagates, branching finishes. Every distinct monomial becomes an unknown, and the whole system becomes a matrix. 0 wrong verdicts on 500 instances checked against exhaustive search, and it says plainly which half of it does the work. Python, PySAT for cross-checking |
|
| Sorting algorithms in 3D Bubble and merge sort keyframed and rendered through Blender's Python API, so the access pattern is something you watch rather than read. 306 and 206 events, keyed out to 1161 and 841 frames at 1080p24. The previews here are the earlier render, from before the timing moved out of the algorithm. Blender 5.2, bpy |
|
| Integer programming, exactly A two-phase simplex in exact rationals, then branch and bound on whatever it leaves fractional. Nothing is ever a float, so a bound is a fact about the programme rather than about the arithmetic. 200 random programmes settle to the same optimum as an enumeration of every whole point in the box. The knapsack above takes 9 nodes. Python, fractions |
|
| Matrix algorithms from scratch An FFT, a determinant through the Schur complement, an exact integer inverse and a trace that never forms the product. NumPy is the oracle, never the implementation. 11 checks against NumPy, matching to 1e-13. The inverse is exact rather than nearly right. Python, NumPy |
|
| The French income tax, modelled Where does an extra euro of gross salary stop being worth much? Exponential fits per bracket, then the Lambert W function to find where the effective rate stops accelerating. The tipping point is 59 800 EUR gross a year. SciPy, Quarto |
The lesson that cost the most time here, and the one that transfers. The Flappy Bird agent plateaued and no hyperparameter moved it. The bird is yellow, the sky is light blue, and the two are nearly equiluminant, so the luminance greyscale every Atari pipeline uses was giving the bird 22 levels of contrast out of 255 while the obstacles got 64. Taking the blue channel instead gives 181.
Same network, same hyperparameters, same seed: greyscale needed 200k steps to clear its first pipe and never passed 0.80; the blue channel cleared one at 50k and passed ten at 250k. It looked like a tuning problem for a long time, and it was never a tuning problem. The write-up is here, with the run that failed and a scaling bug of mine that made one loss term 224 times another.
cd <folder>
pip install -r requirements.txtEach folder's README says what to run. The Blender scripts load in Blender's Scripting workspace or render headless from the command line. Trained weights and the full-resolution renders are attached to the latest release rather than committed, so a clone stays small.
How the numbers above were checked for stability, written on 2026-11-04, after the published runs and not before them: no protocol, prediction or deviation file existed when they were made, so none of this is a pre-registration.
Environment. A fresh conda env, Python 3.11, numpy==2.4.6, matplotlib,
and python-sat (the PySAT cross-check). CPU only; no GPU was used.
Command and seeds. python rerun_seeds.py <job>, jobs listed in the file.
Five runs per number, k = 0 to 4. Where a script commits its seeds, run 0 uses them, so the published number is one of the five and runs 1 to 4 are new.
Seeds: test_bruteforce.py batches 10k+1, 10k+2, 10k+3; visualise.py
seed0 = 1000 + 10000k; test_linear_algebra.py default_rng(k);
test_integer_programming.py Random(20260822 + k); the sorts 7 + k.
Spread is the sample standard deviation (n-1), with the minimum to maximum.
What counts as agreement. The oracles the tests already name: exhaustive
search or Minisat22 for the SAT solver (0 wrong verdicts, 0 invalid assignments),
enumeration for branch and bound (0 disagreements), numpy for the matrix code.
| Number as published | Where | Published | Five seeds: mean (sd), min to max |
|---|---|---|---|
| wrong verdicts, 500 instances against exhaustive search | SAT solver | 0 | 0 (0), 0 to 0 |
| invalid assignments, same 500 | SAT solver | 0 | 0 (0), 0 to 0 |
| unsound UNSAT claims by the elimination, same 500 | SAT solver | 0 | 0 (0), 0 to 0 |
| unsatisfiable instances in the n=12 sweep (m/n 2 to 7, 60 per ratio) | SAT solver | 272 | 270.2 (7.7), 260 to 279 |
| of those, caught by the elimination alone | SAT solver | 0 | 0 (0), 0 to 0 |
| satisfiable fraction at m/n = 3.0, n=12 | SAT solver | 100% | 99.7% (0.7), 98.3% to 100% (one run had 59 of 60) |
| first sweep ratio with under half satisfiable, n=12 | SAT solver | right of 4.26 | 5.1 (0.2): 5.0 in four runs, 5.5 in one |
| verdict mismatches against Minisat22, n=20 m=60, 500 instances per run | SAT solver | 0 (of 20 000) | 0 (0), 0 to 0 |
| systems the elimination alone calls UNSAT, same | SAT solver | 0.00% | 0 (0), 0 to 0 |
| 11 checks against numpy | Linear algebra | 11 of 11 | 11 (0), 11 to 11 |
fft_1d against numpy.fft, n=64, max absolute error |
Linear algebra | "1e-13" | 5.8e-15 (1.0e-15), 4.8e-15 to 7.1e-15 |
A @ B through the FFT, n=16, max relative error |
Linear algebra | "1e-16" | 1.1e-16 (1.9e-17), 8.9e-17 to 1.4e-16 |
| determinant through the Schur complement, n=16, relative error | Linear algebra | "1e-13" | 1.9e-8 (4.3e-8), 5.2e-14 to 9.5e-8; within 1e-13 in two runs of five, median 5.7e-13 |
| disagreements with enumeration, 200 programmes | Integer programming | 0 | 0 (0), 0 to 0 |
| bubble sort events, 20 bars | Sorting | 306 | 308.2 (19.9), 277 to 326; seed 7 gives 306 |
| merge sort events, 16 bars | Sorting | 206 | 204.6 (1.5), 203 to 206; seed 7 gives 206 |
The determinant row is the one that moves: the README's "matches to 1e-13 at n=16" holds for some matrices and is off by up to six orders of magnitude for others (the random 16 x 16 draws differ in conditioning), so the figure is a best case, not a typical one. The two event counts are properties of the random input that seed 7 draws, not constants of the algorithm.
- Flappy Bird, every number. One training run each (23 minutes; five per arm
is about two hours), so each is marked one seed in
Flappy_Bird_CNN/README.md, with the spread its own variance allows, a power line and the command for a future run. - Deterministic results with no random input: 9, 3 and 1 nodes and the optima 44, 3 and 34 of the integer programmes, and the 59 800 EUR tipping point. A rerun returns the same value.
- No committed script produces them: 285 unsatisfiable instances with 1 flagged (n 10 to 14), 258 for the row-reduction variant, 0.00% resolved at n=20 m=60, and about 99.95% satisfiable at m/n = 3.0. They stay as published, unchecked here.
- The protocol is written after the published runs, not before.
- The 20 000-instance PySAT cross-check was rerun at 500 instances per seed, not 20 000: at the measured 0.28 s an instance, 5 x 20 000 is about 8 hours, past the 30 minutes allowed for a run.
- Failures are counted per run rather than asserted, so one would be a number, not a stop.
- The three error sizes and the PySAT run have no committed seeds to repeat:
they use
default_rng(1000 + k)andrandom.seed(12345 + k), so run 0 for them is new, not the published run.