From b640dd0f6769e51bfdd228bc95000e635b304673 Mon Sep 17 00:00:00 2001 From: savannaos Date: Thu, 27 Apr 2017 12:19:50 -0400 Subject: [PATCH] added end game features --- src/CheckersGameState3.java | 85 +++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/src/CheckersGameState3.java b/src/CheckersGameState3.java index b7be28a..64864d7 100644 --- a/src/CheckersGameState3.java +++ b/src/CheckersGameState3.java @@ -199,6 +199,19 @@ public class CheckersGameState3 implements CheckersGameState{ return backward || forward; } + private boolean any_jumps(int pos){ + if(this.board[pos] == 1){ + if(any_jumps(pos, 4, 5, this.board, false)) return true; + } + else if(this.board[pos] == 2){ + if(any_jumps(pos, -4, -5, this.board, false)) return true; + } + else { + if(any_jumps(pos,4,5,this.board,true)) return true; + } + return false; + } + public List actions(){ return this.actions; } @@ -443,11 +456,14 @@ public class CheckersGameState3 implements CheckersGameState{ 2: num attacking pieces 3: central pieces 4: # pawns on diagonal + 2 * # kings on diagonal - 5: ^ same but for the two smaller diagonals + 5: bridge pattern + 6: triangle pattern + 7: dog pattern + 8: opponents kings are on the side. ] */ public double[] getEndGameFeatures(int player){ - double[] features = new double[6]; + double[] features = new double[9]; double total = 0.0; double mypieces = 0.0; for(int i = 0; i