[Polycasso-commit] SF.net SVN: polycasso:[68] trunk/polycasso/src/com/mebigfatguy/polycasso/ Improv
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2009-11-27 02:02:51
|
Revision: 68
http://polycasso.svn.sourceforge.net/polycasso/?rev=68&view=rev
Author: dbrosius
Date: 2009-11-27 02:02:43 +0000 (Fri, 27 Nov 2009)
Log Message:
-----------
on a large run of failures, reset the stats to reset the randomness of picking improvements
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 00:07:37 UTC (rev 67)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 02:02:43 UTC (rev 68)
@@ -29,6 +29,7 @@
*/
public class ImprovementTypeStats {
+ private static final int MAX_FAILURE_RUN = 50;
private static class Stats {
public int successes = 1;
public int totals = 1;
@@ -42,6 +43,7 @@
private Map<ImprovementType, Stats> typeStats = new EnumMap<ImprovementType, Stats>(ImprovementType.class);
private Random r = new Random();
+ private int failureRun;
/**
* creates an initial state of statistics
@@ -61,6 +63,10 @@
if (successful)
stats.successes++;
stats.totals++;
+ failureRun = successful ? 0 : failureRun + 1;
+ if (failureRun > MAX_FAILURE_RUN) {
+ initStats();
+ }
}
/**
@@ -98,5 +104,6 @@
for (ImprovementType type : values) {
typeStats.put(type, new Stats());
}
+ failureRun = 0;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|