-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ch1_Stochastic_Ships.html
132 lines (126 loc) · 3.67 KB
/
Ch1_Stochastic_Ships.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!--
Stochastic Texts reimplementation
copyright (c) 2014 Nick Montfort <nickm@nickm.com>
based on a 1959 program (Stochastische Texte) by Theo Lutz
the text is a translation of Lutz's German text by Helen MacCormack
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-->
<style type="text/css">
/* <![CDATA[ */
body {
background:#000;
color:#ccc;
margin:0 0 0 18pt;
font-family:Optima, sans-serif;
font-size:16pt;
}
a {
color:#117;
text-decoration:none;
}
#main {
padding-top:18px;
width:70%;
}
#main div {
font-weight:bold;
padding-bottom:9px;
}
#info {
top:0;
right:0;
bottom:0;
position:absolute;
height:100%;
width:25%;
color:#333;
background:#999;
margin-left:6px;
border-left:thin #000 solid;
border-bottom:thin #000 solid;
padding:9px;
font-size:80%
}
/* ]]> */
</style>
<script type="text/javascript">
var t = 0,
subjects = ['COOK', 'JANSZOON', 'CABOT', 'VASCO DA GAMA', 'PONCE DE LEON', 'MAGELLAN',
'PIZARRO', 'VESPUCCI', 'ERIKSSON', 'SEA', 'OCEAN', 'LAND', 'SHIP',
'RIVER', 'MAP', 'CHART'],
predicates = ['CLASSICAL', 'EXPLORATORY', 'SEARCHING', 'UNCERTAIN', 'LOST', 'OTHER',
'FAR', 'UNKNOWN', 'KNOWN', 'DEEP', 'MAPPING', 'EXPLOITING', 'EXAMINING',
'STOLEN', 'THEORETICAL', 'SAILING'],
conjunctions = [' AND ', ' OR ', ' THEREFORE ', '. ', '. ', '. ', '. ', '. '],
operators = ['A', 'EVERY', 'NO', 'NOT EVERY'];
function rand_range(maximum) {
"use strict";
return Math.floor(Math.random() * (maximum + 1));
}
function choose(array) {
"use strict";
return array[rand_range(array.length - 1)];
}
function phrase() {
"use strict";
var text = choose(operators) + ' ' + choose(subjects);
if (text === 'A EYE') {
text = 'AN EYE';
}
return text + ' IS ';
}
function litany() {
"use strict";
var last, text, main = document.getElementById('main');
if (25 > t) {
t += 1;
} else {
main.removeChild(document.getElementById('main').firstChild);
}
last = document.createElement('div');
text = phrase() + choose(predicates) + choose(conjunctions);
text = text + phrase() + choose(predicates) + '.';
last.innerHTML = text;
main.appendChild(last);
}
function produce_litany() {
"use strict";
litany();
setInterval(litany, 2000);
}
</script>
<title>Stochastic Texts</title>
</head>
<body onload="produce_litany();">
<div id="info">
<h2>Stochastic Texts</h2>
<h3>Theo Lutz</h3>
1959<br />
Zuse Z22<br />
ALGOL 58<br />
<br />
Translated by<br />
Helen MacCormack<br />
<br />
Reimplemented by<br />
<a href="http://nickm.com">Nick Montfort</a><br />
for <a href="http://nickm.com/memslam/">Memory Slam</a><br />
Also: a <a href="stochastic_texts.py">Python 2</a> version
</div>
<div id="main"></div>
</body>
</html>