Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Diminishing learning parameter
  • Loading branch information
sas12028 committed Apr 29, 2017
1 parent b640dd0 commit b44b5e5
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 128 deletions.
18 changes: 15 additions & 3 deletions src/Learn.java
Expand Up @@ -19,21 +19,33 @@ public class Learn{
// for learning rate, first 30 with .1, next 30 with .05, then final 30 with .01 and see what happens

public static void learn(CheckersAI alpha, CheckersAI beta, LearningEvaluator le, BaseEvaluator be){
final int num_games = 5;
final int iterations = 20;
final int num_games = 30;
final int iterations = 7;

Random rand = new Random();
for(int j = 0; j < iterations; j++){
for(int i = 1; i <= num_games; i++){ // play num_games amount of games
System.out.println("playing game " + i);
int player = rand.nextInt(2) + 1; // choose which player alpha plays as
play(alpha, beta, le, player, true); // alpha and beta play a game
le.updateWeights(.1); // get new weights using data from game
le.updateWeights(learningParameter(i, num_games)); // get new weights using data from game
//le.updateWeights(.1); // get new weights using data from game
}
faceBeta(alpha, beta, le, be);
}
}

public static double learningParameter(int played, int games){
if(played <= .80 * games){
return .10;
}
else{
double remaining = games - .80 * games;
double divisor = remaining - (games - played);
return .10/(divisor);
}
}

public static void faceBeta(CheckersAI alpha, CheckersAI beta, LearningEvaluator le, BaseEvaluator be){
boolean w1;
boolean w2;
Expand Down
2 changes: 1 addition & 1 deletion src/LearningEvaluator.java
Expand Up @@ -45,7 +45,7 @@ public class LearningEvaluator extends BaseEvaluator{
try {
double[] new_weights = reg.estimateRegressionParameters(); //get parameters
for(double x: new_weights){
if(Math.abs(x) > 10000){
if(Math.abs(x) > 100000){
System.out.println("bad data, not updating");
return;
}
Expand Down

0 comments on commit b44b5e5

Please sign in to comment.