예제 #1
0
        static void Main(string[] args)
        {
            ClientRobot.Connect(args);

            FlagPlace toFlagPlace  = null;
            FlagPlace ownFlagPlace = null;

            foreach (var flagPlace in flagPlaces)
            {
                if (flagPlace.TEAM_ID == tank.TEAM_ID)
                {
                    ownFlagPlace = flagPlace;
                }
                else
                {
                    toFlagPlace = flagPlace;
                }
            }


            while (true)
            {
                if (tank.carryFlag)
                {
                    driveTo(ownFlagPlace);
                }
                else
                {
                    driveTo(toFlagPlace);
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            ClientRobot.Connect(args);
            Tank mujRobot = new Tank("My first tank", ClientRobot.TEAM_NAME);

            /* Odkud níže piště kód*/
        }
예제 #3
0
        public static void Main(string[] args)
        {
            Tank tank = new Tank("Rabbit", ClientRobot.TEAM_NAME);

            ClientRobot.Connect(args);
            Console.WriteLine("Rabbit is ready for action.");
            while (true)
            {
                double toX = RANDOM.Next(0, 800) + 100;
                double toY = RANDOM.Next(0, 800) + 100;

                while (Math.Abs(toX - tank.X) > 50 && Math.Abs(toY - tank.Y) > 50)
                {
                    double angle = Utils.AngleDegree(tank.X, tank.Y, toX, toY);
                    if (Math.Abs(tank.AngleDrive - angle) > 3)
                    {
                        tank.Drive(angle, tank.Motor.ROTATE_IN);
                    }
                    else
                    {
                        tank.Wait();
                    }
                }
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            GameTypeCommand gameType = ClientRobot.Connect(args);

            Spot[] spots = new Spot[gameType.ROBOTS_IN_ONE_TEAM];
            for (int i = 0; i < spots.Length; i++)
            {
                spots[i] = new Spot("spot_" + i);
            }
            while (true)
            {
                foreach (Spot spot in spots)
                {
                    process(spot, getWhatToDo(spot));
                }
            }
        }
예제 #5
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Spot start.");
            string name = "Spot";
            Tank   spot = new Tank(name, ClientRobot.TEAM_NAME);

            ClientRobot.Connect(args);
            Console.WriteLine("Spot is ready for action.");

            int direction = 90;

            while (true)
            {
                if (spot.Power.Equals(0))
                {
                    spot.Drive(direction, 100);
                }
                else if ((direction == 90 && spot.Y > 575) ||
                         (direction == 270 && spot.Y < 425) ||
                         (direction == 180 && spot.X < 150) ||
                         (direction == 0 && spot.X > 850))
                {
                    spot.Drive(direction, 0);
                    direction = (direction + 90) % 360;
                }
                else
                {
                    for (int angle = 0; angle < 360; angle += 30)
                    {
                        ScanAnswerCommand scanAnswer;
                        if ((scanAnswer = spot.Scan(angle, 10)).ENEMY_ID != spot.ID)
                        {
                            spot.Shoot(angle, scanAnswer.RANGE);
                        }
                    }
                }
            }
        }
예제 #6
0
        public static void Main(string[] args)
        {
            ClientRobot.Connect(args);
            while (true)
            {
                RepairmenState repairmenState = getRepairmenState();
                MinerState     minerState     = getMinerState();


                switch (minerState)
                {
                case MinerState.DETONATE:
                    if (mineLayer.PutMinesList.Count > 0)
                    {
                        mineLayer.DetonateMine(mineLayer.PutMinesList[0].ID);
                    }
                    break;

                case MinerState.PUT_MINE:
                    mineLayer.PutMine();
                    break;

                case MinerState.GO_TO_REPAIRMAN:
                    mineLayer.Drive(AngleUtils.AngleDegree(mineLayer.X, mineLayer.Y, repairman.X, repairman.Y),
                                    mineLayer.Motor.ROTATE_IN);
                    break;

                case MinerState.GO_TO_BASE:
                    robotDriveToBase(mineLayer);
                    break;

                case MinerState.GO_AROUND:
                    if (EuclideanSpaceUtils.Distance(mineLayer.X, mineLayer.Y, capturedBase.X, capturedBase.Y) < BaseCapture.BASE_SIZE * 3.0 / 4.0)
                    {
                        scan1 = mineLayer.Scan(AngleUtils.AngleDegree(mineLayer.X, mineLayer.Y, capturedBase.X, capturedBase.Y), 10);
                    }
                    else
                    {
                        robotDriveAround(mineLayer);
                    }
                    break;
                }

                switch (repairmenState)
                {
                case RepairmenState.GO_AROUND:
                    if (EuclideanSpaceUtils.Distance(mineLayer.X, mineLayer.Y, capturedBase.X, capturedBase.Y) <
                        BaseCapture.BASE_SIZE * 3.0 / 4.0)
                    {
                        scan2 = repairman.Scan(AngleUtils.AngleDegree(mineLayer.X, mineLayer.Y, capturedBase.X, capturedBase.Y), 10);
                    }
                    else
                    {
                        robotDriveAround(repairman);
                    }
                    break;

                case RepairmenState.GO_TO_BASE:
                    robotDriveToBase(repairman);
                    break;

                case RepairmenState.REPAIR:
                    repairman.Repair((int)EuclideanSpaceUtils.Distance(repairman.X, repairman.Y, mineLayer.X, mineLayer.Y) + 1);
                    break;
                }

                if (repairmenState == RepairmenState.REPAIR)
                {
                    mineLayer.previousHitpoints = mineLayer.HitPoints;
                }
            }
        }