Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- When creating an engine which simulates the behavior of logic gates, there is three fundamental problems for the engine to overcome:
- PROBLEM #1: "The NOT Problem"
- Imagine a NOT-Gate A with one input a and one output b. Should b be directly connected to a, A will negate itself and turn b off. In return, a will be disabled and A will enable b again.
- As you can see, a NOT-Gate connected to itself is an infinite logic loop and unless an infinite loop should result internally, the amount of ticks or the "engine speed" has to be reduced to a finite amount of "ticks".
- PROBLEM #2: "The XOR Problem"
- Imagine two sensors A and B and an XOR Gate C, given that A = B. A and B will activate simultaneously, meaning that on paper C will never output a signal.
- To accomplish this, C has to wait for both A and B to send their information to C's inputs and then process these.
- PROBLEM #3: "The OR, AND Problem"
- Imagine three sensors A, B, C aswell as an AND-Gate X and an OR-Gate Y. A = B.
- The connections are as following:
- A---|
- X---?
- B-| |
- Y-|
- C-|
- The expected outcome is that when the sensors are activated, first Y gets activated and turns on one of X's inputs and A gets activated, turning on the other input of X, making X output information. If there is a delay between these operations, it could be that within the next tick Y outputs to X, but the sensor A is already turned off.
- As a result of this, should A (B) be sensors that only output for one tick, a delay in data transfer and incorrect order of component ticking leads to X not being able to output information.
- Thus, define the order in which components are activated as their longest, unique, non-repititive path to a source. Define "source" as a component which does not have any path from any of its inputs to a component without any inputs.
- In this example, the longest path of A, B and C to a source is precisely of length 0, as they are root-components themselves. Thus, they are being ticked by the engine first.
- Y's longest path to a root component is of length 1 (Y->B or Y->C), thus, it is activated next.
- X's longest path to a root component is of length 2 (X->Y->B or X->Y->C), thus, it is activated after Y.
- Examples of root components are:
- - batteries
- - sensors
- - unconnected/self-connected NOT-Gates
Advertisement
Add Comment
Please, Sign In to add comment