Skip to content

Commit

Permalink
Interface doesn't allow for variable declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
sas12028 committed Apr 3, 2017
1 parent 20e5b1b commit 154c531
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/CheckersGameState3.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void generate_moves(int origin, int delta1, int delta2, List<Move> moves
}


private void calculate_jumps(String path, int[] b, int orig, int delta1, int delta2, List<Move3> jumps, boolean king){
private void calculate_jumps(String path, int[] b, int orig, int delta1, int delta2, List<Move> jumps, boolean king){
if(!any_jumps(orig, delta1, delta2, b, king)){
if(path.contains(",")){
jumps.add(new Move3(path));
Expand Down Expand Up @@ -226,16 +226,16 @@ private void calculate_jumps(String path, int[] b, int orig, int delta1, int del

CheckersGameState3 result(Move x){
int[] newState = this.board.clone();
newState[x.destination()] = this.board[x.origin()];
newState[x.origin()] = 0;
if(x.destination < 4 && this.player == 2){
newState[x.destination()] = this.board[x.source()];
newState[x.source()] = 0;
if(x.destination() < 4 && this.player == 2){
newState[x.destination()] = 4;
}
else if(x.destination() > 30 && this.player == 1){
newState[x.destination()] = 3;
}
if(x.kills() != null){
for(int k: x.kills()){
if(x.captures() != null){
for(int k: x.captures()){
newState[k] = 0;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Move.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

public interface Move {
// Starting and ending Positions
public int source();
public int destination();
// Returns a list of captured positions
public int[] captures();
// Returns the string representation of a move
Expand Down
2 changes: 1 addition & 1 deletion src/Move3.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public int[] calculate_kills(String[] steps){
return k;
}

public int origin(){
public int source(){
return src;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public static void main(String[] args){

CheckersGameState3 s2 = new CheckersGameState3(1, b2);
s2.printState();
for(Move3 m: s2.actions()){
s2.result(s2.actions().get(1)).printState();
for(Move m: s2.actions()){
System.out.println(m);
}
}
Expand Down

0 comments on commit 154c531

Please sign in to comment.