Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e736fe1

Browse files
committed
-
2 parents c1ec09c + 495d95b commit e736fe1

File tree

1 file changed

+62
-11
lines changed

1 file changed

+62
-11
lines changed

src/search/game/Chess.java

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
public class Chess extends GameSearch {
2323

24+
// note: set the following to false if running in IntelliJ IDE: console does not display
25+
// unicode characters. Usually, you want to set to true (at least try it).
26+
static public boolean USE_UNICODE_CHARS = true; // set to true for graphics characters
27+
2428
/**
2529
* Notes: PROGRAM false -1, HUMAN true 1
2630
*/
@@ -114,20 +118,61 @@ public void printPosition(Position p) {
114118
}
115119
System.out.println();
116120
}
121+
117122
private String pp(int piece, int square_index) {
118123
if (piece == 0) return " ";
119-
String color;
120-
if (piece < 0) color = "B"; else color = "W";
121-
int p = piece; if (p < 0) p = -p;
122-
switch (p) {
123-
case 1: return " " + color + "P";
124-
case 2: return " " + color + "N";
125-
case 3: return " " + color + "B";
126-
case 4: return " " + color + "R";
127-
case 5: return " " + color + "Q";
128-
case 9: return " " + color + "K";
124+
if (USE_UNICODE_CHARS) {
125+
switch (piece) {
126+
case 1:
127+
return " \u2659 ";
128+
case 2:
129+
return " \u2658 ";
130+
case 3:
131+
return " \u2657 ";
132+
case 4:
133+
return " \u2656 ";
134+
case 5:
135+
return " \u2655 ";
136+
case 9:
137+
return " \u2654 ";
138+
case -1:
139+
return " \u265F ";
140+
case -2:
141+
return " \u265E ";
142+
case -3:
143+
return " \u265D ";
144+
case -4:
145+
return " \u265C ";
146+
case -5:
147+
return " \u265B ";
148+
case -9:
149+
return " \u265A ";
150+
}
151+
return "error";
152+
153+
154+
} else {
155+
String color;
156+
if (piece < 0) color = "B";
157+
else color = "W";
158+
int p = piece;
159+
if (p < 0) p = -p;
160+
switch (p) {
161+
case 1:
162+
return " " + color + "P";
163+
case 2:
164+
return " " + color + "N";
165+
case 3:
166+
return " " + color + "B";
167+
case 4:
168+
return " " + color + "R";
169+
case 5:
170+
return " " + color + "Q";
171+
case 9:
172+
return " " + color + "K";
173+
}
174+
return "error";
129175
}
130-
return "error";
131176
}
132177

133178
final public Position [] possibleMoves(Position p, boolean player) {
@@ -213,9 +258,15 @@ static public void main(String [] args) throws UnsupportedEncodingException {
213258
"\u265F " + // black pawn
214259
"\n" +
215260
"\u2610 " + "\u2612 " + "\u25A0 " + "\u25FC"; // trying for white and black squares
261+
<<<<<<< HEAD:src/search/game/Chess.java
216262
System.out.println(unicodeMessage);
217263
PrintStream out = new PrintStream (System.out, true , "UTF8" );
218264
out.println(unicodeMessage);
265+
=======
266+
//System.out.println(unicodeMessage);
267+
// PrintStream out = new PrintStream (System.out, true , "UTF8" );
268+
// out.println(unicodeMessage);
269+
>>>>>>> 495d95beea81d9738eb55f1535f51ddb2a12a29c:src-search-game/Chess.java
219270

220271
ChessPosition p = new ChessPosition();
221272
for (int i=0; i<120; i++) p.board[i] = initialBoard[i];

0 commit comments

Comments
 (0)