DroidFish: Use Locale.US for all text formatting.

This commit is contained in:
Peter Osterlund
2013-04-14 18:55:04 +00:00
parent ca757cebd7
commit a14a8250a1
13 changed files with 53 additions and 44 deletions

View File

@@ -21,6 +21,7 @@ package chess;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
/**
*
@@ -320,7 +321,7 @@ public class Game {
for (int i = 0; i < moveList.size(); i++) {
Move move = moveList.get(i);
String strMove = TextIO.moveToString(pos, move, false);
moves.append(String.format(" %s", strMove));
moves.append(String.format(Locale.US, " %s", strMove));
UndoInfo ui = new UndoInfo();
pos.makeMove(move, ui);
}
@@ -364,10 +365,10 @@ public class Game {
whiteMove = "...";
}
if (compressed) {
ret.append(String.format("%d. %s %s ",
ret.append(String.format(Locale.US, "%d. %s %s ",
pos.fullMoveCounter, whiteMove, blackMove));
} else {
ret.append(String.format("%3d. %-10s %-10s%n",
ret.append(String.format(Locale.US, "%3d. %-10s %-10s%n",
pos.fullMoveCounter, whiteMove, blackMove));
}
whiteMove = "";
@@ -381,10 +382,10 @@ public class Game {
whiteMove = "...";
}
if (compressed) {
ret.append(String.format("%d. %s %s ",
ret.append(String.format(Locale.US, "%d. %s %s ",
pos.fullMoveCounter, whiteMove, blackMove));
} else {
ret.append(String.format("%3d. %-8s %-8s%n",
ret.append(String.format(Locale.US, "%3d. %-8s %-8s%n",
pos.fullMoveCounter, whiteMove, blackMove));
}
}
@@ -393,7 +394,7 @@ public class Game {
if (compressed) {
ret.append(gameResult);
} else {
ret.append(String.format("%s%n", gameResult));
ret.append(String.format(Locale.US, "%s%n", gameResult));
}
}
return ret.toString();

View File

@@ -22,6 +22,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Locale;
/**
* A player that reads input from the keyboard.
@@ -39,7 +40,7 @@ public class HumanPlayer implements Player {
public String getCommand(Position pos, boolean drawOffer, List<Position> history) {
try {
String color = pos.whiteMove ? "white" : "black";
System.out.print(String.format("Enter move (%s):", color));
System.out.print(String.format(Locale.US, "Enter move (%s):", color));
String moveStr = in.readLine();
if (moveStr == null)
return "quit";

View File

@@ -18,6 +18,8 @@
package chess;
import java.util.Locale;
/**
*
* @author petero
@@ -560,7 +562,7 @@ public class TextIO {
*/
public static final String asciiBoard(Position pos) {
StringBuilder ret = new StringBuilder(400);
String nl = String.format("%n");
String nl = String.format(Locale.US, "%n");
ret.append(" +----+----+----+----+----+----+----+----+"); ret.append(nl);
for (int y = 7; y >= 0; y--) {
ret.append(" |");

View File

@@ -36,6 +36,7 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;
/**
@@ -71,20 +72,20 @@ public class ChessController {
private void setSearchInfo() {
StringBuilder buf = new StringBuilder();
buf.append(String.format("%n[%d] ", pvDepth));
buf.append(String.format(Locale.US, "%n[%d] ", pvDepth));
if (pvUpperBound) {
buf.append("<=");
} else if (pvLowerBound) {
buf.append(">=");
}
if (pvIsMate) {
buf.append(String.format("m%d", pvScore));
buf.append(String.format(Locale.US, "m%d", pvScore));
} else {
buf.append(String.format("%.2f", pvScore / 100.0));
buf.append(String.format(Locale.US, "%.2f", pvScore / 100.0));
}
buf.append(pvStr);
buf.append(String.format("%n"));
buf.append(String.format("d:%d %d:%s t:%.2f n:%d nps:%d", currDepth,
buf.append(String.format(Locale.US, "%n"));
buf.append(String.format(Locale.US, "d:%d %d:%s t:%.2f n:%d nps:%d", currDepth,
currMoveNr, currMove, currTime / 1000.0, currNodes, currNps));
final String newPV = buf.toString();
gui.runOnUIThread(new Runnable() {
@@ -121,7 +122,7 @@ public class ChessController {
Position pos = new Position(game.pos);
UndoInfo ui = new UndoInfo();
for (Move m : pv) {
buf.append(String.format(" %s", TextIO.moveToString(pos, m, false)));
buf.append(String.format(Locale.US, " %s", TextIO.moveToString(pos, m, false)));
pos.makeMove(m, ui);
}
pvStr = buf.toString();
@@ -211,17 +212,17 @@ public class ChessController {
month = now.get(Calendar.MONTH) + 1;
day = now.get(Calendar.DAY_OF_MONTH);
}
pgn.append(String.format("[Date \"%04d.%02d.%02d\"]%n", year, month, day));
pgn.append(String.format(Locale.US, "[Date \"%04d.%02d.%02d\"]%n", year, month, day));
String white = "Player";
String black = ComputerPlayer.engineName;
if (!humanIsWhite) {
String tmp = white; white = black; black = tmp;
}
pgn.append(String.format("[White \"%s\"]%n", white));
pgn.append(String.format("[Black \"%s\"]%n", black));
pgn.append(String.format("[Result \"%s\"]%n", game.getPGNResultString()));
pgn.append(String.format(Locale.US, "[White \"%s\"]%n", white));
pgn.append(String.format(Locale.US, "[Black \"%s\"]%n", black));
pgn.append(String.format(Locale.US, "[Result \"%s\"]%n", game.getPGNResultString()));
if (!fen.equals(TextIO.startPosFEN)) {
pgn.append(String.format("[FEN \"%s\"]%n", fen));
pgn.append(String.format(Locale.US, "[FEN \"%s\"]%n", fen));
pgn.append("[SetUp \"1\"]\n");
}
pgn.append("\n");