/
trainsearch.html
82 lines (78 loc) · 3.08 KB
/
trainsearch.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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$(".help").toggle();
});
var worker;
function searchForDeadlocks() {
if (typeof worker !== "undefined") worker.terminate();
$("#output").empty();
function print(msg) {
$("#output").append(msg);
}
// avoid locking up the interface
worker = new Worker("trainsearch.js");
worker.onmessage = function(e) { print(e.data); };
var pathstr = $("#paths").val();
worker.postMessage(pathstr);
}
</script>
</head>
<body>
<div class="container">
<h2>Train Search</h2>
<p>Search for deadlocks in your intersections.</p>
<div><a style="cursor:hand;cursor:pointer;" onclick='$(".help").toggle();'>Click here to see an explanation.</a></div>
<div class="help">
<ul>
<li>The rail system is divided into blocks. A "block" is some area of rail that can be either free or occupied.</li>
<li>Connected rails have the same block, no matter if they're a fork or a crossing.</li>
<li>Signals form the borders of blocks.</li>
<li>Syntax: every line is a path that a train may take through the intersection, passing through blocks as it goes.</li>
<li>
For instance, a crossing of two rails might look like this:
<pre>1,10,2
3,10,4</pre>
Meaning "A train starts out in block 1, drives into block 10 (past a signal), leaves block 10 (past another signal) and exits the intersection at block 2. Simultaneously, another train may start out in block 3, drive into the shared block 10 (past yet another signal), leave it again and exit the intersection at block 4."
</li>
<li>Pre-signals are represented by a dash "-" instead of a comma. Ie. a path that passes over two pre-signals followed by a regular signal could be represented as
<pre>1-2-3,4</pre>
</li>
<li>Block numbers can be in any order. Block numbers can be discontinuous.</li>
<li>You can use the block numbers from in-game. Simply hold the mouse over a rail signal, and the game will tell you which two blocks it connects.</li>
<li>Alternatively, take a screenshot of the intersection and draw in the block borders with an editor like GIMP.<br>
For instance, the default paths are for <a style="cursor:hand;cursor:pointer;" onclick='$("#intersection-example").toggle()'>this intersection</a>.
<div id="intersection-example" style="display:none;"><img src="http://i.imgur.com/OlTkliv.jpg"/></div></li>
<li>The intersection is considered "deadlocked" when none of the trains passing
through it can move to the next block in their path.</li>
</ul>
</div>
<hr>
<textarea id="paths" rows="10" cols="50">
2,3
2,10,11,5
2,14,9,13,7
4,5
4,11,12,7
4,15,10,14,1
6,7
6,12,9,1
6,16,11,15,3
8,1
8,9,10,3
8,13,12,16,5
</textarea>
<div>
<button onclick="searchForDeadlocks();">Search for deadlocks</button>
<div id="output">
</div>
<div style="margin-top: 40px;" id="bottom-spacer"></div>
</div>
</div>
</body>
</html>