Published unlisted
Edited
Jun 24, 2018
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
aspects = ({
names: ['lantern', 'heart', 'knock', 'edge', 'moth', 'winter', 'forge', 'grail'],
colors: ['#ffd050', '#ffacac', '#b450ff', '#a1be74', '#dcdcdc', '#cfe8f4', '#ff7900', '#bb3434'],
// edge: #91be84, lantern: #ffdc00, knock: #b400ff
lack: ['inadequate', 'restless', 'ignorant', 'unprepared', 'forgetful', 'mortal', 'weak', 'thirsting'],
mood: ['22', '11', '20', '10', '00', '01', '12', '21'],
tip: ['glorious', 'determined', 'seeking', 'hard', 'primeval', 'cold', 'unflinching', 'hungry'],
fear: ['enrapt', 'crushed', 'in too deep', 'sliced apart', 'found out', 'forgotten', 'burned', 'used'],
count: 8 // the canonical choice
})
Insert cell
Insert cell
Insert cell
function take_n(arr, n) {
let bag = arr.slice(), // shallow copy
m = bag.length, i,j, tmp // https://www.frankmitchell.org/2015/01/fisher-yates/
for (i = m-1; i >= m-n; --i) {
j = Math.floor(Math.random()*(i+1)) // shuffle into back of bag
tmp = bag[i]; bag[i] = bag[j]; bag[j] = tmp
}
return bag.slice(-n)
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof loyalty = {
let permuted = take_n(aspects.lack, aspects.count),
idxs = [0,3,6,7].map(i => permuted.indexOf(aspects.lack[i]))
return multiselect(permuted, idxs, "urself")
}
Insert cell
ending = (choices) => {
let [key,res] = score(choices),
bar = Math.max(...res),
ret = key.filter((u,i) => res[i] == bar)
// return the most salient endings
return bar >= 2 ? ret : []
// key[res.indexOf(bar)]
}
Insert cell
Insert cell
score = (choices) => {
function hits(...targets) {
return targets.reduce((sum, i) => sum + choices.includes(i), 0)
} // return aspects.secrets
// munge the codewheels back to indexes
let xIn = (s) => (u) => aspects[s].indexOf(u),
a = piety.map(xIn('tip')),
b = aster.map(xIn('fear')),
c = loyalty.map(xIn('lack'))
return [['filial piety', 'star-crossedness', 'order-loyalty'],
[hits(...a), hits(...b), hits(...c)]]
// [hits(1,2,4,6), hits(2,3,5,7), hits(0,3,6,7)]]
// md`Ann observes that it is not easy to write very many specific endings, nor for a cast whose state is variable. Perhaps we should try the fan-in, and generate from the end to the beginning.`
// return 'Combinatorial morass!'
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {select, text, slider, radio} from "@jashkenas/inputs"
Insert cell
import {multiselect, cycling, fadein} from "@jazztap/spinner-inputs"
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more