-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtower.html
More file actions
75 lines (75 loc) · 3.29 KB
/
tower.html
File metadata and controls
75 lines (75 loc) · 3.29 KB
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
<!DOCTYPE html><html>
<head>
<!-- (C) Wilbert van Ham 2017-2019, released under GNU affero public license -->
<meta charset="UTF-8">
<title>Towers of Hanoi/ tower of Londen, setup</title>
<script>
window.onload = init
function init(){
// for reload
setNDisk(document.getElementById('nDiskUsed').value)
}
function setNDisk(n){
// set number of disks
document.getElementById('startPosition').value = ""
document.getElementById('endPosition').value = "||"
document.getElementById('maxMove').value = 2**n-1
for(var i=0; i<n; i++) {
document.getElementById('startPosition').value += i
document.getElementById('endPosition').value += i
}
document.getElementById('startPosition').value += "||"
}
function addToStack(event){
// add current game to stack
// add period if necessary
var s = ""
if (document.getElementById('games').value)
s =","
s += document.getElementById('startPosition').value
s += "."
s += document.getElementById('endPosition').value
s += "."
s += document.getElementById('maxMove').value
document.getElementById('games').value += s
document.getElementById("start").disabled = false
}
function emptyStack(){
document.getElementById("games").value = ""
document.getElementById("start").disabled = true
}
function changeAction(event){
// go to separate form for ppn
var form = document.getElementById('gameForm')
form.action = event.target.options[event.target.options.selectedIndex].value;
}
</script>
</head>
<body>
<h1>Towers of Hanoi/ tower of Londen, setup</h1>
<form id=gameForm action="hanoi.svg">
<table>
<tr><th>participant</th><td><input name=ppn type=number min=0 value=0></td></tr>
<tr><th>template</th><td><select onchange="changeAction(event)" >
<option value="hanoi.svg" selected>disks</option>
<option value="london.svg">spheres</option>
</select></td></tr>
<tr><th>debug</th><td><input name=debug type=checkbox></td></tr>
<tr><th>show arrows</th><td><input name=arrows type=checkbox></td></tr>
<tr><th>show number of games</th><td><input name=nogames type=checkbox></td></tr>
<tr><th>hanoi constraint:</th><td><input name=hanoi type=checkbox checked></td></tr>
<tr><th>do not repeat attempt when above move limit:</th><td><input name=noErrorRepeat type=checkbox checked></td></tr>
<tr><th>maximum tower height:</th><td><input name=maxHeight placeholder=777></td></tr>
<tr><th>maximum time (s):</th><td><input name=maxTime></td></tr>
<tr><th>Setup Game:</h></tr>
<tr><th></th><th>number of disks (standard Hanoi)</th><td><input form=dummy id=nDiskUsed name=nDiskUsed value=7 type=number min=1 max=7 onchange='setNDisk(this.value)'></td></tr>
<tr><th></th><th>start position:</th><td><input form=dummy id=startPosition placeholder="012||"></td></tr>
<tr><th></th><th>end position:</th><td><input form=dummy id=endPosition placeholder="||012"></td></tr>
<tr><th></th><th>maximum moves:</th><td><input form=dummy id=maxMove></td></tr>
<tr><th></th><th>alter stack:</th><td><input type=button value="add game to stack" onclick='addToStack(event)'><input type=button value="empty stack" onclick='emptyStack()'></td></tr>
<tr><th>game stack:</th><td><input id=games name=games></td></tr>
<tr><th>go</th><td><input id="start" type=submit value="start games" disabled></td><!--<td colspan=13><input id="ppn" type=button onclick="ppnForm(event)" value="ppn form"></td>--></tr>
</table>
</form>
</body>
</html>