예제 #1
0
 public void run(double timeincr)
 {
     //given a time increment do what we can
     //where do we want to go?
     mode = botMode.tele;
     if (distancetogo > 0)
     {
         distancetogo -= maxSpeed * timeincr;
         return; //currently driving
     }
     if (def != null)
     {
         //currently trying to breach a defense
         //has time elapsed?
         defenseTimetogo -= timeincr;
         if (defenseTimetogo < 0)
         {
             if (def.attempt())
             {
                 //success!
                 field.teleScore += 5;
                 def              = null;
             }
             else
             {
                 //fail, try again
                 defenseTimetogo = def.friction;
             }
         }
     }
     else
     {
         destination = strategy.NextLocation(destination);
     }
 }
예제 #2
0
        public fieldLocation.places NextLocation(fieldLocation.places current)
        {
            //given a location, where to go next?
            fieldLocation.places results = fieldLocation.places.not_set;
            switch (current)
            {
            case fieldLocation.places.not_set:
                if (bot.team == Bot.Alliance.blue)
                {
                    results = fieldLocation.places.red_outerworks;
                }
                else
                {
                    results = fieldLocation.places.blue_outerworks;
                }
                bot.distancetogo = WorldFacts.neutralToOuter;
                break;

            case fieldLocation.places.blue_outerworks:
                bot.def = pickDefense(current);
                if (bot.def != null)
                {
                    bot.defenseTimetogo = bot.def.friction;
                    results             = fieldLocation.places.blue_outerworks_breached;
                }
                break;

            case fieldLocation.places.red_outerworks:
                bot.def = pickDefense(current);
                if (bot.def != null)
                {
                    bot.defenseTimetogo = bot.def.friction;
                    results             = fieldLocation.places.red_outworks_breached;
                }
                break;

            case fieldLocation.places.red_outworks_breached:
                if (bot.canShoot || bot.canAuto.HasFlag(Bot.autoAbility.shoot) || bot.hasBall)
                {
                    results          = fieldLocation.places.red_courtyard;
                    bot.distancetogo = WorldFacts.courtToOuter;
                }     //otherwise, head back?
                else
                {
                    bot.def = pickDefense(current);
                    if (bot.def != null)
                    {
                        bot.defenseTimetogo = bot.def.friction;
                        results             = fieldLocation.places.red_outerworks;
                    }     //note in auto we would just sit there
                }
                break;
            }
            return(results);
        }
예제 #3
0
        public Bot(teleAbility kind, autoAbility autoKind, Alliance side)
        {
            canShoot  = kind.HasFlag(teleAbility.shoot);
            canClimb  = kind.HasFlag(teleAbility.climb);
            canBreach = kind.HasFlag(teleAbility.breach);

            canAuto = autoKind;
            hasBall = true; //let each robot start with a ball
            mode    = botMode.none;

            strategy         = new BotStrategy(this);
            location.current = fieldLocation.places.neutral;
            destination      = fieldLocation.places.not_set;
            distancetogo     = 0;
            team             = side;
            maxSpeed         = 5.0; //default to 5 fps
        }
예제 #4
0
파일: Bot.cs 프로젝트: iscrc/StrongHold
        public Bot(teleAbility kind, autoAbility autoKind, Alliance side)
        {
            canShoot = kind.HasFlag(teleAbility.shoot);
            canClimb = kind.HasFlag(teleAbility.climb);
            canBreach = kind.HasFlag(teleAbility.breach);

            canAuto = autoKind;
            hasBall = true; //let each robot start with a ball
            mode = botMode.none;

            strategy = new BotStrategy(this);
            location.current = fieldLocation.places.neutral;
            destination = fieldLocation.places.not_set;
            distancetogo = 0;
            team = side;
            maxSpeed = 5.0; //default to 5 fps
        }
예제 #5
0
        public Defense pickDefense(fieldLocation.places current)
        {
            Defense results = null;

            Defense[] options;

            if (current == fieldLocation.places.blue_outerworks)
            {
                options = bot.field.blueOuterworks;
            }
            else
            {
                options = bot.field.redOuterworks;
            }
            switch (bot.mode)
            {
            case Bot.botMode.auto:
                switch (current)
                {
                case fieldLocation.places.red_outerworks:
                case fieldLocation.places.blue_outerworks:
                    if (!bot.canAuto.HasFlag(Bot.autoAbility.breach))
                    {
                        return(results);                                                      //bot cant breach in auto
                    }
                    results = options[3];
                    break;

                case fieldLocation.places.red_outworks_breached:
                case fieldLocation.places.blue_outerworks_breached:
                    results = null;         //in auto you dont go back
                    break;
                }
                break;

            case Bot.botMode.tele:
                results = options[3];
                break;
            }
            return(results);
        }
예제 #6
0
        //bot actions
        //shooter pattern:
        //  from passage receive ball,
        //  move to neutral,
        //  move to X outerworks,
        //  move to courtyard
        //  high shooter:
        //      move to position
        //      shoot
        //  low shooter:
        //      move to batter
        //      score
        //      move to courtyaard
        //  move to outerworks
        //  move to neutral
        //  move to passage

        public void runAuto(double timeincr)
        {
            mode = botMode.auto;
            if (canAuto == autoAbility.none)
            {
                return;                              //sits in auto
            }
            if (distancetogo > 0)
            {
                distancetogo -= maxSpeed * timeincr;
                return; //currently driving
            }
            if (def != null)
            {
                //currently trying to breach a defense
                //has time elapsed?
                defenseTimetogo -= timeincr;
                if (defenseTimetogo < 0)
                {
                    if (def.attempt())
                    {
                        //success!
                        field.autoScore += 10;
                        def              = null;
                    }
                    else
                    {
                        //fail, try again
                        defenseTimetogo = def.friction;
                    }
                }
            }
            else
            {
                destination = strategy.NextLocation(destination);
            }
        }
예제 #7
0
파일: Bot.cs 프로젝트: iscrc/StrongHold
        //bot actions
        //shooter pattern: 
        //  from passage receive ball, 
        //  move to neutral, 
        //  move to X outerworks,
        //  move to courtyard
        //  high shooter:
        //      move to position
        //      shoot
        //  low shooter:
        //      move to batter
        //      score
        //      move to courtyaard
        //  move to outerworks
        //  move to neutral
        //  move to passage

        public void runAuto(double timeincr)
        {
            mode = botMode.auto;
            if (canAuto == autoAbility.none) return; //sits in auto
            if (distancetogo > 0)
            {
                distancetogo -= maxSpeed * timeincr; 
                return; //currently driving
            }
            if (def != null)
            {
                //currently trying to breach a defense
                //has time elapsed?
                defenseTimetogo -= timeincr;
                if (defenseTimetogo < 0)
                {
                    if (def.attempt())
                    {
                        //success!
                        field.autoScore += 10;
                        def = null;
                    }
                    else
                    {
                        //fail, try again
                        defenseTimetogo = def.friction;
                    }
                }
            }
            else
            {
                destination = strategy.NextLocation(destination);
            }
 
        }
예제 #8
0
파일: Bot.cs 프로젝트: iscrc/StrongHold
 public void run(double timeincr)
 {
     //given a time increment do what we can
     //where do we want to go?
     mode = botMode.tele;
     if (distancetogo > 0)
     {
         distancetogo -= maxSpeed * timeincr;
         return; //currently driving
     }
     if (def != null)
     {
         //currently trying to breach a defense
         //has time elapsed?
         defenseTimetogo -= timeincr;
         if (defenseTimetogo < 0)
         {
             if (def.attempt())
             {
                 //success!
                 field.teleScore += 5;
                 def = null;
             }
             else
             {
                 //fail, try again
                 defenseTimetogo = def.friction;
             }
         }
     }
     else
     {
         destination = strategy.NextLocation(destination);
     }
 }