Beispiel #1
0
        public void Estimate(double agentX, double agentY, double agentVx, double agentVy,
                             double puckX, double puckY, double puckVx, double puckVy, double PuckR,
                             double oppX, double oppY, double oppVx, double oppVy
                             )
        {
            AHEntities.SenseEventType newEvent = EstimatorStrategy.Estimate(agentX, agentY, agentVx, agentVy,
                                                                            puckX, puckY, puckVx, puckVy, PuckR, oppX, oppY, oppVx, oppVy, WM);

            if (newEvent == SenseEventType.NoEvent)
            {
                return;
            }

            SenseEventArgs senseEvent;

            mLogger.AddLogMessage("Perception: new event detected: " + newEvent.ToString() +
                                  ", puck velocity: (" + puckVx.ToString() + "," + puckVy.ToString() + ")", true);
            if ((newEvent == SenseEventType.yWall) && (puckVx < 0))
            {
                mLogger.AddLogMessage("Perception: Invoking Refining Of Current Plan");
                senseEvent = new SenseEventArgs(SensePlanArg.Refine, newEvent);
            }
            else
            {
                mLogger.AddLogMessage("Perception: Invoking New Planing");
                senseEvent = new SenseEventArgs(SensePlanArg.Plan, newEvent);
            }
            OnEstimationUpdate(this, senseEvent);
        }
Beispiel #2
0
        public void StartNewPlan(object sender, EventArgs e)
        {
            ActionDirective             tempA;
            SenseEventArgs              senseE    = (SenseEventArgs)e;
            Dictionary <string, double> gameState = WM.GetPhysicalState();
            Point puckV = new Point(gameState["PuckVx"], gameState["PuckVy"]);

            if ((senseE.EventType == SenseEventType.yWall) && (puckV.X > 0))
            {
                // no replan (prepare action)
                currentEvent = senseE.EventType;
                mLogger.AddLogMessage("Tactics: No New Action Required: " + currentActionDirective.Action.ToString());
            }
            else
            {
                //new plan
                if ((currentEvent == senseE.EventType) &&
                    ((currentEvent == SenseEventType.StuckPlayer) || (currentEvent == SenseEventType.StuckAgent)))
                {
                    // no replan
                    mLogger.AddLogMessage("Tactics: No New Action Required: " + currentActionDirective.Action.ToString());
                }
                else if ((senseE.EventType == SenseEventType.yWall) && (puckV.X < 0))
                {
                    // need to replan current action
                    currentEvent = senseE.EventType;
                    mLogger.AddLogMessage("Tactics: Refining Old Action: " + currentActionDirective.Action.ToString());
                    PlanningScheduler.MakePlanRequest(senseE.EventType);
                }
                else
                {
                    currentEvent = senseE.EventType;
                    tempA        = actionSelectionStrategy.SelectAction(senseE.EventType);
                    //if (tempA.Action != currentActionDirective.Action)
                    //{
                    lock (currentActionDirective.ActionDirectiveLock)
                    {
                        currentActionDirective.Action    = tempA.Action;
                        currentActionDirective.TimeStamp = senseE.TimeStamp;
                        currentActionDirective.Duration  = tempA.Duration - (DateTime.Now - senseE.TimeStamp);
                    }
                    // log action - new action
                    mLogger.AddLogMessage("Tactics: New Action Selected: " + currentActionDirective.Action.ToString());
                    PlanningScheduler.MakePlanRequest(senseE.EventType);

                    /*}
                     * else
                     * {
                     *  mLogger.AddLogMessage("Tactics: Old Action Selected: " + currentActionDirective.Action.ToString());
                     *  PlanningScheduler.MakePlanRequest(senseE.EventType);
                     * }*/
                }
            }


            /*
             * // new plan required
             * if ((senseE.EventType == SenseEventType.AgentCollision) || (senseE.EventType == SenseEventType.OpponentCollision) ||
             *  (senseE.EventType == SenseEventType.xWall) || (senseE.EventType == SenseEventType.yWall) && (puckV.X < 0))
             * {
             *  tempA = actionSelectionStrategy.SelectAction(senseE.EventType);
             *  if (tempA.Action != currentActionDirective.Action)
             *  {
             *      lock (currentActionDirective.ActionDirectiveLock)
             *      {
             *          currentActionDirective.Action = tempA.Action;
             *          currentActionDirective.TimeStamp = senseE.TimeStamp;
             *          currentActionDirective.Duration = tempA.Duration - (DateTime.Now - senseE.TimeStamp);
             *      }
             *      // log action - new action
             *      mLogger.AddLogMessage("Tactics: New Action Selected: " + currentActionDirective.Action.ToString());
             *      PlanningScheduler.MakePlanRequest(senseE.EventType);
             *  }
             *  else
             *  {
             *      mLogger.AddLogMessage("Tactics: Old Action Selected: " + currentActionDirective.Action.ToString());
             *      PlanningScheduler.MakePlanRequest(senseE.EventType);
             *  }
             * }
             * else
             * {
             *  // log action
             *  mLogger.AddLogMessage("Tactics: Refinement Of Active Action: " + currentActionDirective.Action.ToString());
             *  PlanningScheduler.MakePlanRequest(senseE.EventType);
             * }*/



            /*
             * if (senseE.PlanType == SensePlanArg.Plan)
             * {
             *  tempA = actionSelectionStrategy.SelectAction(senseE.EventType);
             *  // construct the action directive object
             *  if (tempA.Action != currentActionDirective.Action)
             *  {
             *      lock (currentActionDirective.ActionDirectiveLock)
             *      {
             *          currentActionDirective.Action = tempA.Action;
             *          currentActionDirective.TimeStamp = senseE.TimeStamp;
             *          currentActionDirective.Duration = tempA.Duration - (DateTime.Now - senseE.TimeStamp);
             *      }
             *      // log action - new action
             *      mLogger.AddLogMessage("Tactics: New Action Selected: " + currentActionDirective.Action.ToString());
             *  }
             *  else
             *  {
             *      if ((currentActionDirective.Action != AHEntities.Action.PREPARE))
             *      {
             *          // log action - refinement of current action.
             *          mLogger.AddLogMessage("Tactics: New (reselection) Action Selected: " + currentActionDirective.Action.ToString());
             *      }
             *  }
             *  PlanningScheduler.MakePlanRequest(senseE.EventType);
             * }
             * else
             * {
             *  // current directive is still valid, need to schedule replanning
             *  // log action
             *  mLogger.AddLogMessage("Tactics: Refinement Of Active Action: " + currentActionDirective.Action.ToString());
             *  PlanningScheduler.MakePlanRequest(senseE.EventType);
             * }*/
        }