-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoardViewer.html
58 lines (54 loc) · 1.4 KB
/
BoardViewer.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
<!DOCTYPE html>
<html>
<head>
<title>n-rooks solver</title>
<style type="text/css">
.square {
width: 30px;
height: 30px;
text-align: center;
}
.positive {
background-color: lightgrey;
}
.negative {
background-color: grey;
}
.inConflict{
background-color: red;
}
</style>
</head>
<body>
<script src="lib/jquery-1.8.3.js"></script>
<script src="lib/underscore.js"></script>
<script src="lib/backbone.js"></script>
<script src="src/Board.js"></script>
<script src="src/BoardView.js"></script>
<script src="src/solvers.js"></script>
<script>
// This function uses a board visualizer lets you view an interactive version of any piece matrix.
window.displayBoard = function(matrix){
$('body').html(
new BoardView({
model: new Board(matrix)
}).render()
);
};
$(function(){
// this is a pre-baked solution for n-queens in the n = 4 case, rendered to the screen using our handy visualizer.
displayBoard([
[0, 1, 0, 0],
[0, 0, 0, 1],
[1, 0, 0, 0],
[0, 0, 1, 0]
]);
var n = 4;
findNRooksSolution(n);
countNRooksSolutions(n);
findNQueensSolution(n);
countNQueensSolutions(n);
});
</script>
</body>
</html>