-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadditionMachine.html
82 lines (60 loc) · 1.57 KB
/
additionMachine.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
<html>
<head>
<script type="text/javascript" src="js/jquery.min.js" /></script>
<script type="text/javascript">
var output = { state: "A", position:0, tape:[1,1,1,0,1,1,1,1,1] };
var stateTable = {
"A": {
1: [ 1, "right", "A" ],
0: [ 0, "right", "B" ]
},
"B": {
1: [ 0, "left", "C" ],
0: [ 0, "right", "B" ]
},
"C": {
1: [ 1, "left", "D" ],
0: [ 0, "left", "C" ]
},
"D": {
1: [ 1, "left", "D" ],
0: [ 1, "right", "A" ]
}
};
$(document).ready(function(){
var m = new TuringMachine(output, stateTable);
m.drawRow();
$("#step").click(function(){
m.step();
});
$("#run").click(function(){
m.run();
});
$("#pause").click(function(){
m.pause();
});
drawStateTable();
});
</script>
<script type="text/javascript" src="js/turingMachine.js" /></script>
<style type="text/css">
table {border:1px solid black;}
table td {border:1px solid black;}
#stateTable {float:left;}
#outputTable {float:left;margin-left:20px;}
div.step {border:1px solid #ccc;float:left;}
div.state {border:1px solid #ccc;float:left;}
div.tapeRow {clear:left;}
div.tapeItem {border:1px solid #ccc;float:left;}
</style>
</head>
<body>
<button type="button" id="step">step</button>
<button type="button" id="run">run</button>
<button type="button" id="pause">pause</button>
<div id="stepNum">0</div>
<div id="currentState">Current State: A Read: - Write: -</div>
<div id="stateTable"></div>
<div id="outputTable"></div>
</body>
</html>