コード例 #1
0
        protected override void BotTakeAction(int turn, int tick, LastTickRecord ltr)
        {
            WhatHappened = ltr;
            string match = turn.ToString() + "," + tick.ToString();

            turnTicksRecieved.Add(match);
        }
コード例 #2
0
ファイル: PirateBot.cs プロジェクト: Itsey/Boondoggle
 private void ProcessLastTickRecord(LastTickRecord tdr)
 {
     if (tdr.Events.Count > 0)
     {
         foreach (var v in tdr.Events)
         {
             if (v.ActionType == LastTickEventType.Moved)
             {
                 myLocation.X += v.XDeltaMove;
                 myLocation.Y += v.YDeltaMove;
             }
         }
     }
 }
コード例 #3
0
ファイル: PirateBot.cs プロジェクト: Itsey/Boondoggle
        protected override void BotTakeAction(int turn, int tick, LastTickRecord tdr)
        {
            ProcessLastTickRecord(tdr);

            scanAge++;

            if ((lastScan == null) || (tdr.Events.Count > 0) || (scanAge > 10))
            {
                PerformScan();
                AnalyseScanForTargetLock();
            }


            if (this.CurrentSpeed < 5)
            {
                Accelerate();
            }



            double nd = CurrentHeading;

            if (!IsThisDirectionClearn(nd))
            {
                //TestUtils.DumpScanResult(lastScan, turn, tick, this.Name);

                double newHeading = GetNewHeading(nd);

                if (newHeading != nd)
                {
                    ChangeHeading(newHeading);
                }
                else
                {
                    BotWriteMessage("No new heading found, stopping.");
                    Decelerate();
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// The main interface point called from the egine is ActualTakeAction, which is called for each tick.  Each tick is called passing a LastTickRecord
        /// whcih describes what happened to the bot during the last tick.  During the first tick no events will be returned in the last tick record.
        /// </summary>
        /// <param name="turn">The integer turn number - increments from 1 thorugh to the end of the battle</param>
        /// <param name="tick">The integer tick number 1 through to 10</param>
        /// <param name="tdr">A description of the events that occured last turn.</param>
        protected override void BotTakeAction(int turn, int tick, LastTickRecord tdr)
        {
            // Reference Bot Always Accellerates to 5 Speed and drives around at that speed
            if (this.CurrentSpeed < 5)
            {
                Accelerate();
            }

            // A Point of interest indicates something that is not a wall or floor in the scan results.  This
            // will be an object such as a BOT - in this instance if right turn bot finds another bot it will open fire.
            if (!disableWeapons)
            {
                // This bot disables its weapons when it runs out of ammunition.
                if (lastScan.NumberOfPOI > 0)
                {
                    BotWriteMessage("Point of interest found");

                    // Check Each Of the points of interest that were returned in the scan.
                    foreach (var v in lastScan.GetPointsOfInterest())
                    {
                        // Check whether the point of interest is a Bot, if it is then we can open fire at the bot.
                        if (lastScan.GetResultAtPosition(v.ScanLocation) == ScanTileResult.Bot)
                        {
                            BotWriteMessage("FIRING : " + v.POIIdentity.ToString());

                            var result = FireWeapon(v.POIIdentity, "Rifle");

                            // N.B. This will also fail for other reasons, for example if the weapon is on cooldown.
                            if (result.State == UsageEndState.Fail_NoAmmo)
                            {
                                disableWeapons = true;
                            }
                        }
                    }
                }
            }

            // Find which direction you are heading in, from the bots Current Heading
            double nd = CurrentHeading;

            // This is a helper method that checks the scan results and sees whether there is a wall
            // or blocker in the way.
            if (!IsThisDirectionClearn(nd))
            {
                // DO NOT USE THIS METHOD
                //TestUtils.DumpScanResult(lastScan, turn, tick, this.Name);

                // This is where your navigation logic goes, this is where you write the code to determine
                // how your bot should navigate around.
                double newHeading = GetNewHeading(nd);

                if (newHeading != nd)
                {
                    ChangeHeading(newHeading);
                }
                else
                {
                    BotWriteMessage("No new heading found, stopping.");
                    Decelerate();
                }
            }
        }
コード例 #5
0
ファイル: KevBot.cs プロジェクト: Itsey/Boondoggle
        /// <summary>
        ///
        /// </summary>
        /// <remarks>
        /// [-1, 1][ 0, 1][ 1, 1]
        /// [-1, 0][ kev ][ 1, 0]
        /// [-1,-1][ 0,-1][ 1,-1]
        /// </remarks>
        /// <param name="turn"></param>
        /// <param name="tick"></param>

        protected override void BotTakeAction(int turn, int tick, LastTickRecord ltr)
        {
            //reset the scan
            scannedThisTick = false;

            //if (turn == 4 & tick == 10) {
            //    Plisky.Boondoggle2.Test.TestUtils.DumpScanResult(grid, turn, tick, this.Name);
            //}

            int things = this.Scan(turn, tick);

            if (things == 0)
            {
                if (speed > 1)
                {
                    for (int i = 0; i < 11; i++)
                    {
                        b.Info.Log($"Nothing around!  Speed is {speed} Decelerating to {speed + 1}");
                        this.speed = Decelerate();
                    }
                }
            }
            else
            {
                if (rifle < 11)
                {
                    foreach (var poi in grid.GetPointsOfInterest())
                    {
                        b.Info.Log("KevBot FIRE!!!  - TargetId {" + poi.POIIdentity.ToString() + "}");
                        var eur = FireWeapon(poi.POIIdentity, "Rifle" + rifle);
                        b.Info.Log($"KevBot fire result was : {eur.State}");
                        if (eur.State == UsageEndState.Fail_NoAmmo)
                        {
                            rifle++;
                        }
                    }
                }
                else
                {
                    if (speed < 10)
                    {
                        for (int i = 0; i < 11; i++)
                        {
                            b.Info.Log($"Bitches in the hood!  Speed is {speed} Accelerating to {speed + 1}");
                            this.speed = Accelerate();
                        }
                    }
                }
            }

            var nextHeading = GetNextPositionFromDirection();

            //The position we are about to occupy is unscanned
            if (grid.GetResultAtPosition(nextHeading.Point) == ScanTileResult.Unscanned)
            {
                b.Info.Log("Found our next heading is unscanned, rescan!");
                rescan      = true;
                things      = this.Scan(turn, tick);
                nextHeading = GetNextPositionFromDirection();
            }

            //The position we are about to occupy is unoccupied
            if (grid.GetResultAtPosition(nextHeading.Point) == ScanTileResult.Unoccupied)
            {
                // Nothing of interest was returned on the map
                //if (things == 0)
                //{
                //    return;
                //}

                bool currentHeadingIsSafe = true;
                int  bots = 0;
                //There is something on the map that we might bump into, check whether
                //they can potentially move into the position we are about to occupy
                foreach (var rp in currentPosition.RelatedPoints)
                {
                    if (grid.GetResultAtPosition(rp) == ScanTileResult.Bot)
                    {
                        currentHeadingIsSafe = false;
                        b.Info.Log($"Found a bot at {rp.X}:{rp.Y} - can't go to {currentPosition.Point.X}:{currentPosition.Point.Y}, in case we collied");
                        bots++;
                    }
                    ////TODO : change this to walls straight ahead of us only
                    //if (grid.GetResultAtPosition(rp) == ScanTileResult.SolidWall)
                    //{
                    //    currentHeadingIsSafe = false;
                    //    b.Info.Log("Found a wall at {0}:{1} - can't go to {2}:{3}, in case we collied", rp.X, rp.Y, currentPosition.Point.X, currentPosition.Point.Y);
                    //    break;
                    //}
                }

                if (currentHeadingIsSafe)
                {
                    return;
                }

                b.Info.Log($"Current heading is not safe, there are {bots} bots about, change direction!");

                rescan = true;
                Scan(turn, tick);
            }
            else if (grid.GetResultAtPosition(nextHeading.Point) == ScanTileResult.SolidWall)
            {
                b.Info.Log($"Found a wall at {nextHeading.Point.X}:{nextHeading.Point.Y}");
                rescan = true;
                Scan(turn, tick);
                currentHeading.InUse = false;
                SetHeadingAttributes(currentHeading);
                nextHeading.Used  = true;
                nextHeading.InUse = false;
                SetHeadingAttributes(nextHeading);
            }

            //foreach (var rp in currentHeading.RelatedPoints) {
            //    if (grid.GetResultAtPosition(rp) == ScanTileResult.Bot) {
            //        b.Info.Log("Found a bot at {0}:{1} - can't go to {2}:{3}, in case we collied", rp.X, rp.Y, currentHeading.Point.X, currentHeading.Point.Y);
            //        currentHeading.InUse = false;
            //        SetHeadingAttributes(currentHeading);
            //        break;
            //    }
            //}

            //if (currentHeading.InUse)
            //    return;

            List <Heading> freeheadings = FindFreeHeadings(grid);

            if (freeheadings.Count() == 0)
            {
                b.Info.Log("No free headings left, start again");
                headings.ForEach(h => h.Used = false);
                freeheadings = FindFreeHeadings(grid);
            }

            foreach (var heading in freeheadings)
            {
                //if (heading == currentHeading)
                //    continue;
                if (heading == nextHeading)
                {
                    continue;
                }
                if (heading.Used)
                {
                    continue;
                }

                if (grid.GetResultAtPosition(heading.Point) == ScanTileResult.Unoccupied)
                {
                    currentHeading.InUse = false;
                    currentHeading.Used  = true;
                    SetHeadingAttributes(currentHeading);
                    b.Info.Log(currentHeading + " Used set to true, InUse set to false");
                    nextHeading.InUse = false;
                    nextHeading.Used  = true;
                    SetHeadingAttributes(nextHeading);
                    b.Info.Log(nextHeading + " Used set to true, InUse set to false");

                    heading.InUse = true;
                    SetHeadingAttributes(heading);
                    b.Info.Log(heading + " InUse set to true");
                    currentHeading = heading;
                    b.Info.Log($"Found a clear path at {currentHeading.Point.X}:{currentHeading.Point.Y} {Heading.HeadingText(currentHeading.Point)} - Let's go there!");
                    HeadToPoint(heading.Point);
                    return;
                }
            }
            b.Info.Log("No where to go, HALT!");
            this.speed = 0;
        }