package model.playerModel.node; import java.util.Hashtable; import model.playerModel.Node; public class SigmoidNode implements Node { // Training rate. private final double A = .15; private final Hashtable dendrites = new Hashtable(); private final double s = 1; // Slope paramater for the activation function. // It's doing nothing right now, but I figured // I'd implement it as a tweaking option. private final double THRESHOLD = .5; public void addNode(Node n, double weight) { dendrites.put(n, weight); } @Override public boolean axon() { double sum = 0; for (Node n : dendrites.keySet()) { sum += n.axon() ? dendrites.get(n) : 0; } return (activation(sum) > THRESHOLD); } @Override public void learn(boolean correct) { for (Node n : dendrites.keySet()) { if (correct && n.axon()) { dendrites.put(n, dendrites.get(n) + A); n.learn(correct); } } } private double activation(double sum) { // Sigmoid function: // 1/(1+(e^(-bt))) double a = -1 * s * sum; a = Math.exp(a); a = 1 + a; a = 1 / a; return a; } }