22
33import java .io .BufferedReader ;
44import java .io .File ;
5+ import java .io .FileNotFoundException ;
56import java .io .FileReader ;
67import java .io .IOException ;
78import java .io .PrintWriter ;
@@ -30,6 +31,7 @@ public class TrainingDataUpdater {
3031 public void setUp () {
3132 EubosEngineMain .logger .setLevel (Level .OFF );
3233 eubos_stub = new EubosEngineMain ();
34+ hashMap = new FixedSizeTranspositionTable (16 ,1 );
3335 }
3436
3537 private int getScoreForDepth (int searchDepth ) {
@@ -39,21 +41,23 @@ private int getScoreForDepth(int searchDepth) {
3941
4042 protected void setupPosition (String fen ) {
4143 pm = new PositionManager ( fen );
42- hashMap = new FixedSizeTranspositionTable ();
44+ hashMap . reset ();
4345 classUnderTest = new MiniMaxMoveGenerator (hashMap , pm , pm );
4446 classUnderTest .setEngineCallback (eubos_stub );
4547 }
4648
4749 @ Test
4850 @ Ignore
49- public void test_UpdateReferenceTrainingData ()throws IllegalNotationException , IOException {
51+ public void test_UpdateReferenceTrainingData ()throws IllegalNotationException {
5052 // Load each group of training data in turn (1M positions at a time)
51- File [] files = new File ("D :\\ tester \\ out " ).listFiles ();
53+ File [] files = new File ("C :\\ \\ NN " ).listFiles ();
5254 for (File filename : files ) {
53-
55+ int count = 0 ;
56+ float total_time_ms = 0.0f ;
5457 // Read each file in, then position by position, update the score
58+ Long then = System .currentTimeMillis ();
5559 try (BufferedReader in = new BufferedReader (new FileReader (filename ));
56- PrintWriter out = new PrintWriter ("D :\\ updated \\ " +filename .getName (), "UTF-8" )) {
60+ PrintWriter out = new PrintWriter ("C :\\ NN_updated \\ " +filename .getName (), "UTF-8" )) {
5761 String entry ;
5862 while ((entry = in .readLine ()) != null ) {
5963
@@ -68,8 +72,19 @@ public void test_UpdateReferenceTrainingData()throws IllegalNotationException, I
6872 String updated_entry = fen + "|" + Integer .toString (score ) + "|0.5" ;
6973 out .println (updated_entry );
7074
71- System .out .print ('.' );
75+ count ++;
76+ if ((count % 1000 ) == 0 ) {
77+ Long now = System .currentTimeMillis ();
78+ total_time_ms += (float )(now - then );
79+ float rate = ((float )count ) / (total_time_ms / 1000.0f ); // average positions per second
80+ System .out .print (String .format ("%.1f pos/s\n " , rate ));
81+ then = now ;
82+ }
7283 }
84+ } catch (FileNotFoundException e ) {
85+ e .printStackTrace ();
86+ } catch (IOException e ) {
87+ e .printStackTrace ();
7388 }
7489 }
7590 }
0 commit comments