public ChessGame(string gameName, bool displayBoard) { AllocConsole(); Console.ReadLine(); Thread.Sleep(2000); var cA = new Client(IPAddress.Loopback, "AI1", (byte)new Random().Next(256)); cA.SendMessage(Packet.Packets.Connect, cA.ClientName); //var r = new Random(); //var col1 = Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256)); //var col2 = Color.FromArgb(255 - col1.R, 255 - col1.G, 255 - col1.B); var cB = new Client(IPAddress.Loopback, "AI2", (byte)new Random().Next(256)); cB.SendMessage(Packet.Packets.Connect, cB.ClientName); cA.SendMessage(Packet.Packets.Game, "ADD", gameName, "0", "ff000000", "ffffffff"); var acceptedA = cA.SendMessage(Packet.Packets.Game, "JOIN", gameName); if (acceptedA.Item1.Code == Packet.Packets.Error) { return; } var acceptedB = cB.SendMessage(Packet.Packets.Game, "JOIN", gameName); if (acceptedB.Item1.Code == Packet.Packets.Error) { return; } var retirn = cA.SendMessage(Packet.Packets.Game, "GET", gameName, "NoUpdate"); Board = Board.UnSerialize(retirn.Item2); DrawBoard(); var a = new NeuralNetwork(new Random(), true, this); var b = new NeuralNetwork(new Random(), false, this); //Thread.Sleep(4000); var gameInfo = GameLoop(gameName, displayBoard, a, b, cA, cB); //Console.WriteLine("End Game"); //Console.WriteLine("White: " + gameInfo.WhiteCheckMate); //Console.WriteLine("Black: " + gameInfo.BlackCheckMate); //Console.WriteLine("Check W: " + gameInfo.AmountCheckW); //Console.WriteLine("Check B: " + gameInfo.AmountCheckB); //Console.WriteLine("Move Count W: " + gameInfo.MoveCountW); //Console.WriteLine("Move Count B: " + gameInfo.MoveCountB); //Console.WriteLine("Total Time W: " + gameInfo.TotalTimeW); //Console.WriteLine("Total Time B: " + gameInfo.TotalTimeB); //Console.WriteLine("Draw: " + gameInfo.Draw); cA.SendMessage(Packet.Packets.DisconnectGame, gameName, cA.ClientName, "PLAYING"); cB.SendMessage(Packet.Packets.DisconnectGame, gameName, cB.ClientName, "PLAYING"); var whiteOld = a; var blackOld = b; for (var i = 0; i < MaxGenerations; i++) { Console.WriteLine("Generation " + i); cA.SendMessage(Packet.Packets.Game, "ADD", gameName, "0", "ff000000", "ffffffff"); acceptedA = cA.SendMessage(Packet.Packets.Game, "JOIN", gameName); if (acceptedA.Item1.Code == Packet.Packets.Error) { return; } acceptedB = cB.SendMessage(Packet.Packets.Game, "JOIN", gameName); if (acceptedB.Item1.Code == Packet.Packets.Error) { return; } retirn = cA.SendMessage(Packet.Packets.Game, "GET", gameName, "NoUpdate"); Board = Board.UnSerialize(retirn.Item2); var children = RunGeneration(gameName, whiteOld, blackOld, cA, cB); whiteOld = children.Item1; blackOld = children.Item2; cA.SendMessage(Packet.Packets.DisconnectGame, gameName, cA.ClientName, "PLAYING"); cB.SendMessage(Packet.Packets.DisconnectGame, gameName, cB.ClientName, "PLAYING"); } cA.IsRunning = false; cA.DisposeSocket(); cB.IsRunning = false; cB.DisposeSocket(); Console.Read(); }