Skip to content

Commit 670a763

Browse files
cjboltcjbolt
authored andcommitted
Optimise
1 parent 7f04123 commit 670a763

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

EubosChess/src/main/java/eubos/search/transposition/FixedSizeTranspositionTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private synchronized void pruneTable(EubosEngineMain eubos, int moveNumber) {
222222
public void reset() {
223223
for (int i=0; i < maxTableSize; i++) {
224224
hashes[i] = 0L;
225-
transposition_table[i] = 0L;
225+
//transposition_table[i] = 0L;
226226
}
227227
}
228228

EubosChess/src/test/java/eubos/neural_net/TrainingDataUpdater.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.BufferedReader;
44
import java.io.File;
5+
import java.io.FileNotFoundException;
56
import java.io.FileReader;
67
import java.io.IOException;
78
import 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

Comments
 (0)