Пример #1
0
        private static int RunAcpcSession()
        {
            if (_cmdLine.Verbose)
            {
                Console.Out.WriteLine("Starting ACPC session in directory {0}", Directory.GetCurrentDirectory());
            }

            string [] addressParts = _cmdLine.ServerAddress.Get(Props.Global).Split(
                new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

            string hostName;
            int    port;

            if (addressParts.Length != 2 || !int.TryParse(addressParts[1], out port))
            {
                Console.Error.WriteLine("Wrong server address ");
                return(-1);
            }
            hostName = addressParts[0];

            Acpc11ServerMessageConverter converter = new Acpc11ServerMessageConverter();

            IPlayer player = CreatePlayer();

            converter.Player     = player;
            converter.PlayerName = BotName;

            AcpcServerAdapter adapter = new AcpcServerAdapter();

            adapter.MessageConverter = converter;
            adapter.IsVerbose        = _cmdLine.Verbose;
            adapter.IsTrafficVerbose = _cmdLine.VerboseTraffic;

            if (!adapter.Connect(hostName, port, _cmdLine.ConnectTimeout))
            {
                return(-1);
            }

            adapter.Run();

            player.OnSessionEnd();

            if (_cmdLine.Verbose)
            {
                Console.WriteLine("Games played: {0}", converter.GameCount);
            }

            return(0);
        }
        public void Test_Interactive()
        {
            Player player = new Player();

            Acpc11ServerMessageConverter c = new Acpc11ServerMessageConverter();

            c.Player     = player;
            c.PlayerName = "Pl";

            AcpcServerAdapter adapter = new AcpcServerAdapter();

            adapter.MessageConverter = c;

            adapter.IsVerbose = true;

            adapter.Connect("192.168.178.21", 18791, 100);

            adapter.Run();
        }