-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoard.java
More file actions
61 lines (53 loc) · 1.68 KB
/
Board.java
File metadata and controls
61 lines (53 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
public class Board {
// Chess board is 8x8
// Coordinates start at 1 and end at 8
public Square[][] boardList;
public Board() {
this.boardList = new Square[8][8];
for (int i = 0; i < boardList.length; i++) {
for (int j = 0; j < boardList[0].length; j++) {
boardList[i][j] = new Square(i + 1, j + 1);
}
}
}
public Square getSquare(int x, int y) {
return boardList[8-y][x-1];
}
// For Testing
public String showInfluence(Piece p) {
String retString = "";
Square[] bList = p.influence(this);
for (int i = 0; i < boardList.length; i++) {
for (int j = 0; j < boardList[0].length; j++) {
if (boardList[i][j].squareInArray(bList)) {
retString += p.toString() + "i ";
} else {
retString += boardList[i][j].toString();
}
}
retString += "\n";
}
return retString;
}
public String toString() {
String retString = "";
for (int i = 0; i < boardList.length; i++) {
for (int j = 0; j < boardList[0].length; j++) {
retString += boardList[i][j].toString();
}
retString += "\n";
}
return retString;
}
// THIS DOESN'T WORK YET
public boolean isLegalPosition() {
return true;
}
// getAdjacentTiles, getRank, getFile, and getDiagonals might be helpful methods.
// public Square[] getRank(Square current) {
// for (int i = 0; i < 8; i++) {
//
// }
// Square[] returnarr = boardList[current.x][:]
// }
}