- Updated the Node interface and its implementations to include a strength() function. This is a double value between 0 and 1 representing the percent activation.
- Updated the PlayerModel to fix a bug in the high score tracking. - Created HighScoreDialog.java, which displays the high scores from a PlayerModel. In the future, it will have a "New Game" button so that it can be used to transition between games.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user