// Use this for initialization void Start() { if (Robot1 != null && Robot2 != null) { // Load brains //var brain1 = Utility.LoadBrain(string.Format(@"Assets\Scripts\Populations\{0}Champ.gnm.xml", "Stationary Melee")); var brain1 = Utility.LoadBrain(Application.persistentDataPath + string.Format("/Populations/{0}Champ.gnm.xml", "Rifle Markman")); BattleGUI.Robot1Name = "Rifle Markman"; Destroy(Robot1.GetComponent <RobotController>()); Robot1.AddComponent <BattleController>(); Robot1.transform.position = new Vector3(Robot1.transform.position.x + Utility.GenerateNoise(5f), 1, Robot1.transform.position.z + Utility.GenerateNoise(5f)); controller1 = Robot1.GetComponent <BattleController>(); controller1.HitLayers = 1 << LayerMask.NameToLayer("Robot"); // var brain2 = Utility.LoadBrain(string.Format(@"Assets\Scripts\Populations\{0}Champ.gnm.xml", "Simple Attack")); var brain2 = Utility.LoadBrain(Application.persistentDataPath + string.Format("/Populations/{0}Champ.gnm.xml", "Simple Attack")); BattleGUI.Robot2Name = "Simple Attack"; Destroy(Robot2.GetComponent <RobotController>()); Robot2.AddComponent <BattleController>(); Robot2.transform.position = new Vector3(Robot2.transform.position.x + Utility.GenerateNoise(5f), 1, Robot2.transform.position.z + Utility.GenerateNoise(5f)); controller2 = Robot2.GetComponent <BattleController>(); controller1.Activate(brain1, Robot2); controller2.Activate(brain2, Robot1); } }
public static void Main(string[] args) { var longestGrid = new DistanceGrid(10, 10); // BinaryTree.Maze(longestGrid); Sidewinder.Maze(longestGrid); var start = longestGrid[0, 0]; var distances = start.Distances; var(newStart, distance) = distances.Max; var newDistances = newStart.Distances; var(goal, distance2) = newDistances.Max; longestGrid.Distances = newDistances.PathTo(goal); var output = longestGrid.ToUgly(goal); Console.WriteLine(output); Console.WriteLine("The exit cell(and the farthest from the start) coordinates: x=" + goal.Column + " y=" + goal.Row); TextWriter ts = new StreamWriter(@"C:\1.txt"); ts.Write(output); ts.Close(); var robot = new Robot { Location = new Point { X = newStart.Column, Y = newStart.Row } }; var robot2 = new Robot2 { Location = new Point { X = newStart.Column, Y = newStart.Row } }; var robot3 = new Robot3 { Location = new Point { X = newStart.Column, Y = newStart.Row } }; var maze = Maze.Load(@"C:\1.txt"); var ai = new AI { Robot2 = robot2, Maze = maze, Robot = robot, Robot3 = robot3 }; ai.StartBot(ai); }
// Use this for initialization void Start() { _instance = this; status = Status.isWaitting; startUI = transform.GetChild(1).GetChild(0); }