-
Notifications
You must be signed in to change notification settings - Fork 0
/
busybvr4.htm
94 lines (90 loc) · 2.86 KB
/
busybvr4.htm
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
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>4-state 2-symbol busy beaver automaton</title>
<link rel='shortcut icon' type=image/x-icon href=data:image/x-icon;,>
<meta property='og:description' content='A computer theoretical Turing machine simulation that writes as much non-blank on its tape as possible in JavaScript0 on GemiWeb0' name='description'>
<meta name=viewport content='width=device-width, initial-scale=1'>
<meta name=referrer content=no-referrer>
<meta http-equiv=x-dns-prefetch-control content=off>
<meta name=color-scheme content='light dark'>
<meta http-equiv='Content-Security-Policy' content="default-src 'none'; font-src data: blob:; frame-src data: blob:; img-src data: blob:; manifest-src data: blob:; media-src data: blob:; style-src data: blob: 'unsafe-inline' 'unsafe-eval'; script-src 'unsafe-inline'; base-uri 'none'; form-action javascript:; navigate-to 'none';">
</head>
<body><h2
>Explanation</h2
>Simulates the 4-state busy beaver - a computer theoretical Turing machine that writes as much non-blank on its tape as possible.<p
><a target=_blank href=https://en.wikipedia.org/wiki/Busy_beaver
>en.wikipedia.org/wiki/Busy_beaver</a
><h2
>Requirements</h2
>You can install a web browser that supports at least JavaScript 1.0 (1995) to run this application or you may consider implementing a GemiWeb0 browser with JavaScript0 yourself according to the following specification:<p
><a target=_blank href=https://bkil.gitlab.io/gemiweb0
>bkil.gitlab.io/gemiweb0</a
><script>
'use strict';
function showTape(step, state, tape, i) {
var written = 0;
var label = 'ABCDh';
label = label.charAt(state);
var j = -1;
var htm = '';
while (14 > (j = j + 1)) {
if (j - i) {
htm = htm + ' ';
} else {
htm = htm + label;
}
if (tape[j]) {
htm = htm + '1';
written = written + 1;
} else {
htm = htm + '.';
}
}
return htm + ' #' + step + ' w' + written;
}
function run() {
var tape = new Array;
var step = 0;
var state = 0;
var i = 10;
var htm = '<pre role=img>' + showTape(step, state, tape, i);
while (4 > state) {
if (tape[i]) {
if (!state) {
i = i - 1;
state = 1;
} else if (!(state = state - 1)) {
tape[i] = 0;
i = i - 1;
state = 2;
} else if (!(state = state - 1)) {
i = i - 1;
state = 3;
} else {
tape[i] = 0;
i = i + 1;
state = 0;
}
} else {
tape[i] = 1;
i = i + 1;
if (!state) {
state = 1;
} else if (!(state = state - 1)) {
i = i - 2;
} else if (!(state = state - 1)) {
state = 4;
} else {
state = 3;
}
}
htm = htm + String.fromCharCode(10) + showTape(step = step + 1, state, tape, i);
}
document.write(htm + '</pre>');
document.close();
}
run();
</script
></body></html>