Skip to content

Commit

Permalink
Merge branch 'feature/minimax'
Browse files Browse the repository at this point in the history
  • Loading branch information
sas12028 committed Apr 16, 2017
2 parents 34feec2 + daa9992 commit ad0a564
Show file tree
Hide file tree
Showing 17 changed files with 454 additions and 404 deletions.
Binary file added resources/boardstaterep.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions src/CheckersAI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class CheckersAI{


Evaluator eval;

public CheckersAI(Evaluator e, int player){
this.eval = e;
}

public Move minimax(CheckersGameState s){

return null;
}

}
23 changes: 21 additions & 2 deletions src/CheckersGameState3.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -274,5 +295,3 @@ public void printState(){
System.out.print("\n");
}
}


5 changes: 5 additions & 0 deletions src/Evaluator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public interface Evaluator{

double evaluate(CheckersGameState s);

}
11 changes: 11 additions & 0 deletions src/Evaluator00.java
Original file line number Diff line number Diff line change
@@ -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.
Loading

0 comments on commit ad0a564

Please sign in to comment.