-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNode.cs
70 lines (64 loc) · 1.72 KB
/
Node.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Game
{
public class Node : ICloneable
{
public int[] children = Array.Empty<int>();
public Vector pos;
public bool isActivated = false;
public string? gateName;
public static Dictionary<string, (Color color, Func<bool, bool, bool> eval)> gates = new()
{
{
"AND",
(Color.Blue, (bool a, bool b) => a && b)
},
{
"OR",
(Color.Red, (bool a, bool b) => a || b)
},
{
"XOR",
(Color.Lime, (bool a, bool b) => a ^ b)
},
{
"NAND",
(Color.Cyan, (bool a, bool b) => !(a && b))
},
{
"NOR",
(Color.Magenta, (bool a, bool b) => !(a || b))
},
{
"XNOR",
(Color.Yellow, (bool a, bool b) => !(a ^ b))
},
};
public static int size = 32;
public Vector dim = new(size, size);
public Node(Vector pos, int[] children)
{
this.pos = pos;
this.children = children;
}
public Node(Vector pos, bool isActivated)
{
this.pos = pos;
this.isActivated = isActivated;
}
public Node(Vector pos, string gateName, int[] children)
{
this.pos = pos;
this.gateName = gateName;
this.children = children;
}
public object Clone()
{
return MemberwiseClone();
}
}
}