
com.fathzer.jchess.uci.PerftTask Maven / Gradle / Ivy
package com.fathzer.jchess.uci;
import java.util.function.Supplier;
import com.fathzer.games.MoveGenerator;
import com.fathzer.games.perft.PerfT;
import com.fathzer.games.perft.PerfTResult;
import com.fathzer.games.util.ContextualizedExecutor;
class PerftTask extends LongRunningTask> {
private PerfT perft;
private final Supplier> engine;
private final int depth;
private final int parallelism;
public PerftTask(Supplier> engine, int depth, int parallelism) {
this.engine = engine;
this.depth = depth;
this.parallelism = parallelism;
}
@Override
public PerfTResult get() {
try (ContextualizedExecutor> exec = new ContextualizedExecutor<>(parallelism)) {
this.perft = new PerfT<>(exec);
return perft.divide(depth, engine::get);
}
}
@Override
public void stop() {
super.stop();
perft.interrupt();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy