Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed bug
  • Loading branch information
sos13004 committed Apr 19, 2017
1 parent d848dfb commit 4eb3faa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/CheckersGameState3.java
Expand Up @@ -177,14 +177,14 @@ public class CheckersGameState3 implements CheckersGameState{
int delta = 1; //black
if(player == 2) delta = -1; //white
return (valid_square(index+(delta*4)) && empty(board, index+(delta*4))) ||
(valid_square(index+(delta*5)) && empty(board, index+(delta*5)))
(valid_square(index+(delta*5)) && empty(board, index+(delta*5)));
}

private boolean king_can_move(int index){
return (valid_square(index+4) && empty(board, index+4)) ||
(valid_square(index+5) && empty(board, index+5)) ||
(valid_square(index-4) && empty(board, index-4)) ||
(valid_square(index-5) && empty(board, index-5))
(valid_square(index-5) && empty(board, index-5));
}

private boolean can_jump(int orig, int delta, int[] board){
Expand Down Expand Up @@ -366,21 +366,23 @@ public class CheckersGameState3 implements CheckersGameState{
mypieces+=1.0;
if(isLoner(i)) features[1] +=1.0;
if(isSafe(i)) features[2] +=1.0;
if(this.board[i]) == player){ //pawn
if(this.board[i] == player){ //pawn
features[3]+=1.0;
if(pawn_can_move(i)) features[4] += 1.0;
}
else if(this.board[i]) == player+2){ //king
else if(this.board[i] == player+2){ //king
features[5]+=1.0;
if(king_can_move(i)) features[6] += 1.0;
}
}
}
}
features[0] = mypieces/total;
return features;
}



/*feature: piece has no neighbors*/
public boolean isLoner(int pos){
if(this.board[pos-5] == 0 && this.board[pos-4] ==0 && this.board[pos+4] ==0 && this.board[pos+5] ==0){
Expand Down

0 comments on commit 4eb3faa

Please sign in to comment.