Skip to content
Permalink
68bd8ae02c
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
36 lines (26 sloc) 916 Bytes
public class BaseEvaluator implements Evaluator{
// meant for beta to use
// when beta should use alpha's weights, have alpha commit to beta.csv and then call refreshWeights()
protected WeightsParser wp;
protected String file;
protected double[] weights;
public BaseEvaluator(String file){
this.wp = new WeightsParser();
this.file = file;
this.weights = this.wp.getWeights(file);
}
private double dot(double[] a1, double[] a2){ // function for dot product
double res = 0;
for(int i = 0; i < a1.length; i++){
res += (a1[i] * a2[i]);
}
return res;
}
public double evaluate(CheckersGameState s, int player){
double[] params = s.getFeatures(player);
return dot(this.weights, params);
}
public void refreshWeights(){
this.weights = this.wp.getWeights(this.file);
}
}