import java.util.*;
import java.io.*;

public class Tron {

	//We can't print to console, because that channel is used for IO with the environment.
	//We therefore create a PrintWriter and output to that. Use "OutputDebug" rather than "System.out.print".
	public static PrintWriter debug;
	public static <T> void log(T s) {
		if(debug != null) {
			debug.append(s.toString());
			debug.flush();
		}
	}

	public static enum Direction {
		NORTH, EAST, SOUTH, WEST
	}

	public static enum Tile {
		EMPTY, PLAYER1, PLAYER2, 
		TAKEN_BY_PLAYER1, TAKEN_BY_PLAYER2
	}

	public static void init() {
		try {
			debug = new PrintWriter(new FileOutputStream(new File("debug"+getString().trim()+".log"))); //Cast to seconds.
		} catch(Exception e) {
			System.out.println("Debug file could not be open.");
			System.exit(1);
		}
	}

	private static int[][] deserializeMap(String mapString) {
		String[] tiles = mapString.trim().split(" ");
		int[] tileVals = new int[tiles.length];
		for (int i=0; i<tiles.length; i++) tileVals[i] = Integer.parseInt(tiles[i].trim());

		int[][] map = new int[16][16];
		for (int i=0; i<16; i++) map[i] = Arrays.copyOfRange(tileVals,i*16,(i+1)*16);
		return map;
	}

	private static String getString() {
		try {
			StringBuilder builder = new StringBuilder();
			int buffer;
			while ((buffer = System.in.read()) >= 0) {
				if (buffer == '\n') {
					break;
				} else {
					builder = builder.append((char)buffer);
				}
			}
			return builder.toString();
		} catch(Exception e) {
			System.exit(1);
			return null;
		}
    }

	public static int[][] getMap() {
		String message = getString().trim();
		if(message.equals("KILL")) {
			System.exit(0);
		}
		return deserializeMap(message);
	}

	public static void sendMove(Direction move) {
		System.out.print(move.ordinal()+"\n");
		System.out.flush();
	}
}
@@ -300,12 +300,8 @@
 atic
- %3CT%3E
  voi
@@ -306,17 +306,22 @@
 oid log(
-T
+Object
  s) %7B%0A%09%09
@@ -391,24 +391,147 @@
 sh();%0A%09%09%7D%0A%09%7D
+%0A%09public static void logln(Object s) %7B%0A%09%09if(debug != null) %7B%0A%09%09%09debug.append(s.toString() + %22%5Cn%22);%0A%09%09%09debug.flush();%0A%09%09%7D%0A%09%7D
 %0A%0A%09public st
@@ -623,24 +623,20 @@
 TY, 
-PLAYER1, PLAYER2
+ME, OPPONENT
 , %0A%09
@@ -649,15 +649,10 @@
 _BY_
-PLAYER1
+ME
 , TA
@@ -662,15 +662,22 @@
 _BY_
-PLAYER2
+OPPONENT, WALL
 %0A%09%7D%0A
@@ -952,23 +952,42 @@
  static 
-int%5B%5D%5B%5D
+ArrayList%3CArrayList%3CTile%3E%3E
  deseria
@@ -1062,23 +1062,34 @@
 t(%22 %22);%0A
+%0A
 %09%09
-int%5B%5D
+ArrayList%3CTile%3E
  tileVal
@@ -1100,25 +1100,25 @@
 new 
-int%5Btiles.length%5D
+ArrayList%3CTile%3E()
 ;%0A%09%09
@@ -1160,22 +1160,35 @@
 tileVals
-%5Bi%5D = 
+.add(Tile.values()%5B
 Integer.
@@ -1216,108 +1216,155 @@
 m())
-;%0A%0A%09%09int%5B%5D%5B%5D map = new int%5B16%5D%5B16%5D;%0A%09%09for (int i=0; i%3C16; i++) map%5Bi%5D = Arrays.copyOfRange(tileVals,
+%5D);%0A%0A%0A%09%09ArrayList%3CArrayList%3CTile%3E%3E map = new ArrayList%3CArrayList%3CTile%3E%3E();%0A%09%09for (int i=0; i%3C16; i++) map.add(new ArrayList%3CTile%3E(tileVals.subList(
 i*16
@@ -1373,16 +1373,18 @@
 i+1)*16)
+))
 ;%0A%09%09retu
@@ -1776,15 +1776,34 @@
 tic 
-int%5B%5D%5B%5D
+ArrayList%3CArrayList%3CTile%3E%3E
  get

Update Tron.java in Java Tutorials Folder