Skip to content

Commit

Permalink
Fixes #33, removed --threads 2 from the default config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
featurecat committed Nov 7, 2018
1 parent 84d8709 commit 37d00fd
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ src/main/resources/META-INF
target
leelaz_opencl_tuning
lizzie.sh
lizzie.jar
2 changes: 1 addition & 1 deletion src/main/java/featurecat/lizzie/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private JSONObject createDefaultConfig() {
leelaz.put(
"engine-command",
String.format(
"%s --gtp --lagbuffer 0 --weights %%network-file --threads 2",
"%s --gtp --lagbuffer 0 --weights %%network-file",
getBestDefaultLeelazPath()));
leelaz.put("engine-start-location", ".");
leelaz.put("max-analyze-time-minutes", 5);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/featurecat/lizzie/Lizzie.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Lizzie {
public static LizzieFrame frame;
public static Board board;
public static Leelaz leelaz;
public static String lizzieVersion = "0.5";
public static String lizzieVersion = "0.6";
private static String[] mainArgs;

/** Launches the game window, and runs the game. */
Expand Down
46 changes: 24 additions & 22 deletions src/main/java/featurecat/lizzie/analysis/Leelaz.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,32 @@ public void startEngine(String engineCommand) throws IOException {
String[] names = currentWeightFile.split("[\\\\|/]");
currentWeight = names.length > 1 ? names[names.length - 1] : currentWeightFile;
}

// Check if engine is present
File startfolder = new File(config.optString("engine-start-location", "."));
File lef = startfolder.toPath().resolve(new File(commands.get(0)).toPath()).toFile();
if (!lef.exists()) {
JOptionPane.showMessageDialog(
null,
resourceBundle.getString("LizzieFrame.display.leelaz-missing"),
"Lizzie - Error!",
JOptionPane.ERROR_MESSAGE);
throw new IOException("engine not present");
}

// Check if network file is present
File wf = startfolder.toPath().resolve(new File(currentWeightFile).toPath()).toFile();
if (!wf.exists()) {
JOptionPane.showMessageDialog(
null, resourceBundle.getString("LizzieFrame.display.network-missing"));
throw new IOException("network-file not present");
}

//
// // Check if engine is present
// File startfolder = new File(config.optString("engine-start-location", "."));
// File lef = startfolder.toPath().resolve(new File(commands.get(0)).toPath()).toFile();
// System.out.println(lef.getPath());
// if (!lef.exists()) {
// JOptionPane.showMessageDialog(
// null,
// resourceBundle.getString("LizzieFrame.display.leelaz-missing"),
// "Lizzie - Error!",
// JOptionPane.ERROR_MESSAGE);
// throw new IOException("engine not present");
// }
//
// // Check if network file is present
// File wf = startfolder.toPath().resolve(new File(currentWeightFile).toPath()).toFile();
// if (!wf.exists()) {
// JOptionPane.showMessageDialog(
// null, resourceBundle.getString("LizzieFrame.display.network-missing"));
// throw new IOException("network-file not present");
// }

// todo enable
// run leelaz
ProcessBuilder processBuilder = new ProcessBuilder(commands);
processBuilder.directory(startfolder);
// processBuilder.directory(startfolder); // todo enable
processBuilder.redirectErrorStream(true);
process = processBuilder.start();

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/featurecat/lizzie/gui/BoardRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private void drawGoban(Graphics2D g0) {

cachedBackgroundImage = new BufferedImage(width, height, TYPE_INT_ARGB);
Graphics2D g = cachedBackgroundImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

// Draw the wooden background
drawWoodenBoard(g);
Expand Down Expand Up @@ -293,7 +294,9 @@ private void drawStones() {
cachedStonesImage = new BufferedImage(boardLength, boardLength, TYPE_INT_ARGB);
cachedStonesShadowImage = new BufferedImage(boardLength, boardLength, TYPE_INT_ARGB);
Graphics2D g = cachedStonesImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
Graphics2D gShadow = cachedStonesShadowImage.createGraphics();
gShadow.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

// we need antialiasing to make the stones pretty. Java is a bit slow at antialiasing; that's
// why we want the cache
Expand Down Expand Up @@ -323,6 +326,7 @@ private void drawStones() {
*/
private void drawScore(Graphics2D go) {
Graphics2D g = cachedStonesImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
Stone scorestones[] = Lizzie.board.scoreStones();
int scoreRadius = stoneRadius / 4;
for (int i = 0; i < Board.boardSize; i++) {
Expand Down Expand Up @@ -369,7 +373,9 @@ private void drawBranch() {
}

Graphics2D g = (Graphics2D) branchStonesImage.getGraphics();
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
Graphics2D gShadow = (Graphics2D) branchStonesShadowImage.getGraphics();
gShadow.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

Optional<MoveData> suggestedMove = (isMainBoard ? mouseOveredMove() : getBestMove());
if (!suggestedMove.isPresent()) {
Expand Down Expand Up @@ -852,6 +858,7 @@ private BufferedImage getScaleStone(boolean isBlack, int size) {
stoneImage = new BufferedImage(size, size, TYPE_INT_ARGB);
Image img = isBlack ? Lizzie.config.theme.blackStone() : Lizzie.config.theme.whiteStone();
Graphics2D g2 = stoneImage.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2.drawImage(img.getScaledInstance(size, size, java.awt.Image.SCALE_SMOOTH), 0, 0, null);
g2.dispose();
if (isBlack) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/featurecat/lizzie/gui/LizzieFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ public void paint(Graphics g0) {

cachedImage = new BufferedImage(getWidth(), getHeight(), TYPE_INT_ARGB);
Graphics2D g = (Graphics2D) cachedImage.getGraphics();
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

if (Lizzie.config.showStatus) drawCommandString(g);

Expand Down Expand Up @@ -520,6 +521,7 @@ public void paint(Graphics g0) {

// draw the image
Graphics2D bsGraphics = (Graphics2D) bs.getDrawGraphics();
bsGraphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
bsGraphics.drawImage(cachedBackground, 0, 0, null);
bsGraphics.drawImage(cachedImage, 0, 0, null);

Expand Down Expand Up @@ -548,6 +550,7 @@ private Graphics2D createBackground() {
redrawBackgroundAnyway = false;

Graphics2D g = cachedBackground.createGraphics();
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

BufferedImage wallpaper = boardRenderer.getWallpaper();
int drawWidth = max(wallpaper.getWidth(), getWidth());
Expand Down

0 comments on commit 37d00fd

Please sign in to comment.