1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package edu.caltech.cs2.project09.bots;
import edu.caltech.cs2.project09.game.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
public abstract class AbstractSearcher<B extends Board> implements Searcher<B> {
protected Evaluator<B> evaluator;
protected Timer timer;
protected int ply;
protected int cutoff;
private BestMove bestMove;
private PropertyChangeSupport bestMovePropertyChange;
public AbstractSearcher() {
setTimer(new SimpleTimer(180000));
}
public void setEvaluator(Evaluator<B> e) {
evaluator = e;
}
public void setDepth(int depth) {
this.ply = depth;
}
public void setCutoff(int cutoff) {
this.cutoff = cutoff;
}
public void setTimer(Timer t) {
this.timer = t;
}
protected void reportNewBestMove(BestMove move) {
this.bestMovePropertyChange.firePropertyChange("bestMove", this.bestMove, move);
this.bestMove = move;
}
public void addOnBestMoveListener(PropertyChangeListener listener) {
this.bestMovePropertyChange.addPropertyChangeListener(listener);
}
public void removeOnBestMoveListener(PropertyChangeListener listener) {
this.bestMovePropertyChange.removePropertyChangeListener(listener);
}
}