-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNeuron.java
More file actions
82 lines (69 loc) · 2.29 KB
/
Neuron.java
File metadata and controls
82 lines (69 loc) · 2.29 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
import java.util.HashMap;
import java.awt.Color;
import java.util.ArrayList;
public abstract class Neuron extends ScreenObject implements Cloneable{
private ArrayList<Neuron> sources = new ArrayList<Neuron>();
private HashMap<Neuron,Integer> sinks = new HashMap<Neuron,Integer>();
private String type;
private ArrayList<Double> values = new ArrayList<Double>();
public Neuron(String type) {
super(Color.white, new Coor(0, 0));
switch(type){
case "Sensor": this.setPosX(50);
this.type = type;
break;
case "Internal": this.setPosX(100);
this.type = type;
break;
case "Motor": this.setPosX(150);
this.type = type;
break;
}
}
public ArrayList<Neuron> getSources(){
return this.sources;
}
public HashMap<Neuron,Integer> getSinks(){
return this.sinks;
}
public String getClassType() {
return type;
}
public ArrayList<Double> getValues() {
return values;
}
public void addValue(Double value) {
this.values.add(value);
}
public void clearValues() {
this.values.clear();
}
public void addSource(Neuron neuron){
this.sources.add(neuron);
}
public void addSink(Neuron neuron,int sinkWeight){
this.sinks.put(neuron,sinkWeight);
}
public void removeSource(Neuron neuron){
this.sources.remove(neuron);
}
public void removeSink(Neuron neuron){
this.sinks.remove(neuron);
}
public void replaceSource(Neuron initial, Neuron replacement){
this.sources.set(this.sources.indexOf(initial),replacement);
}
public void replaceSink(Neuron initial, Neuron replacement){
this.sinks.put(replacement, this.sinks.get(initial));
this.sinks.remove(initial);
}
public static Coor getPrintPos(int x, int y) {
Screens.brainWorldToScreen.setWorld(Screens.brainPanel.getWidth(), Screens.brainPanel.getHeight());
int[] ans = Screens.brainWorldToScreen.translate(new int[]{x,y});
return new Coor(ans[0], ans[1]);
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}