-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
91 lines (88 loc) · 5.72 KB
/
index.html
File metadata and controls
91 lines (88 loc) · 5.72 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="assets/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="style.css">
<title>TerraBool - A Terraria boolean function minifier</title>
</head>
<body>
<header>
<h1>TerraBool</h1>
<h2 role="doc-subtitle">A Terraria boolean function minifier</h2>
<section>
<h2>About</h2>
<p>This app is made to exploit how logic gates and wires behave in Terraria. The main property being how signals don't necessarily turn on a device when power is provided, but rather toogle the on/off state. This property can be used to make circuits, that maximizes use of XOR logic, as connecting two wires together is the same as putting them through an XOR gate.</p>
</section>
</header>
<main>
<section id="minifier">
<h2>Find function from truth table</h2>
<form onsubmit="event.preventDefault(); calculate()">
<input type="text" id="term" placeholder="001100110000xxxx">
<button>Calculate</button>
<a id="download" href="" style="display: none;">download .csv</a>
<div id="loader" style="display: none;"></div>
</form>
<p id="error" style="display: none;">Invalid value length</p>
<div id="result"></div>
</section>
<section id="example">
<h2>How to use the minifier</h2>
<div id="table_img">
<table>
<tr><th>A</th><th>B</th><th>C</th><th>D</th><th>f(A,B,C,D)</th></tr>
<tr><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr>
<tr><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td></tr>
<tr><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td></tr>
<tr><td>0</td><td>0</td><td>1</td><td>1</td><td>1</td></tr>
<tr><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td></tr>
<tr><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td></tr>
<tr><td>0</td><td>1</td><td>1</td><td>0</td><td>1</td></tr>
<tr><td>0</td><td>1</td><td>1</td><td>1</td><td>1</td></tr>
<tr><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td></tr>
<tr><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td></tr>
<tr><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr>
<tr><td>1</td><td>0</td><td>1</td><td>1</td><td>0</td></tr>
<tr><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td></tr>
<tr><td>1</td><td>1</td><td>0</td><td>1</td><td>x</td></tr>
<tr><td>1</td><td>1</td><td>1</td><td>0</td><td>x</td></tr>
<tr><td>1</td><td>1</td><td>1</td><td>1</td><td>x</td></tr>
</table>
<img id="example_img" src="img/example.gif" alt="ingame example of the function">
</div>
<p>Type in the output values for the function as a binary number. The given truth table would be entered as <i>xxx0011011001100</i>. (The x'es are don't cares.)</p>
<h3>How to interpret a generated boolean function.</h3>
<p>First, you must be familiar with logical operations AND(∧), OR(∨), NOT(¬), XOR(⊕), XNOR(⨀).</p>
<p>There are two kinds of XOR used in this app. One is the "parity function" XOR, which will be used without the gate in Terraria, and is implied in the result by writing inputs right after eachother. The other is the "Turns on when exactly one lamp is active" XOR, which means that you have to use that gate in the game, denoted by <b>⊕</b>.</p>
<p>Using the function generated from the example table, we get "¬c ⊕ ¬ac ⊕ ¬cd ⊕ acd"</p>
<h3>Here's how this function translates into Terraria</h3>
<p><mark class="term"><mark class="negation">¬</mark>c</mark>
<mark class="gate">⊕</mark>
<mark class="term"><mark class="negation">¬</mark>ac</mark>
<mark class="gate">⊕</mark>
<mark class="term"><mark class="negation">¬</mark>cd</mark>
<mark class="gate">⊕</mark>
<mark class="term">acd</mark></p>
<p>
<mark class="gate">The operation connecting the terms show which logic gate to use ingame.</mark><br>
<mark class="term">The terms show which inputs connect to a single logic gate lamp.</mark><br>
<mark class="negation">The negation sign in front of a term means that the gate lamp should be in an "ON" state</mark>
</p>
<p>
Not all functions can be expressed with a single logic gate. In these cases, the app will list functions in two columns. choose one from each column, create the two gates ingame, and combine their outputs with a common wire.
</p>
<h3>(November 2023 update) This version now lists all equivalent functions!</h3>
<p>
When making multi-output modules, the first result rarely has no wire routing issues. This is why the app now lists all equivalent functions, so you can choose the one that works best for you.
</p>
</section>
</main>
<footer>
</footer>
<script src="js/dictionary.js"></script>
<script src="js/solution.js"></script>
</body>
</html>