Skip to content
Permalink
Browse files

evaluator number of pieces ratio

  • Loading branch information
sos13004 committed Apr 15, 2017
1 parent a1d0377 commit daa9992ce5d4fcc0df32f0c168b0a4eff171d15e
Binary file not shown.
File renamed without changes.
File renamed without changes.
@@ -252,6 +252,27 @@ private int other(int player){
}
}

public boolean myPiece(int i){
if(this.player == 1 && i == 1 || this.player == 1 && i == 3) //black
return true;
if(this.player == 0 && i == 2 || this.player == 0 && i == 4) //white
return true;
else return false;
}

public double pieceRatio(){
double total = 0.0;
double mypieces = 0.0;
for(int i = 0; i<this.board.length; i++){
if(i%9!=8){
if(this.board[i] != 0 ) total+=1.0;
if(myPiece(this.board[i])) mypieces+=1.0;
}
}
//System.out.println("" + mypieces);
return mypieces/total;
}

public void printState(){
boolean leading = false;
int printed = 0;
@@ -274,5 +295,3 @@ public void printState(){
System.out.print("\n");
}
}


@@ -1,5 +1,5 @@
public interface Evaluator{

int evaluate(CheckersGameState s);
double evaluate(CheckersGameState s);

}
@@ -0,0 +1,11 @@
/* Evaluates a given board state based on the ratio of pieces
the player has out of the total alive pieces on the board */

public class Evaluator00 implements Evaluator {

public double evaluate(CheckersGameState s){
CheckersGameState3 gs = (CheckersGameState3) s;
return gs.pieceRatio();
}

}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit daa9992

Please sign in to comment.
You can’t perform that action at this time.