/// <summary> /// Analyse the situation of the actual event in combination with the meta data storage. /// </summary> /// <param name="storage">Meta data storage.</param> /// <param name="actualEvent">Actual event.</param> /// <returns>The detected local situation.</returns> public SituationType Analyse(IMetaDataStorage storage, AbstractFolderEvent actualEvent) { SituationType type = this.DoAnalyse(storage, actualEvent); Logger.Debug(string.Format("Local Situation is: {0}", type)); return(type); }
public Situation(SituationType situationType, string briefing, int decisionsCount, Sprite sprite, SituationBackground situationBackground) { m_SituationType = situationType; m_Briefing = briefing; m_Decisions = new Decision[decisionsCount]; m_CharacterSprite = sprite; m_SituationBackground = situationBackground; }
public bool doAction(SituationType currentSituation) { bool result = false; if (actionType == currentSituation) { } return(result); }
public Situation(SituationType type, int id, int air, int hum, int light, int soil, int temp) { Type = type; ID = id; AirQuality = air; Humidity = hum; LightLevel = light; SoilMoisture = soil; Temperature = temp; }
/// <summary> /// Analyse the specified actual event. /// </summary> /// <param name="storage">Storage of saved MappedObjects.</param> /// <param name="actualEvent">Actual event.</param> /// <returns>The detected situation type</returns> public SituationType Analyse(IMetaDataStorage storage, AbstractFolderEvent actualEvent) { if (actualEvent.Remote == MetaDataChangeType.NONE && this.IsRemoteObjectDifferentToLastSync(storage, actualEvent)) { actualEvent.Remote = MetaDataChangeType.CHANGED; } SituationType type = this.DoAnalyse(storage, actualEvent); return(type); }
public static string GetDescription(this SituationType situationType) { switch (situationType) { case SituationType.ThisLastSingleInLastObsoleteToFixTail: return("The only event for its category in the obsolete range which range equals to the element's end time " + "can be optimized when string value of end parameters is longer than the start parameters. "); case SituationType.ThisLastSingleInLastObsoleteToFixEndTime: return("The only event for its category in the obsolete range which range equals to the element's end time " + "can be optimized when string value of end time is longer than the start time. "); case SituationType.ThisLastInLastObsoleteToRemove: return("The event in the obsolete range which range's end time equals to the element's end time " + "is useless and can be safely removed."); case SituationType.NextHeadAndThisInObsoleteToRemove: return("When one event is in an obsolete range and the next event's start time is in the same obsolete range, " + "the event is useless and can be safely removed."); case SituationType.ThisFirstSingleIsStaticAndDefaultToRemove: return("no description."); case SituationType.ThisFirstIsStaticAndSequentWithNextHeadToRemove: return("no description."); case SituationType.MoveSingleIsStaticToRemoveAndChangeInitial: return("no description."); case SituationType.MoveSingleEqualsInitialToRemove: return("no description."); case SituationType.InitialToZero: return("no description."); case SituationType.ThisPrevIsStaticAndSequentToCombine: return("no description."); case SituationType.ThisIsStaticAndSequentWithPrevToCombine: return("no description."); case SituationType.PrevIsStaticAndTimeOverlapWithThisStartTimeToRemove: return("no description."); default: throw new ArgumentOutOfRangeException(nameof(situationType), situationType, null); } }
private void DoHandle(AbstractFolderEvent actualEvent) { SituationType localSituation = this.LocalSituation.Analyse(this.storage, actualEvent); SituationType remoteSituation = this.RemoteSituation.Analyse(this.storage, actualEvent); ISolver solver = this.Solver[(int)localSituation, (int)remoteSituation]; if (solver == null) { throw new NotImplementedException(string.Format("Solver for LocalSituation: {0}, and RemoteSituation {1} not implemented", localSituation, remoteSituation)); } Stopwatch watch = Stopwatch.StartNew(); this.Solve(solver, actualEvent); watch.Stop(); Logger.Debug(string.Format("Solver {0} took {1} ms", solver.GetType(), watch.ElapsedMilliseconds)); }
/// <summary> /// 四个方向上对某个点某种颜色棋子进行估分 /// </summary> /// <param name="x">横坐标</param> /// <param name="y">纵坐标</param> /// <param name="color"></param> /// <returns></returns> public int evaluate(int x, int y, int color) { int sum = 0; //四个方向估值 for (int i = 0; i < 4; i++) { SituationType type = GetSituationType(x, y, i, color); switch (type) { case SituationType.BeFive: sum += BE_FIVE; break; case SituationType.ActiveFour: sum += ACTIVIE_FOUR; break; case SituationType.RushFour: sum += RUSH_FOUR; break; case SituationType.ActiveThree: sum += ACTIVIE_THREE; break; case SituationType.SleepThree: sum += SLEEP_THREE; break; case SituationType.ActiveTwo: sum += ACTIVE_TWO; break; case SituationType.SleepTwo: sum += SLEEP_TWO; break; default: sum += OTHER; break; } } return(sum); }
/// <summary> /// 某种颜色棋子在某个方向上的棋型 /// </summary> /// <param name="x">横坐标</param> /// <param name="y">纵坐标</param> /// <param name="dir">方向</param> /// <param name="color">棋子颜色</param> /// <returns></returns> public SituationType GetSituationType(int x, int y, int dir, int color) { SituationType type = JudgeBeFive(x, y, dir, color); if (type == SituationType.Other) { type = JudgeActiveFour(x, y, dir, color); if (type == SituationType.Other) { type = JudgeRushFour(x, y, dir, color); if (type == SituationType.Other) { type = JudgeActiveThreeSleepThree(x, y, dir, color); if (type == SituationType.Other) { return(type = JudgeActvieTwoSleepTwo(x, y, dir, color)); } else { return(type); } } else { return(type); } } else { return(type); } } else { return(type); } }
// rozmisteni robotu a micku podle zvoleneho typu situace public void InitializeObjects(SituationType situationType) { situation = situationType; GameBall.GetComponent <Rigidbody>().velocity = new Vector2(0, 0); foreach (RobotSoccerSimulator.RealSimulator.Robot r in rightPlayerRobots) { r.Velocity = new Vector2D(0, 0); } foreach (RobotSoccerSimulator.RealSimulator.Robot r in leftPlayerRobots) { r.Velocity = new Vector2D(0, 0); } if (situationType == SituationType.Start) { GameBall.transform.position = new Vector3(0, 5, 0); BluePlayer1.transform.position = new Vector3((float)-AREA_X / 6, 5, (float)-AREA_Y / 6); BluePlayer2.transform.position = new Vector3((float)-AREA_X / 6, 5, (float)AREA_Y / 6); BluePlayer3.transform.position = new Vector3((float)-AREA_X / 3, 5, (float)-AREA_Y / 3); BluePlayer4.transform.position = new Vector3((float)-AREA_X / 3, 5, (float)AREA_Y / 3); BlueGoal.transform.position = new Vector3((float)-AREA_X / 2 + (float)ROBOT_EDGE_SIZE / 2, 5, 0); RedPlayer1.transform.position = new Vector3((float)AREA_X / 6, 5, (float)-AREA_Y / 6); RedPlayer2.transform.position = new Vector3((float)AREA_X / 6, 5, (float)AREA_Y / 6); RedPlayer3.transform.position = new Vector3((float)AREA_X / 3, 5, (float)-AREA_Y / 3); RedPlayer4.transform.position = new Vector3((float)AREA_X / 3, 5, (float)AREA_Y / 3); RedGoal.transform.position = new Vector3((float)AREA_X / 2 - (float)ROBOT_EDGE_SIZE / 2, 5, 0); } else if (situationType == SituationType.BluePlaceKick) { GameBall.transform.position = new Vector3(0, 5, 0); RedPlayer1.transform.position = new Vector3(-12, 5, -6); RedPlayer2.transform.position = new Vector3(18, 5, 6); RedPlayer3.transform.position = new Vector3(32, 5, -18); RedPlayer4.transform.position = new Vector3(23, 5, 28); RedGoal.transform.position = new Vector3((float)AREA_X / 2 - (float)ROBOT_EDGE_SIZE / 2, 5, 0); BluePlayer1.transform.position = new Vector3((float)-31.5, 5, 0); BluePlayer2.transform.position = new Vector3((float)-22.5, 5, -22); BluePlayer3.transform.position = new Vector3((float)-24.5, 5, 20); BluePlayer4.transform.position = new Vector3((float)-62.5, 5, 0); BlueGoal.transform.position = new Vector3((float)-AREA_X / 2 + (float)ROBOT_EDGE_SIZE / 2, 5, 0); } else if (situationType == SituationType.BluePenaltyKick) { GameBall.transform.position = new Vector3((float)72.5, 5, 0); RedPlayer1.transform.position = new Vector3(-6, 5, -34); RedPlayer2.transform.position = new Vector3(-6, 5, 34); RedPlayer3.transform.position = new Vector3(-6, 5, -47); RedPlayer4.transform.position = new Vector3(-6, 5, 47); RedGoal.transform.position = new Vector3((float)AREA_X / 2 - (float)ROBOT_EDGE_SIZE / 2, 5, 0); BluePlayer1.transform.position = new Vector3(54, 5, 0); BluePlayer2.transform.position = new Vector3(-6, 5, -19); BluePlayer3.transform.position = new Vector3(-6, 5, 19); BluePlayer4.transform.position = new Vector3(-6, 5, 0); BlueGoal.transform.position = new Vector3((float)-AREA_X / 2 + (float)ROBOT_EDGE_SIZE / 2, 5, 0); } else if (situationType == SituationType.BlueFreeKick) { GameBall.transform.position = new Vector3(72.5f, 5, 0); BluePlayer1.transform.position = new Vector3(25, 5, -30); BluePlayer2.transform.position = new Vector3(56, 5, 0); BluePlayer3.transform.position = new Vector3(-41, 5, 0); BluePlayer4.transform.position = new Vector3(25, 5, 30); BlueGoal.transform.position = new Vector3((float)-AREA_X / 2 + (float)ROBOT_EDGE_SIZE / 2, 5, 0); RedPlayer1.transform.position = new Vector3(88, 5, -20); RedPlayer2.transform.position = new Vector3(88, 5, 20); RedPlayer3.transform.position = new Vector3(88, 5, -47); RedPlayer4.transform.position = new Vector3(88, 5, 47); RedGoal.transform.position = new Vector3((float)AREA_X / 2 - (float)ROBOT_EDGE_SIZE / 2, 5, 0); } else if (situationType == SituationType.TRFreeBall) { GameBall.transform.position = new Vector3(55, 5, -60); RedPlayer1.transform.position = new Vector3(35, 5, 6); RedPlayer2.transform.position = new Vector3(80, 5, 6); RedPlayer3.transform.position = new Vector3(74, 5, -60); RedPlayer4.transform.position = new Vector3(60, 5, 6); RedGoal.transform.position = new Vector3(103, 5, -17); BluePlayer1.transform.position = new Vector3(35, 5, -60); BluePlayer2.transform.position = new Vector3(0, 5, -30); BluePlayer3.transform.position = new Vector3(0, 5, -70); BluePlayer4.transform.position = new Vector3(0, 5, 6); BlueGoal.transform.position = new Vector3((float)-AREA_X / 2 + (float)ROBOT_EDGE_SIZE / 2, 5, 0); } else if (situationType == SituationType.BlueGoalKick) { GameBall.transform.position = new Vector3(94, 5, 0); RedPlayer1.transform.position = new Vector3(68, 5, -20); RedPlayer2.transform.position = new Vector3(68, 5, 20); RedPlayer3.transform.position = new Vector3(100, 5, -33); RedPlayer4.transform.position = new Vector3(100, 5, 33); RedGoal.transform.position = new Vector3((float)AREA_X / 2 - (float)ROBOT_EDGE_SIZE / 2, 5, 0); BluePlayer1.transform.position = new Vector3(-6, 5, -30); BluePlayer2.transform.position = new Vector3(-6, 5, 0); BluePlayer3.transform.position = new Vector3(-6, 5, 30); BluePlayer4.transform.position = new Vector3(-50, 5, 0); BlueGoal.transform.position = new Vector3((float)-AREA_X / 2 + (float)ROBOT_EDGE_SIZE / 2, 5, 0); } else if (situationType == SituationType.RedPlaceKick) { InitializeObjects(SituationType.BluePlaceKick); yMirrorRobotsPositions(); } else if (situationType == SituationType.RedPenaltyKick) { InitializeObjects(SituationType.BluePenaltyKick); yMirrorRobotsPositions(); } else if (situationType == SituationType.RedFreeKick) { InitializeObjects(SituationType.BlueFreeKick); yMirrorRobotsPositions(); } else if (situationType == SituationType.TLFreeBall) { InitializeObjects(SituationType.TRFreeBall); yMirrorRobotsPositions(); } else if (situationType == SituationType.BRFreeBall) { InitializeObjects(SituationType.TRFreeBall); xMirrorRobotsPositions(); } else if (situationType == SituationType.BLFreeBall) { InitializeObjects(SituationType.TRFreeBall); xMirrorRobotsPositions(); yMirrorRobotsPositions(); } else if (situationType == SituationType.RedGoalKick) { InitializeObjects(SituationType.BlueGoalKick); yMirrorRobotsPositions(); } }
/// <summary> /// Analyse the situation of the actual event in combination with the meta data storage. /// </summary> /// <param name="storage">Meta data storage.</param> /// <param name="actualEvent">Actual event.</param> /// <returns>The detected local situation.</returns> public SituationType Analyse(IMetaDataStorage storage, AbstractFolderEvent actualEvent) { SituationType type = this.DoAnalyse(storage, actualEvent); return(type); }
public SituationEventArgs(Guid compressorGuid, SituationType situationType) : base(compressorGuid) { SituationType = situationType; Message = situationType.GetDescription(); }