-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogicGates.js
71 lines (58 loc) · 1.96 KB
/
logicGates.js
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
class LOGICGates extends GameOfLife {
constructor() {
super(165, 76);
}
andGate(first, second) {
this.emptyArray();
const FIRST_GUN = { x: 0, y: 9 }
const SECOND_GUN = { x: 38, y: 6 }
const REVERSE_GUN = { x: 122, y: 7 }
this.addGun(FIRST_GUN.x, FIRST_GUN.y);
this.addGun(SECOND_GUN.x, SECOND_GUN.y);
this.addGunReverse(REVERSE_GUN.x, REVERSE_GUN.y);
if (!first)
newGame.addStopper(29, 20);
if (!second)
newGame.addStopper(70, 20);
for (let i = 0; i < 190; i++) {
this.gameRound();
}
return (this.mainGrid[65][55] != 0 ? 1 : 0);
}
notGate(first) {
this.emptyArray();
const FIRST_GUN = { x: 0, y: 9 }
const REVERSE_GUN = { x: 78, y: 10 }
this.addGun(FIRST_GUN.x, FIRST_GUN.y);
this.addGunReverse(REVERSE_GUN.x, REVERSE_GUN.y);
if (!first)
newGame.addStopper(29, 20);
for (let i = 0; i < 103; i++) {
this.gameRound();
}
return (this.mainGrid[35][34] != 0 ? 1 : 0);
}
orGate(first, second){
this.emptyArray();
const FIRST_GUN = { x: 0, y: 9 }
const SECOND_GUN = { x: 38, y: 6 }
const THIRD_GUN = { x: 78, y: 6 }
const REVERSE_GUN = { x: 162, y: 7 }
this.addGun(FIRST_GUN.x, FIRST_GUN.y);
this.addGun(SECOND_GUN.x, SECOND_GUN.y);
this.addGun(THIRD_GUN.x, THIRD_GUN.y);
this.addGunReverse(REVERSE_GUN.x, REVERSE_GUN.y);
if (!first)
newGame.addStopper(70, 20);
if (!second)
newGame.addStopper(110, 20);
for (let i = 0; i < 265; i++) {
this.gameRound();
}
return (this.mainGrid[82][75] != 0 ? 1 : 0);
}
xorGate(first, second){
return (this.orGate(this.andGate(this.notGate(first), second),
this.andGate(this.notGate(second), first)) ? 1 : 0);
}
}