diff --git a/src/model/playerModel/Node.java b/src/model/playerModel/Node.java
index 7184e94..1eea00e 100644
--- a/src/model/playerModel/Node.java
+++ b/src/model/playerModel/Node.java
@@ -6,4 +6,5 @@ public interface Node {
void learn(boolean correct);
+ double strength();
}
diff --git a/src/model/playerModel/PlayerModel.java b/src/model/playerModel/PlayerModel.java
index b6c1da5..7cd2be7 100644
--- a/src/model/playerModel/PlayerModel.java
+++ b/src/model/playerModel/PlayerModel.java
@@ -21,9 +21,18 @@ public class PlayerModel {
private int nextHighInGames = 0;
- // One node for each tile.
- private final SigmoidNode[] outputNode = new SigmoidNode[Board.NUM_COLS
- * Board.NUM_ROWS];
+ // One node for each tile plus four for the colors to be selected.
+ // outputNode[0] is blue.
+ // outputNode[1] is green.
+ // outputNode[2] is red.
+ // outputNode[3] is yellow.
+ // outputNode[4] through outputNode[n] represent grid spaces. A true means
+ // that the player is predicted to place on that tile.
+ // They should be read from the top-left to bottom-right, across rows.
+ // Ideally, the network should return only one true between 0 and 3 and only
+ // one true between 4 and n, representing one color and the tile in which it
+ // should be placed.
+ private final SigmoidNode[] outputNode = new SigmoidNode[(Board.NUM_COLS * Board.NUM_ROWS) + 4];
public PlayerModel() {
for (int i = 0; i < highScore.length; i++) {
@@ -54,6 +63,10 @@ public class PlayerModel {
}
}
+ public int[] getHighScores() {
+ return highScore;
+ }
+
public boolean[] getPrediction(boolean[] input) {
if (input.length == inputNode.length) {
boolean[] prediction = new boolean[outputNode.length];
@@ -118,12 +131,11 @@ public class PlayerModel {
else {
loop: for (int i = 0; i < highScore.length; i++) {
if (score > highScore[i]) {
- for (int j = i; j < highScore.length - 1; j++) {
+ for (int j = highScore.length - 2; j >= i; j--) {
highScore[j + 1] = highScore[j];
}
highScore[i] = score;
-
break loop;
}
}
diff --git a/src/model/playerModel/node/InputNode.java b/src/model/playerModel/node/InputNode.java
index 87b6751..53a6418 100644
--- a/src/model/playerModel/node/InputNode.java
+++ b/src/model/playerModel/node/InputNode.java
@@ -19,4 +19,9 @@ public class InputNode implements Node {
public void setStimulation(boolean active) {
dendrite = active;
}
+
+ @Override
+ public double strength() {
+ return axon() ? 1 : 0;
+ }
}
diff --git a/src/model/playerModel/node/SigmoidNode.java b/src/model/playerModel/node/SigmoidNode.java
index 386a695..7772a72 100644
--- a/src/model/playerModel/node/SigmoidNode.java
+++ b/src/model/playerModel/node/SigmoidNode.java
@@ -4,7 +4,6 @@ import java.util.Hashtable;
import model.playerModel.Node;
-
public class SigmoidNode implements Node {
// Training rate.
@@ -23,14 +22,7 @@ public class SigmoidNode implements Node {
@Override
public boolean axon() {
- double sum = 0;
-
- for (Node n : dendrites.keySet()) {
- sum += n.axon() ? dendrites.get(n) : 0;
- }
-
- return (activation(sum) > THRESHOLD);
-
+ return strength() > THRESHOLD;
}
@Override
@@ -44,6 +36,17 @@ public class SigmoidNode implements Node {
}
}
+ @Override
+ public double strength() {
+ double sum = 0;
+
+ for (Node n : dendrites.keySet()) {
+ sum += n.axon() ? dendrites.get(n) : 0;
+ }
+
+ return activation(sum);
+ }
+
private double activation(double sum) {
// Sigmoid function:
// 1/(1+(e^(-bt)))
diff --git a/src/view/HighScoreDialog.java b/src/view/HighScoreDialog.java
new file mode 100644
index 0000000..0f1dffb
--- /dev/null
+++ b/src/view/HighScoreDialog.java
@@ -0,0 +1,69 @@
+package view;
+
+import javax.swing.BorderFactory;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+
+import model.playerModel.PlayerModel;
+
+public class HighScoreDialog extends JDialog {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static void main(String[] args) {
+ JFrame x = new JFrame();
+ x.setDefaultCloseOperation(EXIT_ON_CLOSE);
+ x.setVisible(true);
+
+ PlayerModel pm = new PlayerModel();
+ pm.logGame(100);
+ pm.logGame(90);
+ pm.logGame(80);
+ pm.logGame(70);
+ pm.logGame(60);
+ pm.logGame(50);
+ pm.logGame(40);
+ pm.logGame(30);
+ pm.logGame(20);
+ pm.logGame(10);
+ pm.logGame(98);
+ pm.logGame(105);
+
+ new HighScoreDialog(x, pm);
+ }
+
+ public HighScoreDialog(JFrame owner, PlayerModel pm) {
+ super(owner, "Game over!", true);
+
+ String text = "";
+ text += "Game Over!";
+ text += "
";
+ text += "High Scores:";
+ text += "