icfp-solver/src/main/java/ru/bosony/solvers/Solver.java
changeset 38 0af2bd7f816a
parent 35 63f356432f75
child 39 27b98e729716
equal deleted inserted replaced
37:6b5044129537 38:0af2bd7f816a
     1 package ru.bosony.solvers;
     1 package ru.bosony.solvers;
     2 
     2 
     3 import java.io.BufferedWriter;
       
     4 import java.io.IOException;
     3 import java.io.IOException;
     5 import java.io.OutputStreamWriter;
       
     6 
     4 
     7 import ru.bosony.model.mine.Mine;
     5 import ru.bosony.model.mine.Mine;
     8 
     6 
     9 /**
     7 /**
    10  * @author indvdum (gotoindvdum[at]gmail[dot]com) <br>
     8  * @author indvdum (gotoindvdum[at]gmail[dot]com) <br>
    11  *         16.07.2012 2:16:03
     9  *         16.07.2012 2:16:03
    12  * 
    10  * 
    13  */
    11  */
    14 public class Solver {
    12 public class Solver {
    15 
    13 
    16 	protected Mine				mine;
    14 	protected Mine		mine;
    17 	protected BufferedWriter	writer;
    15 	protected String	route	= "A";
    18 
    16 
    19 	public Solver(Mine mine) {
    17 	public Solver(Mine mine) {
    20 		this.mine = mine;
    18 		this.mine = mine;
    21 		writer = new BufferedWriter(new OutputStreamWriter(System.out));
       
    22 	}
    19 	}
    23 
    20 
    24 	public void start() throws IOException {
    21 	public void start() throws IOException, InterruptedException {
       
    22 		Runtime.getRuntime().addShutdownHook(new Thread() {
       
    23 			@Override
       
    24 			public void run() {
       
    25 				System.out.println(route);
       
    26 			}
       
    27 		});
    25 		// TODO solver
    28 		// TODO solver
    26 		writer.write("A");
    29 		while (true) {
    27 		writer.flush();
    30 			Thread.sleep(1000);
       
    31 		}
    28 	}
    32 	}
    29 
    33 
    30 	public static void main(String[] args) throws IOException {
    34 	public static void main(String[] args) throws IOException, InterruptedException {
    31 		String map = "";
    35 		String map = "";
    32 		for (String arg : args) {
    36 		for (String arg : args) {
    33 			map += arg + "\n";
    37 			map += arg + "\n";
    34 		}
    38 		}
    35 		map = map.replaceAll("\n$", "");
    39 		map = map.replaceAll("\n$", "");