From ed02e2081f5a56c5a4463f64d3855b5d18035cb1 Mon Sep 17 00:00:00 2001 From: Sailesh Date: Tue, 4 Apr 2017 00:21:52 -0400 Subject: [PATCH] Fix toString of move --- src/Move3.java | 53 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/src/Move3.java b/src/Move3.java index 6b13bbc..5c89bd3 100644 --- a/src/Move3.java +++ b/src/Move3.java @@ -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