我在尝试编译我的 Java 代码时遇到了一个我真的无法解释的错误:
error: constructor MinimaxThread in class MinimaxThread cannot be applied to given types;
MinimaxThread mmt = new MinimaxThread(board.clone(), 2, true);
^
required: no arguments
found: MCBoard,int,boolean
reason: actual and formal argument lists differ in length
这个错误没有意义,因为我有一个构造函数,它接受一个 MCBoard、int 和 boolean:
public class MinimaxThread implements Runnable {
public MCBoard board;
public int depth;
public HashMap<Tuple, Integer> moveEvals;
boolean cont = true;
boolean verbose = false;
public MinimaxThread(MCBoard board, int initialDepth, boolean verbose) {
this.board = board;
depth = initialDepth;
moveEvals = new HashMap<Tuple, Integer>();
for (Tuple t : board.legalMoves) {
moveEvals.put(t, new Integer(0));
}
this.verbose = verbose;
}
这是一个重载的构造函数(有一个只有 MCBoard,一个有 MCBoard 和 int),但我不明白这有什么关系。有任何想法吗?这是调用代码:
public static void testMinimax(){
MCBoard board = new MCBoard();
board.move(5,0);
board.move(4,0);
board.move(5,2);
MinimaxThread mmt = new MinimaxThread(board.clone(), 2, true);
mmt.run();
}
编辑:board.clone()
被覆盖:
public MCBoard clone() {
// irrelevant code removed
return new MCBoard(gridClone, turn, legalMovesClone, moveListClone);
}
编辑#2:这是我的 git 存储库,为了重现性:https://github.com/cowpig/MagneticCave