// Path: PacMan-vs-Ghosts/src/game/PacManSimulator.java
// public static class GameConfig {
// 		
// 	public int seed = -1;
// 		
// 	/**
// 	 * Whether POWER PILLS should be present within the environment.
// 	 */
// 	public boolean powerPillsEnabled = true;
// 		
// 	/**
// 	 * Total percentage of PILLS present within the level. If < 1, some (random) pills will be taken away.
// 	 */
// 	public double totalPills = 1;
// 		
// 	/**
// 	 * How many levels Ms PacMan may play (-1 => unbound).
// 	 */
// 	public int levelsToPlay = -1;
// 		
// 	public GameConfig clone() {
// 		GameConfig result = new GameConfig();
// 			
// 		result.seed = seed;
// 		result.powerPillsEnabled = powerPillsEnabled;
// 		result.totalPills = totalPills;
// 		result.levelsToPlay = levelsToPlay;
// 			
// 		return result;
// 	}
// 
// 	public String asString() {
// 		return "" + seed + ";" + powerPillsEnabled + ";" + totalPills + ";" + levelsToPlay;
// 	}
// 		
// 	public void fromString(String line) {
// 		String[] all = line.split(";");
// 		seed = Integer.parseInt(all[0]);
// 		powerPillsEnabled = Boolean.parseBoolean(all[1]);
// 		totalPills = Double.parseDouble(all[2]);
// 		levelsToPlay = Integer.parseInt(all[3]);
// 	}
// 
// 	public String getCSVHeader() {
// 		return "seed;powerPillsEnabled;totalPills;levelsToPlay";
// 	}
// 		
// 	public String getCSV() {
// 		return "" + seed + ";" + powerPillsEnabled + ";" + totalPills + ";" + levelsToPlay;
// 	}
// 		
// }
// 
// Path: PacMan-vs-Ghosts/src/game/controllers/Direction.java
// public enum Direction {
// 	
// 	NONE(-1, 0, 0), UP(Game.UP, 0, -1), RIGHT(Game.RIGHT, 1, 0), DOWN(Game.DOWN, 0, 1), LEFT(Game.LEFT, -1, 0);
// 	
// 	private static Direction[] arrows = new Direction[]{UP, RIGHT, DOWN, LEFT};
// 	
// 	private static List<Direction> arrowsList = null;
// 	
// 	private static Map<Integer, Direction> indices = null;
// 	
// 	public final int index;
// 	public final int dX;
// 	public final int dY;
// 
// 	private Direction(int directionIndex, int dX, int dY) {
// 		this.index = directionIndex;
// 		this.dX = dX;
// 		this.dY = dY;
// 	}
// 	
// 	public Direction opposite() {
// 		switch(this) {
// 		case NONE: return NONE;
// 		case DOWN: return UP;
// 		case LEFT: return RIGHT;
// 		case RIGHT: return LEFT;
// 		case UP: return DOWN;
// 		}
// 		return null;
// 	}
// 	
// 	public Direction cw() {
// 		switch(this) {
// 		case NONE: return NONE;
// 		case DOWN: return LEFT;
// 		case LEFT: return UP;
// 		case RIGHT: return DOWN;
// 		case UP: return RIGHT;
// 		}
// 		return null;
// 	}
// 	
// 	public Direction ccw() {
// 		switch(this) {
// 		case NONE: return NONE;
// 		case DOWN: return RIGHT;
// 		case LEFT: return DOWN;
// 		case RIGHT: return UP;
// 		case UP: return LEFT;
// 		}
// 		return null;
// 	}
// 	
// 	public static Direction forIndex(int directionIndex) {
// 		if (indices == null) {
// 			indices = new HashMap<Integer, Direction>();
// 			for (Direction dir : values()) {
// 				indices.put(dir.index, dir);
// 			}
// 		}
// 		Direction dir = indices.get(directionIndex);
// 		if (dir == null) return NONE;
// 		return dir;
// 	}
// 	
// 	/**
// 	 * UP, RIGHT, DOWN, LEFT
// 	 * @return
// 	 */
// 	public static Direction[] arrows() {
// 		return arrows;
// 	}
// 	
// 	/**
// 	 * UP, RIGHT, DOWN, LEFT
// 	 * @return
// 	 */
// 	public static List<Direction> arrowsList() {
// 		if (arrowsList == null) {
// 			arrowsList = new ArrayList<Direction>(4);
// 			for (Direction d : arrows) {
// 				arrowsList.add(d);
// 			}
// 		}
// 		return arrowsList;
// 	}
// 	
// 
// }


import game.PacManSimulator.GameConfig;
import game.controllers.Direction;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/*
 * Implementation of "Ms Pac-Man" for the "Ms Pac-Man versus Ghost Team Competition", brought
 * to you by Philipp Rohlfshagen, David Robles and Simon Lucas of the University of Essex.
 * 
 * www.pacman-vs-ghosts.net
 * 
 * Code written by Philipp Rohlfshagen, based on earlier implementations of the game by
 * Simon Lucas and David Robles. 
 * 
 * You may use and distribute this code freely for non-commercial purposes. This notice 
 * needs to be included in all distributions. Deviations from the original should be 
 * clearly documented. We welcome any comments and suggestions regarding the code.
 */
package game.core;



public class _G_ extends G
{
	public static final int EDIBLE_ALERT=30;	//for display only (ghosts turning blue)
	
	//to save replays
	private int pacManDir=G.INITIAL_PAC_DIR;
	private StringBuilder sb;

	public _G_(){}
	
	//Instantiates everything to start a new game
// Path: PacMan-vs-Ghosts/src/game/PacManSimulator.java
// public static class GameConfig {
// 		
// 	public int seed = -1;
// 		
// 	/**
// 	 * Whether POWER PILLS should be present within the environment.
// 	 */
// 	public boolean powerPillsEnabled = true;
// 		
// 	/**
// 	 * Total percentage of PILLS present within the level. If < 1, some (random) pills will be taken away.
// 	 */
// 	public double totalPills = 1;
// 		
// 	/**
// 	 * How many levels Ms PacMan may play (-1 => unbound).
// 	 */
// 	public int levelsToPlay = -1;
// 		
// 	public GameConfig clone() {
// 		GameConfig result = new GameConfig();
// 			
// 		result.seed = seed;
// 		result.powerPillsEnabled = powerPillsEnabled;
// 		result.totalPills = totalPills;
// 		result.levelsToPlay = levelsToPlay;
// 			
// 		return result;
// 	}
// 
// 	public String asString() {
// 		return "" + seed + ";" + powerPillsEnabled + ";" + totalPills + ";" + levelsToPlay;
// 	}
// 		
// 	public void fromString(String line) {
// 		String[] all = line.split(";");
// 		seed = Integer.parseInt(all[0]);
// 		powerPillsEnabled = Boolean.parseBoolean(all[1]);
// 		totalPills = Double.parseDouble(all[2]);
// 		levelsToPlay = Integer.parseInt(all[3]);
// 	}
// 
// 	public String getCSVHeader() {
// 		return "seed;powerPillsEnabled;totalPills;levelsToPlay";
// 	}
// 		
// 	public String getCSV() {
// 		return "" + seed + ";" + powerPillsEnabled + ";" + totalPills + ";" + levelsToPlay;
// 	}
// 		
// }
// 
// Path: PacMan-vs-Ghosts/src/game/controllers/Direction.java
// public enum Direction {
// 	
// 	NONE(-1, 0, 0), UP(Game.UP, 0, -1), RIGHT(Game.RIGHT, 1, 0), DOWN(Game.DOWN, 0, 1), LEFT(Game.LEFT, -1, 0);
// 	
// 	private static Direction[] arrows = new Direction[]{UP, RIGHT, DOWN, LEFT};
// 	
// 	private static List<Direction> arrowsList = null;
// 	
// 	private static Map<Integer, Direction> indices = null;
// 	
// 	public final int index;
// 	public final int dX;
// 	public final int dY;
// 
// 	private Direction(int directionIndex, int dX, int dY) {
// 		this.index = directionIndex;
// 		this.dX = dX;
// 		this.dY = dY;
// 	}
// 	
// 	public Direction opposite() {
// 		switch(this) {
// 		case NONE: return NONE;
// 		case DOWN: return UP;
// 		case LEFT: return RIGHT;
// 		case RIGHT: return LEFT;
// 		case UP: return DOWN;
// 		}
// 		return null;
// 	}
// 	
// 	public Direction cw() {
// 		switch(this) {
// 		case NONE: return NONE;
// 		case DOWN: return LEFT;
// 		case LEFT: return UP;
// 		case RIGHT: return DOWN;
// 		case UP: return RIGHT;
// 		}
// 		return null;
// 	}
// 	
// 	public Direction ccw() {
// 		switch(this) {
// 		case NONE: return NONE;
// 		case DOWN: return RIGHT;
// 		case LEFT: return DOWN;
// 		case RIGHT: return UP;
// 		case UP: return LEFT;
// 		}
// 		return null;
// 	}
// 	
// 	public static Direction forIndex(int directionIndex) {
// 		if (indices == null) {
// 			indices = new HashMap<Integer, Direction>();
// 			for (Direction dir : values()) {
// 				indices.put(dir.index, dir);
// 			}
// 		}
// 		Direction dir = indices.get(directionIndex);
// 		if (dir == null) return NONE;
// 		return dir;
// 	}
// 	
// 	/**
// 	 * UP, RIGHT, DOWN, LEFT
// 	 * @return
// 	 */
// 	public static Direction[] arrows() {
// 		return arrows;
// 	}
// 	
// 	/**
// 	 * UP, RIGHT, DOWN, LEFT
// 	 * @return
// 	 */
// 	public static List<Direction> arrowsList() {
// 		if (arrowsList == null) {
// 			arrowsList = new ArrayList<Direction>(4);
// 			for (Direction d : arrows) {
// 				arrowsList.add(d);
// 			}
// 		}
// 		return arrowsList;
// 	}
// 	
// 
// }


// Path: PacMan-vs-Ghosts/src/game/core/_G_.java
import game.PacManSimulator.GameConfig;
import game.controllers.Direction;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/*
 * Implementation of "Ms Pac-Man" for the "Ms Pac-Man versus Ghost Team Competition", brought
 * to you by Philipp Rohlfshagen, David Robles and Simon Lucas of the University of Essex.
 * 
 * www.pacman-vs-ghosts.net
 * 
 * Code written by Philipp Rohlfshagen, based on earlier implementations of the game by
 * Simon Lucas and David Robles. 
 * 
 * You may use and distribute this code freely for non-commercial purposes. This notice 
 * needs to be included in all distributions. Deviations from the original should be 
 * clearly documented. We welcome any comments and suggestions regarding the code.
 */
package game.core;



public class _G_ extends G
{
	public static final int EDIBLE_ALERT=30;	//for display only (ghosts turning blue)
	
	//to save replays
	private int pacManDir=G.INITIAL_PAC_DIR;
	private StringBuilder sb;

	public _G_(){}
	
	//Instantiates everything to start a new game
	public void newGame(GameConfig config)