private void listCommands() { try { m_gtp.querySupportedCommands(); } catch (GtpError error) { System.out.println(error.getMessage()); return; } ArrayList<String> commands = m_gtp.getSupportedCommands(); for (int i = 0; i < commands.size(); ++i) System.out.println(commands.get(i)); }
private boolean newGame(int size) { String command; StringBuilder response = new StringBuilder(); command = m_gtp.getCommandBoardsize(size); if (command != null && !send(command, response)) { System.out.println(response); return false; } command = m_gtp.getCommandClearBoard(size); if (!send(command, response)) { System.out.println(response); return false; } initGame(size); return true; }
private boolean send(String cmd, StringBuilder response) { try { response.append(m_gtp.send(cmd)); return true; } catch (GtpError error) { response.append(error.getMessage()); return false; } }
private boolean cmdPlay(GoColor color, GoPoint point) { String command = m_gtp.getCommandPlay(Move.get(color, point)); StringBuilder response = new StringBuilder(); if (!send(command, response)) { System.out.println(response); return false; } play(Move.get(color, point)); return true; }
private void genmove() { GoColor toMove = m_board.getToMove(); String command = m_gtp.getCommandGenmove(toMove); StringBuilder response = new StringBuilder(); if (!send(command, response)) { System.out.println(response); return; } try { GoPoint point = GtpUtil.parsePoint(response.toString(), m_board.getSize()); System.out.println("Computer move: " + GoPoint.toString(point)); play(Move.get(toMove, point)); printBoard(); } catch (GtpResponseFormatError e) { System.out.println(response); } }