Skip to content

Commit

Permalink
Fix toString of move
Browse files Browse the repository at this point in the history
  • Loading branch information
sas12028 committed Apr 4, 2017
1 parent 154c531 commit ed02e20
Showing 1 changed file with 46 additions and 7 deletions.
53 changes: 46 additions & 7 deletions src/Move3.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,53 @@ public int[] captures(){
// else if(pos < 17){
// int x =
//
public String toString(){
String move = "(" + this.steps[0] + ":" + this.steps[1] + ")";
if(this.steps.length > 2){
for(int i = 1; i < this.steps.length - 1; i++){
move += ":(" + this.steps[i] + ":" + this.steps[i+1] + ")";
}

private String convert(int position) {
// Converts a position to the correct String
int row = position / 4;
int col = (position % 4) * 2;
if(row % 2 == 0){
col++;
}
return move;
return "("+(7-row)+":"+col+")";
}

private int shift(int position){
int row, column;
int new_pos = position;
if(position >= 27){
return (position - 3);
}
else if(position >= 18){
return (position - 2);
}
else if(position >= 9){
return (position - 1);
}
else{
return position;
}
}




// public String toString(){
// String move = "(" + this.steps[0] + ":" + this.steps[1] + ")";
// if(this.steps.length > 2){
// for(int i = 1; i < this.steps.length - 1; i++){
// move += ":(" + this.steps[i] + ":" + this.steps[i+1] + ")";
// }
// }
// return move;
// }
//
public String toString() {
String output = "";
for(int i = 0; i<steps.length; i++) {
output += i!=0 ? ":" : "";
output += convert(shift(Integer.parseInt(steps[i])));
}
return output;
}
}

0 comments on commit ed02e20

Please sign in to comment.