public void SinglePUpdate(TimeSpan elapsedGameTime) { //Plan if (planRRT && predictor != null && predictor.CharactersReady()) { controlling = false; planSolution(); } else if (getDebugInfo) { if (cutplan) { debugInfo = RRT.getDebugInfo(T, pathPlan.cleanPlanRectangle(obstaclesInfo, Diamonds, area, rectangleInfo.Height / 2, true)).ToArray(); } else { debugInfo = RRT.getDebugInfo(T, pathPlan.debugCleanPlan()).ToArray(); } //debugInfo = RRT.getDebugInfo(T, null).ToArray(); getDebugInfo = false; } else if (!getDebugInfo) { debugInfo = null; } //Control - if there is a plan then execute it if (pathPlan.getPathPoints() != null && pathPlan.getPathPoints().Count != 0 && hasStarted && !gameOver) { controlling = true; planExecution(); } else if (pathPlan.getTotalCollectibles() != 0 && controlling && pathPlan.getTotalCollectibles() == uncaughtCollectibles.Count) { //if currently the number of uncaught collectibles is the same as the one supposed to be at the end of the plan, stop the agent and replan replan(false); } //make sure the agent replans when missing the last action else if (pathPlan.getPathPoints().Count == 0 && controlling)// && lastAction) { lastActionReplan(); } //if it none of the above work and the too much time has already passed, replan else if (controlling && (gameTime.ElapsedMilliseconds * 0.001f * gSpeed > pointTimeMargin * gSpeed)) { replan(true); } }
public PathPlan joinPlans(PathPlan plan1, PathPlan plan2) { List <Point> newPoints = new List <Point>(); newPoints.AddRange(plan1.getPathPoints()); newPoints.AddRange(plan2.getPathPoints()); PathPlan newPlan = new PathPlan(cutPlan, plan1.totalCollectibles, newPoints, utils); return(newPlan); }
/********************************************************************************************/ /********************************************************************************************/ /*** ***/ /*** PLAN ***/ /*** ***/ /********************************************************************************************/ /********************************************************************************************/ //used when trying to recover a plan where the agent is not on a platform and state of the plan public PathPlan joinPlans(PathPlan correction, PathPlan original, Point connectionPoint) { List <Point> points = original.getPathPoints(); int i; for (i = 0; i < points.Count; i++) { if (points[i].getPosX() == connectionPoint.getPosX() && points[i].getPosY() == connectionPoint.getPosY() && points[i].getUncaughtColl().Count == connectionPoint.getUncaughtColl().Count) { break; } } for (int j = i; j < points.Count; j++) { correction.addPoint(points[j]); } return(correction); }