Movement logic

This commit is contained in:
FyloZ 2023-03-20 17:41:13 -04:00
parent 86e3b5acc2
commit ec7f3568e5
Signed by: william
GPG Key ID: 835378AE9AF4AE97
7 changed files with 312 additions and 79 deletions

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -4,12 +4,13 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="41395b4b-3252-492c-a869-5f4dab107186" name="Changes" comment=""> <list default="true" id="41395b4b-3252-492c-a869-5f4dab107186" name="Changes" comment="MiniMax">
<change afterPath="$PROJECT_DIR$/src/main/java/laboratoire4/GameTree.java" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/main/java/laboratoire4/Pushed.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/laboratoire4/Player.java" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/main/java/laboratoire4/Pusher.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/laboratoire4/MiniMax.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/laboratoire4/MiniMax.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/laboratoire4/GameTree.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/laboratoire4/GameTree.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/laboratoire4/Pawn.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/laboratoire4/Pawn.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/laboratoire4/PusherBoard.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/laboratoire4/PusherBoard.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -23,6 +24,13 @@
</list> </list>
</option> </option>
</component> </component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="alexis" />
</map>
</option>
</component>
<component name="MacroExpansionManager"> <component name="MacroExpansionManager">
<option name="directoryName" value="x0367gi2" /> <option name="directoryName" value="x0367gi2" />
</component> </component>
@ -44,19 +52,19 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"RunOnceActivity.OpenProjectViewOnStart": "true", &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"SHARE_PROJECT_CONFIGURATION_FILES": "true", &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
"last_opened_file_path": "/home/william/Dev/Projects/Uni/Log320/LOG320_Lab4", &quot;last_opened_file_path&quot;: &quot;/home/william/Dev/Projects&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
} }
}]]></component> }</component>
<component name="RunManager"> <component name="RunManager">
<configuration name="Client" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> <configuration name="Client" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="laboratoire4.Client" /> <option name="MAIN_CLASS_NAME" value="laboratoire4.Client" />
@ -86,11 +94,25 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1679255648701</updated> <updated>1679255648701</updated>
<workItem from="1679255649975" duration="1223000" /> <workItem from="1679255649975" duration="1223000" />
<workItem from="1679261446095" duration="1908000" /> <workItem from="1679261446095" duration="1927000" />
<workItem from="1679281763874" duration="46000" />
<workItem from="1679344371350" duration="3857000" />
</task> </task>
<task id="LOCAL-00001" summary="MiniMax">
<created>1679263366439</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1679263366439</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="MiniMax" />
<option name="LAST_COMMIT_MESSAGE" value="MiniMax" />
</component>
</project> </project>

View File

@ -5,8 +5,7 @@ import java.util.Collection;
public class GameTree { public class GameTree {
private Node root; private Node root;
public Node buildTree(PusherBoard board){
public Node buildTree(){
return null; return null;
} }

View File

@ -1,8 +1,56 @@
package laboratoire4; package laboratoire4;
public enum Pawn { public abstract class Pawn {
R_PUSHER, protected final PawnColor color;
R_PUSHED, protected int col;
B_PUSHER, protected int row;
B_PUSHED
public Pawn(PawnColor color, int col, int row) {
this.color = color;
this.col = col;
this.row = row;
}
public PawnColor getColor() {
return color;
}
public int getCol() {
return col;
}
public int getRow() {
return row;
}
public void setCol(int col) {
this.col = col;
}
public void setRow(int row) {
this.row = row;
}
public abstract boolean isMoveValid(PusherBoard board, PawnMovement movement);
enum PawnColor {
RED,
BLACK
}
enum PawnMovement {
STRAIGHT(0),
LEFT_DIAGONAL(-1),
RIGHT_DIAGONAL(1);
private final int move;
PawnMovement(int move) {
this.move = move;
}
public int getMove() {
return move;
}
}
} }

View File

@ -0,0 +1,26 @@
package laboratoire4;
public class Pushed extends Pawn {
public Pushed(PawnColor color, int col, int row) {
super(color, col, row);
}
@Override
public boolean isMoveValid(PusherBoard game, PawnMovement movement) {
Pawn[][] board = game.getBoard();
Pawn pusher = null;
Pawn to = board[row + 1][col + movement.getMove()];
if (col > 0 && movement == PawnMovement.RIGHT_DIAGONAL) {
pusher = board[row - 1][col - 1];
} else if (col < board.length - 1 && movement == PawnMovement.LEFT_DIAGONAL) {
pusher = board[row - 1][col + 1];
} else if (movement == PawnMovement.STRAIGHT) {
pusher = board[row - 1][col];
}
boolean pusherValid = pusher != null;
boolean destinationValid = to == null || to.color != this.color;
return pusherValid && destinationValid;
}
}

View File

@ -0,0 +1,14 @@
package laboratoire4;
public class Pusher extends Pawn {
public Pusher(PawnColor color, int col, int row) {
super(color, col, row);
}
@Override
public boolean isMoveValid(PusherBoard game, PawnMovement movement) {
Pawn to = game.getBoard()[row + 1][col + movement.getMove()];
return to == null || to.color != this.color;
}
}

View File

@ -1,57 +1,58 @@
package laboratoire4; package laboratoire4;
public class PusherBoard { public class PusherBoard {
private Pawn[][] board; private Pawn[][] board;
public PusherBoard() { public PusherBoard() {
this.newGame(); this.newGame();
} }
public void newGame(){ public void newGame() {
this.board = new Pawn[8][8]; this.board = new Pawn[8][8];
for(int i = 0 ;i<board.length;i++){ // TODO: Construire depuis le serveur
board[7][i] = Pawn.B_PUSHER; for (int i = 0; i < board.length; i++) {
} for (int j = 0; j < board.length; j++) {
Pawn pawn = null;
Pawn.PawnColor color = i < board.length / 2 ?
Pawn.PawnColor.RED :
Pawn.PawnColor.BLACK;
for(int i = 0 ;i<board.length;i++){ if (i == 0 || i == board.length - 1) {
board[6][i] = Pawn.B_PUSHED; pawn = new Pusher(color, i, j);
} } else if (i == 1 || i == board.length - 2) {
pawn = new Pushed(color, i, j);
}
for(int i = 0 ;i<board.length;i++){ board[i][j] = pawn;
board[1][i] = Pawn.R_PUSHED; }
}
for(int i = 0 ;i<board.length;i++){
board[0][i] = Pawn.R_PUSHER;
} }
} }
public int move (String move){ public int move(String move) {
//FORMAT ex : D2-D3 //FORMAT ex : D2-D3
String[] split = move.split("-"); String[] split = move.split("-");
return move(split[0],split[1]); return move(split[0], split[1]);
} }
public int move (String from, String to){ public int move(String from, String to) {
//FORMAT ex : from {D2}, to {D3} //FORMAT ex : from {D2}, to {D3}
int from_col = (int) from.charAt(0) - 65; int from_col = (int) from.charAt(0) - 65;
int from_row = Integer.parseInt(String.valueOf(from.charAt(1)))-1; int from_row = Integer.parseInt(String.valueOf(from.charAt(1))) - 1;
int to_col = (int) to.charAt(0) - 65; int to_col = (int) to.charAt(0) - 65;
int to_row = Integer.parseInt(String.valueOf(to.charAt(1)))-1; int to_row = Integer.parseInt(String.valueOf(to.charAt(1))) - 1;
return move(from_col, from_row, to_col, to_row); return move(from_col, from_row, to_col, to_row);
} }
public int move(int from_col, int from_row, int to_col, int to_row){ public int move(int from_col, int from_row, int to_col, int to_row) {
//FORMAT ex : from_col {3}, from_row {2}, to_col {3}, to_row {3} //FORMAT ex : from_col {3}, from_row {2}, to_col {3}, to_row {3}
//System.out.println("Move :" + from_col+""+from_row + "-"+ to_col+""+to_row); //System.out.println("Move :" + from_col+""+from_row + "-"+ to_col+""+to_row);
//System.out.println("Move is valid : " + isValid(from_col,from_row,to_col,to_row)); //System.out.println("Move is valid : " + isValid(from_col,from_row,to_col,to_row));
if(isValid(from_col,from_row,to_col,to_row)){ if (isValid(from_col, from_row, to_col, to_row)) {
Pawn pawn = this.getBoard()[from_row][from_col]; Pawn pawn = this.getBoard()[from_row][from_col];
//System.out.println("Pawn to move : " + pawn); //System.out.println("Pawn to move : " + pawn);
this.getBoard()[from_row][from_col] = null; this.getBoard()[from_row][from_col] = null;
@ -62,54 +63,54 @@ public class PusherBoard {
} }
private boolean isValid(int from_col, int from_row, int to_col, int to_row){ private boolean isValid(int from_col, int from_row, int to_col, int to_row) {
Pawn[][] board = this.getBoard(); Pawn[][] board = this.getBoard();
//out of bound? //out of bound?
if((from_col >7 || from_col<0)||((from_row >7 || from_row<0))||((to_col >7 || to_col<0))||((to_row >7 || to_row<0))) return false; if ((from_col > 7 || from_col < 0) || ((from_row > 7 || from_row < 0)) || ((to_col > 7 || to_col < 0)) || ((to_row > 7 || to_row < 0)))
return false;
//no pawn to move? //no pawn to move?
Pawn pawnToMove = board[from_row][from_col]; Pawn pawnToMove = board[from_row][from_col];
if(pawnToMove == null) return false; if (pawnToMove == null) return false;
//Pawn at destination is our own pawn? //Pawn at destination is our own pawn?
Pawn destination = board[to_row][to_col]; Pawn destination = board[to_row][to_col];
char source_color = pawnToMove.name().charAt(0); char source_color = pawnToMove.name().charAt(0);
if(destination != null){ if (destination != null) {
char destination_color = destination.name().charAt(0); char destination_color = destination.name().charAt(0);
if(source_color == destination_color) return false; if (source_color == destination_color) return false;
} }
//Pawn goes back? or move is in valid range? //Pawn goes back? or move is in valid range?
if(source_color == 'R'){ if (source_color == 'R') {
if(from_row>to_row) return false; if (from_row > to_row) return false;
if(from_row+1 != to_row) return false; if (from_row + 1 != to_row) return false;
}else if(source_color == 'B'){ } else if (source_color == 'B') {
if(from_row<to_row) return false; if (from_row < to_row) return false;
if(from_row-1 != to_row) return false; if (from_row - 1 != to_row) return false;
} }
//PUSHED is in front a PUSHER? //PUSHED is in front a PUSHER?
if(pawnToMove.equals(Pawn.B_PUSHED)){ if (pawnToMove.equals(Pawn.B_PUSHED)) {
if(from_col+1==to_col){ if (from_col + 1 == to_col) {
if(board[from_row+1][from_col+1] != Pawn.B_PUSHER) return false; return board[from_row + 1][from_col + 1] == Pawn.B_PUSHER;
}else if(from_col-1==to_col){ } else if (from_col - 1 == to_col) {
if(board[from_row-1][from_col+1] != Pawn.B_PUSHER) return false; return board[from_row - 1][from_col + 1] == Pawn.B_PUSHER;
}else if(from_col==to_col){ } else if (from_col == to_col) {
if(board[from_row+1][from_col] != Pawn.B_PUSHER) return false; return board[from_row + 1][from_col] == Pawn.B_PUSHER;
} }
}else if(pawnToMove.equals(Pawn.R_PUSHED)){ } else if (pawnToMove.equals(Pawn.R_PUSHED)) {
if(from_col+1 == to_col){ if (from_col + 1 == to_col) {
if(board[from_row+1][from_col-1] != Pawn.R_PUSHER) return false; return board[from_row + 1][from_col - 1] == Pawn.R_PUSHER;
}else if(from_col-1 == to_col){ } else if (from_col - 1 == to_col) {
if(board[from_row-1][from_col-1] != Pawn.R_PUSHER) return false; return board[from_row - 1][from_col - 1] == Pawn.R_PUSHER;
}else if(from_col == to_col){ } else if (from_col == to_col) {
if(board[from_row-1][from_col] != Pawn.R_PUSHER) return false; return board[from_row - 1][from_col] == Pawn.R_PUSHER;
} }
} }
return true; return true;
} }
@ -117,13 +118,12 @@ public class PusherBoard {
return board; return board;
} }
public void printBoard(){ public void printBoard() {
for (int i = 7; i >= 0; i--) {
for(int i=7; i>=0; i--){ for (int j = 0; j < this.board.length; j++) {
for (int j = 0 ; j < this.board.length; j++){ if (this.board[i][j] != null) {
if(this.board[i][j] != null){
System.out.print(this.board[i][j] + " | "); System.out.print(this.board[i][j] + " | ");
}else{ } else {
System.out.print(" | "); System.out.print(" | ");
} }
} }