class documentation - a shitload of it
All checks were successful
Linux arm64 / Build (push) Successful in 33s
All checks were successful
Linux arm64 / Build (push) Successful in 33s
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package chess.ai.alphabeta;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import chess.ai.GameSimulation;
|
||||
import chess.ai.actions.AIAction;
|
||||
import chess.controller.CommandExecutor;
|
||||
import chess.model.Color;
|
||||
|
||||
/**
|
||||
* Create the threads for an alpha-beta bot.
|
||||
* @see AlphaBetaAI
|
||||
*/
|
||||
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(AIAction 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