-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerator.html
167 lines (139 loc) · 4.55 KB
/
generator.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<title>Generator</title>
</head>
<style>
table, th, td {
padding: 4px;
text-align: center;
border: 1px solid black;
border-collapse: collapse;
}
svg {
//display: block;
margin: auto ;
border: 1px solid black;
}
.centered {
text-align: center;
}
.blocked {
display: block ;
}
</style>
</head>
<script src="js/evnts.js"></script> <!-- required for callback registration-->
<script src="js/bldrs.js"></script> <!-- required for html/svg building -->
<script src="js/chess_base.js"></script>
<script src="js/puzzles.js"></script>
<script src="js/solver.js"></script>
<script>
function loadBoard() {
game= new Generator();
game.init();
var fixer = new Fixer(game);
fixer.fix();
return htmlForBoard(game.getBoard());
};
$(document).ready(function(){
$("#refresh").on("click", function(event){
$("#boardDisplay").html(loadBoard());
game.start();
});
});
CellType = "knight";
function setButtons() {
$(".btn-primary").addClass("btn-secondary");
$(".btn-primary").removeClass("btn-primary");
$("#" + CellType).removeClass("btn-secondary");
$("#" + CellType).addClass("btn-primary");
$("#boardDisplay").html(loadBoard());
game.start();
};
/*
* The page registers callbacks to have its elements
* refreshed when things change. These pull what they
* require from the gameDisplay object.
*/
$(document).ready(function(){
evnts.addCallback("refreshMap", function() {
$("#mapDisplay").html(gameDisplay.map);
});
evnts.addCallback("refreshStatus", function() {
$("#finish").html(gameDisplay.statusMessage);
});
evnts.addCallback("refreshSteps", function() {
$("#missteps").html(gameDisplay.missteps);
});
//after callbacks are registered, we start the game
$("#boardDisplay").html(loadBoard());
$(".typeButton").on("click", function(event){
CellType = event.currentTarget.id;
setButtons();
});
game.start();
});
</script>
<body>
<nav class="navbar navbar-default" style="margin-bottom:0px">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="..">
<img src="imgs/github_badge1.png" style="max-width:100%;max-height:100%" >
</a>
<p class="navbar-text navbar-right">
<a href=".." class="navbar-link">dmackinnon1.github.io</a>
</p>
</div>
</div>
</nav>
<br>
<div class="container-fluid">
<div class='row'>
<div class='col-sm-1'>
</div>
<div class='col-sm-10'>
<div class="page-header">
<h1>Tour Generator</h1>
</div>
<button id="refresh" class="btn btn-default">New Base Tour</button>
<br>
<div>
Using this page, you can explore how new possible paths are opened up by hiding the numbers on specific squares.
When a value on a square is hidden, alternate paths that preserve the remaining exposed numbers will be calculated.
You cannot hide the first square (square numbered 1), but you can hide any other cells. If you hide many cells, the
calculations to find alternate paths may start to take longer. The number of alternate paths varies depending on the
chess piece type that you choose. The piece represented by the circled "X" is a piece that follows the 'numbrix' movement
rules - moving up, down, left, and right. An additional type is provided - the asterix (*) represents a piece that can move
to any square - the graph of its available moves is the complete graph (K_64).
</div>
<br>
<div class="centered">
<div class="btn-group btn-group-lg " role="group">
<button type="button" id="king" class="btn btn-secondary typeButton"><span class='glyphicon glyphicon-king'></span></button>
<button type="button" id="knight" class="btn btn-primary typeButton"><span class='glyphicon glyphicon-knight'></span></button>
<button type="button" id="numbrix" class="btn btn-secondary typeButton"><span class='glyphicon glyphicon-remove-circle'></span></button>
<button type="button" id="complete" class="btn btn-secondary typeButton"><span class='glyphicon glyphicon-asterisk'></span></button>
</div>
</div>
<hr>
<h3><div id="boardDisplay" style="text-align=center">
</div>
</h3>
<hr>
<div id="missteps" style="text-align=center"></div>
<hr>
<div id="mapDisplay" display="block" style="text-align=center"></div>
<hr>
<br>
</div>
<div class='col-sm-1'>
</div>
</body>
</html>