-
Notifications
You must be signed in to change notification settings - Fork 0
/
busybvr.htm
119 lines (112 loc) · 3.5 KB
/
busybvr.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
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
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>2 to 6 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 2 to 6 state busy beaver - a Turing machine that writes as much non-blank on its tape as possible. The 5 and 6 state ones are capped. Optimality has not been proven for the 6-state one yet.<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 stateLabel(state, quit) {
var label = 'h';
if (quit > state) {
label = 'ABCDEF';
label = label.charAt(state);
}
return label;
}
function showTape(step, state, tape, i, mn, mx, quit) {
var written = 0;
var label = stateLabel(state, quit);
var j = mn - 1;
var htm = String.fromCharCode(10);
while (mx >= (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 + ' @' + i;
}
function run(rules, from, to) {
var step = 0;
var state = 0;
var tape = new Array;
var i = 10;
var mn = 0;
var mx = i;
var quit = rules.length >> 1;
var htm = '<pre role=img>' + quit + '-state:';
var j;
var k;
if (!from) {
j = -1;
while (rules.length > (j = j + 1)) {
k = rules.charCodeAt(j) & 31;
htm = htm + ' ' + stateLabel(j >> 1, quit) + (j & 1) + ':' + (k & 1);
if (k & 2) {
htm = htm + 'R';
} else {
htm = htm + 'L';
}
k = stateLabel(k >> 2, quit);
htm = htm + k;
}
k = showTape(step, state, tape, i, mn, mx, quit);
htm = htm + k;
}
while ((quit > state) && (!to || (to > step))) {
step = step + 1;
state = rules.charCodeAt(state + state + (tape[i] || 0)) & 31;
tape[i] = state & 1;
i = (i - 1) + (state & 2);
state = state >> 2;
if (mn > i) {
mn = i;
}
if (i > mx) {
mx = i;
}
if (!from || (step >= from)) {
k = showTape(step, state, tape, i, mn, mx, quit);
htm = htm + k;
}
}
htm = htm + '</pre>';
return htm;
}
function init() {
document.write(
run('GEAK', 0, 0) +
run('GOJGIA', 0, 0) +
run('GEAHSMOB', 0, 0) +
run('GIKGOPAMW@', 0, 999) +
run('GLKVIAP[UFJR', 0, 999));
document.close();
}
init();
</script
></body></html>