Skip to content

Instantly share code, notes, and snippets.

View Johnicholas's full-sized avatar
💭
I may be slow to respond.

Johnicholas Hines Johnicholas

💭
I may be slow to respond.
View GitHub Profile
// a hub world corresponds to a partial order on levels
//
// an example play sequence is:
// 1. the player starts in the hub world,
// - which several open (or unlocked) doors and several closed (or locked) doors
// 2. the player chooses an open door, and plays through a level, and fails
// 3. the player is returned to the hub world
// 4. the player chooses the same open door, plays through the same level, and succeeds
// 5. the player is returned to the hub world, but there is a change:
@Johnicholas
Johnicholas / mark_and_recapture.js
Created April 13, 2015 12:38
mark and recapture for generative text
// This is using the "Bayesian" formula taken from
// http://en.wikipedia.org/wiki/Mark_and_recapture
// to provide a crude estimate of "how many" outputs the grammar might generate.
//
// As I understand it, it is quite easy to technically have infinite outputs,
// and this technique "wrongly" will always give a finite answer.
// However, informally, we want a lot of visible variety,
// and technically-infinite doesn't provide guidance towards
// more visible variety, but abundance will.
//
@Johnicholas
Johnicholas / doran_parberry.lua
Created October 8, 2014 00:13
Transliteration perl->lua of thgie's implementation of Doran and Parberry's procedural quest system
-- procedural quest generation
math.randomseed(os.time())
local DEPTH = 3
actions = {
goto = {
{ description = 'Just wander around and look',
sequence = { '>explore' }
},
@Johnicholas
Johnicholas / validity_one.cpp
Created May 25, 2012 16:38
Cleanest C++ code I've ever written is still verbose and ugly
// Based on validity.py which is copyright (c) Feb 2000, by Denys
// Duchier, Universitaet des Saarlandes
//
// Transliterated (badly) from Python to C++ by Johnicholas Hines,
// but with the two-continuation model changed to the one-continuation model.
// (The failure continuation is the C++ stack.)
#include <string>
#include <tr1/memory>
using std::tr1::shared_ptr;
@Johnicholas
Johnicholas / shift-reset.soar
Created April 7, 2012 19:08
Delimited Continuations in Lambda Calculus in Soar
# This is a lambda-calculus interpreter with shift and reset,
# an implementation of BRICS-RS-3-41 "An Operational Foundation for Delimited Continuations",
# by Biernacka, Biernacki, and Danvy.
#
# Mistakes, misunderstandings and terrible un-idiomatic Soar style by Johnicholas
#
#
# This is the grammar:
#
# A term can have a single outgoing ^reset leading to a reset.
@Johnicholas
Johnicholas / styling_architecture.js
Created February 25, 2012 17:57
Idea regarding styling architecture like CSS
// This is an example of a possible large-scale design idiom.
// (Basically the idea is to imitate cascading stylesheets).
//
// It's hard to give a small, comprehensible example of an
// idea intended to be useful at (medium to) large scale.
// No matter what you do, it's definitely overengineered.
// Sigh.
//
// Often, at the top of an app, or a big component,
// there is a wiring-things-together entity; it might be