Skip to content

Commit

Permalink
Bugfix: issues #2 (again!) and #5
Browse files Browse the repository at this point in the history
  • Loading branch information
AGalassi committed Apr 15, 2019
1 parent 6694cce commit 56a0271
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ public void run() {
e1.printStackTrace();
}
while (!found) {
selected = pawns.get(new Random().nextInt(pawns.size() - 1));
if (pawns.size() > 0) {
selected = pawns.get(new Random().nextInt(pawns.size() - 1));
} else {
selected = pawns.get(0);
}

String from = this.getCurrentState().getBox(selected[0], selected[1]);

selected = empty.get(new Random().nextInt(empty.size() - 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private State checkCaptureWhite(State state, Action a) {
&& (state.getPawn(a.getRowTo(), a.getColumnTo() + 2).equalsPawn("W")
|| state.getPawn(a.getRowTo(), a.getColumnTo() + 2).equalsPawn("T")
|| state.getPawn(a.getRowTo(), a.getColumnTo() + 2).equalsPawn("K")
|| (this.citadels.contains(state.getBox(a.getRowTo(), a.getColumnTo() + 2))&&!(state.getPawn(a.getRowTo(), a.getColumnTo()+2).equalsPawn("B")) &&!(a.getColumnTo()+2==8&&a.getRowTo()==4)&&!(a.getColumnTo()+2==4&&a.getRowTo()==0)&&!(a.getColumnTo()+2==4&&a.getRowTo()==0)&&!(a.getColumnTo()+2==0&&a.getRowTo()==4)))) {
|| (this.citadels.contains(state.getBox(a.getRowTo(), a.getColumnTo() + 2)) &&!(a.getColumnTo()+2==8&&a.getRowTo()==4)&&!(a.getColumnTo()+2==4&&a.getRowTo()==0)&&!(a.getColumnTo()+2==4&&a.getRowTo()==0)&&!(a.getColumnTo()+2==0&&a.getRowTo()==4)))) {
state.removePawn(a.getRowTo(), a.getColumnTo() + 1);
this.movesWithutCapturing = -1;
this.loggGame.fine("Pedina nera rimossa in: " + state.getBox(a.getRowTo(), a.getColumnTo() + 1));
Expand All @@ -342,7 +342,7 @@ private State checkCaptureWhite(State state, Action a) {
&& (state.getPawn(a.getRowTo(), a.getColumnTo() - 2).equalsPawn("W")
|| state.getPawn(a.getRowTo(), a.getColumnTo() - 2).equalsPawn("T")
|| state.getPawn(a.getRowTo(), a.getColumnTo() - 2).equalsPawn("K")
|| (this.citadels.contains(state.getBox(a.getRowTo(), a.getColumnTo() - 2))&&!(state.getPawn(a.getRowTo(), a.getColumnTo()-2).equalsPawn("B")) &&!(a.getColumnTo()-2==8&&a.getRowTo()==4)&&!(a.getColumnTo()-2==4&&a.getRowTo()==0)&&!(a.getColumnTo()-2==4&&a.getRowTo()==0)&&!(a.getColumnTo()-2==0&&a.getRowTo()==4)))) {
|| (this.citadels.contains(state.getBox(a.getRowTo(), a.getColumnTo() - 2)) &&!(a.getColumnTo()-2==8&&a.getRowTo()==4)&&!(a.getColumnTo()-2==4&&a.getRowTo()==0)&&!(a.getColumnTo()-2==4&&a.getRowTo()==0)&&!(a.getColumnTo()-2==0&&a.getRowTo()==4)))) {
state.removePawn(a.getRowTo(), a.getColumnTo() - 1);
this.movesWithutCapturing = -1;
this.loggGame.fine("Pedina nera rimossa in: " + state.getBox(a.getRowTo(), a.getColumnTo() - 1));
Expand All @@ -352,7 +352,7 @@ private State checkCaptureWhite(State state, Action a) {
&& (state.getPawn(a.getRowTo() - 2, a.getColumnTo()).equalsPawn("W")
|| state.getPawn(a.getRowTo() - 2, a.getColumnTo()).equalsPawn("T")
|| state.getPawn(a.getRowTo() - 2, a.getColumnTo()).equalsPawn("K")
|| (this.citadels.contains(state.getBox(a.getRowTo() - 2, a.getColumnTo()))&&!(state.getPawn(a.getRowTo()-2, a.getColumnTo()).equalsPawn("B"))&&!(a.getColumnTo()==8&&a.getRowTo()-2==4)&&!(a.getColumnTo()==4&&a.getRowTo()-2==0)&&!(a.getColumnTo()==4&&a.getRowTo()-2==0)&&!(a.getColumnTo()==0&&a.getRowTo()-2==4)) )) {
|| (this.citadels.contains(state.getBox(a.getRowTo() - 2, a.getColumnTo()))&&!(a.getColumnTo()==8&&a.getRowTo()-2==4)&&!(a.getColumnTo()==4&&a.getRowTo()-2==0)&&!(a.getColumnTo()==4&&a.getRowTo()-2==0)&&!(a.getColumnTo()==0&&a.getRowTo()-2==4)) )) {
state.removePawn(a.getRowTo() - 1, a.getColumnTo());
this.movesWithutCapturing = -1;
this.loggGame.fine("Pedina nera rimossa in: " + state.getBox(a.getRowTo() - 1, a.getColumnTo()));
Expand All @@ -363,7 +363,7 @@ private State checkCaptureWhite(State state, Action a) {
&& (state.getPawn(a.getRowTo() + 2, a.getColumnTo()).equalsPawn("W")
|| state.getPawn(a.getRowTo() + 2, a.getColumnTo()).equalsPawn("T")
|| state.getPawn(a.getRowTo() + 2, a.getColumnTo()).equalsPawn("K")
|| (this.citadels.contains(state.getBox(a.getRowTo() + 2, a.getColumnTo()))&&!(state.getPawn(a.getRowTo()+2, a.getColumnTo()).equalsPawn("B"))&&!(a.getColumnTo()==8&&a.getRowTo()+2==4)&&!(a.getColumnTo()==4&&a.getRowTo()+2==0)&&!(a.getColumnTo()==4&&a.getRowTo()+2==0)&&!(a.getColumnTo()==0&&a.getRowTo()+2==4)))) {
|| (this.citadels.contains(state.getBox(a.getRowTo() + 2, a.getColumnTo()))&&!(a.getColumnTo()==8&&a.getRowTo()+2==4)&&!(a.getColumnTo()==4&&a.getRowTo()+2==0)&&!(a.getColumnTo()==4&&a.getRowTo()+2==0)&&!(a.getColumnTo()==0&&a.getRowTo()+2==4)))) {
state.removePawn(a.getRowTo() + 1, a.getColumnTo());
this.movesWithutCapturing = -1;
this.loggGame.fine("Pedina nera rimossa in: " + state.getBox(a.getRowTo() + 1, a.getColumnTo()));
Expand Down Expand Up @@ -1058,4 +1058,4 @@ public void clearDrawConditions() {
drawConditions.clear();
}

}
}

0 comments on commit 56a0271

Please sign in to comment.