Super IA (#5)
Reviewed-on: #5 Co-authored-by: Persson-dev <sim16.prib@gmail.com> Co-committed-by: Persson-dev <sim16.prib@gmail.com>
This commit was merged in pull request #5.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package chess.ai.minimax;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import chess.controller.CommandExecutor;
|
||||
import chess.model.Color;
|
||||
import chess.model.Move;
|
||||
|
||||
public class AlphaBetaThreadCreator implements ThreadFactory{
|
||||
|
||||
private final Color color;
|
||||
private final GameSimulation simulations[];
|
||||
private int currentThread = 0;
|
||||
|
||||
public AlphaBetaThreadCreator(CommandExecutor commandExecutor, Color color, int threadCount) {
|
||||
this.color = color;
|
||||
simulations = new GameSimulation[threadCount];
|
||||
for (int i = 0; i < threadCount; i++) {
|
||||
simulations[i] = new GameSimulation();
|
||||
commandExecutor.addListener(simulations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getMoveValue(Move move, int searchDepth) {
|
||||
AlphaBetaThread t = (AlphaBetaThread) Thread.currentThread();
|
||||
return t.getMoveValue(move, searchDepth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
AlphaBetaThread t = new AlphaBetaThread(r, simulations[currentThread], color);
|
||||
currentThread++;
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user