Exemplo n.º 1
0
 public NetworkParticipant GetParticipant()
 {
     var client = new ClientWithPackage(listener.AcceptTcpClient());
     CompetitionsBundle = GetCompetitionsBundle(client.HelloPackage);
     int controlledRobot = client.HelloPackage.Side == Side.Random ? new Random().Next(2) : (int)client.HelloPackage.Side;
     return new NetworkParticipant(CompetitionsBundle.competitions, controlledRobot, client.Client);
 }
Exemplo n.º 2
0
        public NetworkParticipant GetParticipant()
        {
            var client = new ClientWithPackage(listener.AcceptTcpClient());

            CompetitionsBundle = GetCompetitionsBundle(client.HelloPackage);
            int controlledRobot = client.HelloPackage.Side == Side.Random ? new Random().Next(2) : (int)client.HelloPackage.Side;

            return(new NetworkParticipant(CompetitionsBundle.competitions, controlledRobot, client.Client));
        }
Exemplo n.º 3
0
 public NetworkParticipant[] GetParticipants(HelloPackage helloPackage)
 {
     var client = new ClientWithPackage(listener.AcceptTcpClient());
     var client2 = new ClientWithPackage(listener.AcceptTcpClient());
     CompetitionsBundle = GetCompetitionsBundle(helloPackage);
     return new[]
     {
         new NetworkParticipant(CompetitionsBundle.competitions, 0, client.Client), 
         new NetworkParticipant(CompetitionsBundle.competitions, 1, client2.Client)
     };
 }
Exemplo n.º 4
0
        public NetworkParticipant[] GetParticipants(HelloPackage helloPackage)
        {
            var client  = new ClientWithPackage(listener.AcceptTcpClient());
            var client2 = new ClientWithPackage(listener.AcceptTcpClient());

            CompetitionsBundle = GetCompetitionsBundle(helloPackage);
            return(new[]
            {
                new NetworkParticipant(CompetitionsBundle.competitions, 0, client.Client),
                new NetworkParticipant(CompetitionsBundle.competitions, 1, client2.Client)
            });
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            competitionsBundle = CompetitionsBundle.Load(CompetitionsName, "Level1");
            competitionsBundle.competitions.HelloPackage = new HelloPackage {
                MapSeed = 1
            };
            competitionsBundle.competitions.Initialize(new CVARCEngine(competitionsBundle.Rules),
                                                       new[] { new RobotSettings(0, false), new RobotSettings(1, true) });

            var botName = args.FirstOrDefault() ?? "None";

            RunForm(competitionsBundle.competitions.CreateBot(botName, 1));
        }
Exemplo n.º 6
0
        private static void InitCompetition(HelloPackage helloPackage, string competitionsName)
        {
            var participantsServer = new ParticipantsServer(competitionsName);
            var participantsTask   = Task.Factory.StartNew(() => participantsServer.GetParticipants(helloPackage));

            RunClients("player2\\Client.exe", "player1\\Client.exe");
            participants       = participantsTask.Result;
            competitionsBundle = participantsServer.CompetitionsBundle;
            participantsServer.CompetitionsBundle.competitions.Initialize(new CVARCEngine(competitionsBundle.Rules), new[]
            {
                new RobotSettings(0, false),
                new RobotSettings(1, false)
            });
        }
Exemplo n.º 7
0
        private static Participant[] InitCompetition()
        {
            var participantsServer = new ParticipantsServer(CompetitionsName);
            var participant        = participantsServer.GetParticipant();

            competitionsBundle = participantsServer.CompetitionsBundle;
            var participants = new Participant[2];

            participants[participant.ControlledRobot] = participant;
            var botNumber = participant.ControlledRobot == 0 ? 1 : 0;

            participantsServer.CompetitionsBundle.competitions.Initialize(new CVARCEngine(participantsServer.CompetitionsBundle.Rules),
                                                                          new[] { new RobotSettings(participant.ControlledRobot, false), new RobotSettings(botNumber, true) });
            var botName = participantsServer.CompetitionsBundle.competitions.HelloPackage.Opponent ?? "None";

            participants[botNumber] = participantsServer.CompetitionsBundle.competitions.CreateBot(botName, botNumber);
            return(participants);
        }
Exemplo n.º 8
0
        static void Main()
        {
            var settings = new BotDemoSettings();

            try
            {
                CompetitionsBundle = CompetitionsBundle.Load(settings.CompetitionsName, "Level1");
                CompetitionsBundle.competitions.HelloPackage = new HelloPackage {
                    MapSeed = -1
                };
                CompetitionsBundle.competitions.Initialize(new CVARCEngine(CompetitionsBundle.Rules), new[] { new RobotSettings(0, true), new RobotSettings(0, true) });
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "CVARC BotDemo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List <Bot> bots = new List <Bot>();

            for (int i = 0; i < CompetitionsBundle.competitions.RobotCount; i++)
            {
                if (i == settings.BotNames.Length)
                {
                    break;
                }
                if (settings.BotNames[i] == "None")
                {
                    continue;
                }
                bots.Add(CompetitionsBundle.competitions.CreateBot(settings.BotNames[i], i));
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var form = new TutorialForm(CompetitionsBundle.competitions);

            new Thread(() => CompetitionsBundle.competitions.ProcessParticipants(true, int.MaxValue, bots.ToArray()))
            {
                IsBackground = true
            }.Start();
            Application.Run(form);
        }