- public void run() throws IOException, InterruptedException {
- //Map<String, String> environment = processBuilder.environment();
- Process process = processBuilder.start();
- InputStream is = process.getInputStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(is));
- OutputStream os = process.getOutputStream();
- BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
-
- Thread engineThread = new Thread(
- new Runnable() {
- public void run() {
- Scanner scanner = new Scanner(br); //
- while (scanner.hasNextLine()) {
- System.out.println(scanner.nextLine());
- }
-/*
- String line;
- try {
- while ((line = br.readLine()) != null) {
- System.out.println(line);
- bw.write("isready");
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-*/
- System.out.println("Engine terminated.");
- }
- }
- );
- engineThread.start();
-
- bw.write("uci\n");
- bw.flush();
- bw.write("isready\n");
- bw.flush();
- bw.write("quit\n");
- bw.flush();
-
- //process.waitFor();
-
- }
-
-
- public static void main(String... args) throws Exception {
-/*
- String[] strings = " uci test one more test".trim().split("\\s+", 2);
- for (String string : strings)
- System.out.println(string);
-*/
-
- new ExternalEngineRunner("stockfish.exe").run();
- }
-