Пример #1
0
        static public IPuzzleAction Parse(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            string parseText = text.Trim();

            if (!parseText.StartsWith("{") || !parseText.EndsWith("}"))
            {
                return(null);
            }
            parseText = parseText.Substring(1, parseText.Length - 2);

            string[] splits = parseText.Split(new[] { ',' });
            if (splits.Length != 2)
            {
                return(null);
            }

            ActionTypes    type      = (ActionTypes)Enum.Parse(typeof(ActionTypes), splits[0].Trim(), true);
            DirectionTypes direction = (DirectionTypes)Enum.Parse(typeof(DirectionTypes), splits[1].Trim(), true);

            return(new PuzzleAction(type, direction));;
        }
Пример #2
0
 public void SetCurrentDirection(DirectionTypes direction)
 {
     this.direction  = direction;
     directionString = null;
     FireChange("Direction");
     FireChange("DirectionString");
 }
Пример #3
0
 public SensationSnapshot(DirectionTypes directionType, FieldOfVisionTypes fieldOfVisionType, List <ISensoryPattern> sensoryPatterns, bool saveable = true)
 {
     Id            = -1;
     Direction     = directionType;
     FieldOfVision = fieldOfVisionType;
     SensoryPatterns.AddRange(sensoryPatterns);
 }
Пример #4
0
 public MessageEntityEntryAttribute(string name, DirectionTypes direction, InteractionTypes interaction, string description)
 {
     Name        = name;
     Direction   = direction;
     Interaction = interaction;
     Description = description;
 }
Пример #5
0
 //to upload
 public FtpFileInfo(string fileName, string destination, DirectionTypes direction, bool mkdirFlag)
 {
     this.completeFileName = fileName;
     this.destination      = destination;
     this.direction        = direction;
     this.mkdirFlag        = mkdirFlag;
 }
Пример #6
0
 public PartialSnapshotCompression(CompressionTypes compressionType, FieldOfVisionTypes fieldOfVision, DirectionTypes direction)
 {
     Id = -1;
     CompressionType = compressionType;
     FieldOfVision   = fieldOfVision;
     Direction       = direction;
 }
Пример #7
0
        static public DirectionTypes Substraction(DirectionTypes first, DirectionTypes second)
        {
            var firstPoint  = ConvertToPoint(first);
            var secondPoint = ConvertToPoint(second);
            var resultPoint = new Point(firstPoint.X - secondPoint.X, firstPoint.Y - secondPoint.Y);

            return(ConvertToDirectionType(resultPoint));
        }
Пример #8
0
        public void Experience(FieldOfVisionTypes fieldOfVisionType, PuzzleBoard partialBoard)
        {
            Point centerPos = new Point();

            switch (fieldOfVisionType)
            {
            case FieldOfVisionTypes.Single:
                centerPos = new Point(0, 0);
                break;

            case FieldOfVisionTypes.ThreeByThree:
                centerPos = new Point(1, 1);
                break;

            case FieldOfVisionTypes.FiveByFive:
                centerPos = new Point(2, 2);
                break;
            }

            List <ISensoryPattern> sensoryPatterns = new List <ISensoryPattern>();

            for (int y = 0; y < partialBoard.Rows; y++)
            {
                for (int x = 0; x < partialBoard.Columns; x++)
                {
                    Point                pos           = new Point(x, y);
                    DirectionTypes       directionType = PuzzleReferee.ConvertToDirectionType(new Point(pos.X - centerPos.X, pos.Y - centerPos.Y));
                    PuzzleCellStateTypes state         = partialBoard.GetState(pos);
                    int    value       = partialBoard.GetValue(pos);
                    string valueString = value >= 0 ? value.ToString() : " ";

                    if (state != PuzzleCellStateTypes.Undefined)
                    {
                        ISensoryUnit sensoryUnitState = GetOrCreateSensoryUnit(SensoryTypes.FieldState, state.ToString());
                        ISensoryUnit sensoryUnitValue = GetOrCreateSensoryUnit(SensoryTypes.FieldValue, valueString);

                        List <ISensoryUnit> sensoryUnits = new List <ISensoryUnit>();
                        sensoryUnits.Add(sensoryUnitState);
                        sensoryUnits.Add(sensoryUnitValue);

                        ISensoryPattern sensoryPattern = new SensoryPattern(directionType, sensoryUnits);

                        if (_kownSensoryPatterns.Contains(sensoryPattern))
                        {
                            sensoryPattern = _kownSensoryPatterns[_kownSensoryPatterns.IndexOf(sensoryPattern)];
                        }
                        else
                        {
                            _kownSensoryPatterns.Add(sensoryPattern);
                            _kownSensoryPatterns.Sort();
                        }

                        sensoryPatterns.Add(sensoryPattern);
                    }
                }
            }
            _lastSensationSnapshot = new SensationSnapshot(DirectionTypes.Center, fieldOfVisionType, sensoryPatterns, IS_SAVEABLE_SNAPSHOT);
        }
Пример #9
0
 private void MoveRobot(DirectionTypes directionType)
 {
     if (_puzzleReferee.CheckAction(_robotBrain.Position, directionType, ActionTypes.Move))
     {
         Point direction      = PuzzleReferee.ConvertToPoint(directionType);
         Point actionPosition = new Point(_robotBrain.Position.X + direction.X, _robotBrain.Position.Y + direction.Y);
         _robotBrain.Position = actionPosition;
     }
 }
Пример #10
0
        static public IPartialSnapshotCompression Parse(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            string parseText = text.Trim();

            if (!parseText.StartsWith("{") || !parseText.EndsWith("}"))
            {
                return(null);
            }
            parseText = parseText.Substring(1, parseText.Length - 2);

            string[] splits = parseText.Split(new[] { ',' });
            if (splits.Length <= 2)
            {
                return(null);
            }

            CompressionTypes   compressionType = (CompressionTypes)Enum.Parse(typeof(CompressionTypes), splits[0].Trim(), true);
            FieldOfVisionTypes fieldOfVision   = (FieldOfVisionTypes)Enum.Parse(typeof(FieldOfVisionTypes), splits[1].Trim(), true);
            DirectionTypes     direction       = DirectionTypes.Undefined;
            string             childNodesText  = splits[2].Trim();

            if (!childNodesText.Contains("{"))
            {
                direction      = (DirectionTypes)Enum.Parse(typeof(DirectionTypes), childNodesText, true);
                childNodesText = splits[3].Trim();
            }

            var result = new PartialSnapshotCompression(compressionType, fieldOfVision, direction);

            if (!childNodesText.Contains("<Empty>"))
            {
                if (!childNodesText.StartsWith(IdentifierChildNodes))
                {
                    result.ChildNodes.Add(PartialSnapshotCompressionNode.Parse(childNodesText));
                }
                else
                {
                    // =======================================================================================================================
                    // ToDo: Check ChildNodeTree also!!! Up to now it's only one single child handled! (Think about regular expressions maybe)
                    // =======================================================================================================================
                    childNodesText = childNodesText.Substring(IdentifierChildNodes.Length);
                    childNodesText = IdentifierChildNodes.Substring(0, childNodesText.Length - 1);
                    var splitedChildNodesText = childNodesText.Split(new[] { ';' });
                    foreach (var childNodeText in splitedChildNodesText)
                    {
                        result.ChildNodes.Add(PartialSnapshotCompressionNode.Parse(childNodeText));
                    }
                }
            }
            return(result);
        }
Пример #11
0
        private void BtnMove_Click(object sender, EventArgs e)
        {
            if (_cbxDirectionTypes.SelectedIndex < 0)
            {
                return;
            }
            DirectionTypes directionType = (DirectionTypes)_cbxDirectionTypes.SelectedItem;

            MoveRobot(directionType);
        }
Пример #12
0
        public void DirectionTypeTest()
        {
            Matrix         target   = new Matrix(new int[3, 3]);
            DirectionTypes expected = DirectionTypes.Northwest;
            DirectionTypes actual;

            target.DirectionType = expected;
            actual = target.DirectionType;
            Assert.AreEqual(expected, actual);
        }
Пример #13
0
 public Robot(double top, double left, string image, string color, string name, DirectionTypes direction)
     : base()
 {
     ID        = Guid.NewGuid().ToString();
     Top       = top;
     Left      = left;
     Image     = image;
     Color     = color;
     Name      = name;
     Direction = direction;
 }
Пример #14
0
 public Message(agsXMPP.protocol.client.Message msg, DirectionTypes directionType, DateTime receivedTime)
 {
     this.InternalMessage  = msg;
     this.DateTimeReceived = receivedTime;
     this.DirectionType    = directionType;
     this.Unread           = (directionType == DirectionTypes.Incoming);
     this.MessageID        = Guid.NewGuid();
     this.InternalMessage  = msg;
     this.Replied          = false;
     base.Path             = MessageID.ToString();
     UpdateItemInfo();
 }
Пример #15
0
 public IActionResult Test([FromJsonBody] string phoneNumber, [FromJsonBody] string test1,
                           [FromJsonBody][Range(0, 100, ErrorMessage = "Age must be between 0 and 100")] int?age,
                           [FromJsonBody] bool gender,
                           [FromJsonBody] double salary, [FromJsonBody] DirectionTypes dir,
                           [FromJsonBody][Required] string name)
 {
     if (ModelState.IsValid == false)
     {
         var errors = ModelState.SelectMany(e => e.Value.Errors).Select(e => e.ErrorMessage);
         return(Json("Invalid input!" + string.Join("\r\n", errors)));
     }
     return(Json($"phoneNumber={phoneNumber},test1={test1},age={age},gender={gender},salary={salary},dir={dir}"));
 }
Пример #16
0
        private void RobotBrain_ActionWanted(object sender, ActionWantedEventArgs e)
        {
            DirectionTypes actionDirection = e.Action.Direction;
            ActionTypes    actionType      = e.Action.Type;

            if (_puzzleReferee.CheckAction(_robotBrain.Position, actionDirection, actionType))
            {
                Point direction        = PuzzleReferee.ConvertToPoint(actionDirection);
                Point actionPosition   = new Point(_robotBrain.Position.X + direction.X, _robotBrain.Position.Y + direction.Y);
                int   stateChangeCount = 0;
                switch (actionType)
                {
                case ActionTypes.Move:
                    _robotBrain.Position = actionPosition;
                    break;

                case ActionTypes.MarkAsEmpty:
                    stateChangeCount = _puzzleBoard.SetState(actionPosition, PuzzleCellStateTypes.Empty).Count;
                    break;

                case ActionTypes.MarkAsFilled:
                    stateChangeCount = _puzzleBoard.SetState(actionPosition, PuzzleCellStateTypes.Filled).Count;
                    break;

                case ActionTypes.RemoveMarker:
                    stateChangeCount = _puzzleBoard.SetState(actionPosition, PuzzleCellStateTypes.NotMarked).Count;
                    break;
                }
                if (_puzzleBoard.IsWrong())
                {
                    _robotBrain.ActionFeedback -= 1000;
                }
                else if (_puzzleBoard.IsComplete())
                {
                    _robotBrain.ActionFeedback += 100;
                }
                else if (stateChangeCount > 0)
                {
                    _robotBrain.ActionFeedback += stateChangeCount;
                }
            }

            if (!_simulationRunsInBackground && _cbxAutoRefreshPlayground.Checked)
            {
                RefreshPlayGround();
                RecreateCells();
            }
        }
Пример #17
0
        private void DoStateAction(PuzzleCellStateTypes markerState)
        {
            if (_cbxDirectionTypes.SelectedIndex < 0)
            {
                return;
            }
            DirectionTypes directionType  = (DirectionTypes)_cbxDirectionTypes.SelectedItem;
            Point          direction      = PuzzleReferee.ConvertToPoint(directionType);
            Point          markerPosition = new Point(_robotBrain.Position.X + direction.X, _robotBrain.Position.Y + direction.Y);

            _puzzleBoard.SetState(markerPosition, markerState);

            if (_cbxAutoRefreshPlayground.Checked)
            {
                RefreshPlayGround();
                RecreateCells();
            }
        }
Пример #18
0
        Vector3 GetDirectionFromType(Transform _transform, DirectionTypes type)
        {
            switch (type)
            {
            case DirectionTypes.MarkerForward:
                return(_transform.forward);

            case DirectionTypes.MarkerRight:
                return(_transform.right);

            case DirectionTypes.MarkerLeft:
                return(-_transform.right);

            case DirectionTypes.MarkerBackward:
                return(-_transform.forward);

            case DirectionTypes.MarkerUp:
                return(_transform.up);

            case DirectionTypes.MarkerBottom:
                return(-_transform.up);

            case DirectionTypes.WorldForward:
                return(Vector3.forward);

            case DirectionTypes.WorldBackward:
                return(Vector3.back);

            case DirectionTypes.WorldRight:
                return(Vector3.right);

            case DirectionTypes.WorldLeft:
                return(Vector3.left);

            case DirectionTypes.WorldUp:
                return(Vector3.up);

            case DirectionTypes.WorldBottom:
                return(Vector3.down);

            default:
                return(Vector3.zero);
            }
        }
Пример #19
0
        public void AddExit(string direction, long destination, string description)
        {
            DirectionTypes dir = Realm.Library.Common.Extensions.EnumerationExtensions.GetEnumIgnoreCase <DirectionTypes>(direction);

            if (Exits.Any(x => x.Direction == dir))
            {
                return;
            }

            ExitData newExit = new ExitData((int)dir, direction)
            {
                Destination = destination,
                Description = description,
                Direction   = dir,
                Keywords    = direction
            };

            Exits.Add(newExit);
        }
Пример #20
0
        public bool CheckAction(Point position, DirectionTypes directionType, ActionTypes actionType)
        {
            bool  result         = false;
            Point direction      = ConvertToPoint(directionType);
            Point actionPosition = new Point(position.X + direction.X, position.Y + direction.Y);

            switch (actionType)
            {
            case ActionTypes.Move:
                result = actionPosition.X >= 0 && actionPosition.X < _board.Columns && actionPosition.Y >= 0 && actionPosition.Y < _board.Rows;
                break;

            case ActionTypes.MarkAsEmpty:
            case ActionTypes.MarkAsFilled:
                result = _board.GetState(actionPosition) == PuzzleCellStateTypes.NotMarked;
                break;
            }
            return(result);
        }
Пример #21
0
        static public ISensoryPattern Parse(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            string parseText = text.Trim();

            if (!parseText.StartsWith("{") || !parseText.EndsWith("}"))
            {
                return(null);
            }
            parseText = parseText.Substring(1, parseText.Length - 2);

            string[] splits = parseText.Split(new[] { ',' });
            if (splits.Length != 2)
            {
                return(null);
            }

            DirectionTypes direction        = (DirectionTypes)Enum.Parse(typeof(DirectionTypes), splits[0].Trim(), true);
            string         sensoryUnitsText = splits[1].Trim();

            if (sensoryUnitsText.Length >= 2)
            {
                sensoryUnitsText = sensoryUnitsText.Substring(1, sensoryUnitsText.Length - 2);
            }
            else
            {
                sensoryUnitsText = string.Empty;
            }
            string[]            sensoryUnitSplittedText = sensoryUnitsText.Split(new[] { ';' });
            List <ISensoryUnit> sensoryUnits            = new List <ISensoryUnit>();

            foreach (string sensoryUnitText in sensoryUnitSplittedText)
            {
                sensoryUnits.Add(SensoryUnit.Parse(sensoryUnitText));
            }

            return(new SensoryPattern(direction, sensoryUnits));
        }
Пример #22
0
        public void StartPrintStatistics(DirectionTypes directionType)
        {
            _directionType = directionType;

            switch (directionType)
            {
            case DirectionTypes.Sender:
                _log.Info(GetSenderSummaryHeader());
                break;

            case DirectionTypes.Receiver:
                _log.Info(GetReceiverSummaryHeader());
                break;

            default:
                throw new ArgumentOutOfRangeException("directionType");
            }

            _printStatisticsTimer = new Timer(PrintStatisticsTask, this, 1000, 1000);
        }
Пример #23
0
        public bool ClickGetDirection(DirectionTypes p_DirectionType)
        {
            try
            {
                if (!getDirectionsButton.Enabled || !getDirectionsButton.Displayed)
                {
                    return(LogError("Get Directions button is disabled or invisible!"));
                }

                getDirectionsButton.Click();

                // Wait for the response
                WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 10));
                switch (p_DirectionType)
                {
                case DirectionTypes.TRAFFIC_AWARE:
                    wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[contains(text(),'Traffic Aware Route')]")));
                    break;

                case DirectionTypes.TOLL_AWARE:
                    wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[contains(text(),'Toll aware')]")));
                    break;

                case DirectionTypes.FASTEST:
                    wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[contains(text(),'Fastest')]")));
                    break;

                case DirectionTypes.SHORTEST:
                    wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[contains(text(),'Shortest')]")));
                    break;
                }

                Thread.Sleep(1000); // hacky
            }
            catch (Exception ex)
            {
                return(LogError("Exception caught while performing ClickGetDirection(), error: " + ex.ToString()));
            }

            return(true);
        }
Пример #24
0
    void KeyInputHandle()
    {
        if (Input.anyKeyDown)
        {
            m_activeInput = true;
        }

        if (m_activeInput)
        {
            if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
            {
                m_directionType = DirectionTypes.Left;
                m_activeInput   = false;
            }
            else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
            {
                m_directionType = DirectionTypes.Right;
                m_activeInput   = false;
            }
            else if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
            {
                m_directionType = DirectionTypes.Up;
                m_activeInput   = false;
            }
            else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
            {
                m_directionType = DirectionTypes.Down;
                m_activeInput   = false;
            }

            if (m_directionType != DirectionTypes.None && m_OnTouchEvent != null)
            {
                m_OnTouchEvent(m_directionType);
            }
        }
        else
        {
            m_directionType = DirectionTypes.None;
        }
    }
Пример #25
0
        static private List <ISensoryPattern> Split(DirectionTypes directionType, int level, List <ISensoryUnit> sensoryUnits)
        {
            List <ISensoryPattern> result = new List <ISensoryPattern>();

            if (level == 1)
            {
                foreach (ISensoryUnit leftUnit in sensoryUnits)
                {
                    var splittedSensoryUnits = new List <ISensoryUnit>();
                    splittedSensoryUnits.Add(leftUnit);
                    ISensoryPattern newEntry = new SensoryPattern(directionType, splittedSensoryUnits);
                    result.Add(newEntry);
                }
            }
            else if (level >= 2)
            {
                var reducedSensoryUnits = new List <ISensoryUnit>();
                reducedSensoryUnits.AddRange(sensoryUnits);

                foreach (ISensoryUnit leftUnit in sensoryUnits)
                {
                    if (reducedSensoryUnits.Count < level)
                    {
                        break;
                    }
                    reducedSensoryUnits.RemoveAt(0);
                    var testPattern = Split(directionType, level - 1, reducedSensoryUnits);
                    foreach (var rightPattern in testPattern)
                    {
                        var splittedSensoryUnits = new List <ISensoryUnit>();
                        splittedSensoryUnits.Add(leftUnit);
                        splittedSensoryUnits.AddRange(rightPattern.SensoryUnits);
                        ISensoryPattern newEntry = new SensoryPattern(directionType, splittedSensoryUnits);
                        result.Add(newEntry);
                    }
                }
            }

            return(result);
        }
Пример #26
0
    protected void CheckKeys()
    {
        if (Input.anyKeyDown)
        {
            m_activeInput = true;
        }

        if (m_activeInput)
        {
            if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
            {
                m_directionType = DirectionTypes.Left;
                m_activeInput   = false;
            }
            else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
            {
                m_directionType = DirectionTypes.Right;
                m_activeInput   = false;
            }
            else if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
            {
                m_directionType = DirectionTypes.Up;
                m_activeInput   = false;
            }
            else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
            {
                m_directionType = DirectionTypes.Down;
                m_activeInput   = false;
            }

            if (m_directionType != DirectionTypes.None && SwipeEvents != null)
            {
                SwipeEvents(m_directionType);
            }
        }
        else
        {
            m_directionType = DirectionTypes.None;
        }
    }
Пример #27
0
 // Start is called before the first frame update
 void Start()
 {
     if (GameObject.FindGameObjectWithTag("Player") != null)
     {
         playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
     }
     if (randomizeXStart)
     {
         if (Random.Range(0f, 1f) < 0.5f) // ~50% chance
         {
             var flipValues = false;
             if (StartPositionX == StartPositionsX.screen_left)
             {
                 StartPositionX = StartPositionsX.screen_right;
                 flipValues     = true;
             }
             else if (StartPositionX == StartPositionsX.screen_right)
             {
                 StartPositionX = StartPositionsX.screen_left;
                 flipValues     = true;
             }
             if (flipValues)
             {
                 CustomShapeVector.x     *= -1;
                 CustomDirectionVector.x *= -1;
                 offset_x *= -1;
                 if (Direction == DirectionTypes.left)
                 {
                     Direction = DirectionTypes.right;
                 }
                 else if (Direction == DirectionTypes.left)
                 {
                     Direction = DirectionTypes.right;
                 }
             }
         }
     }
 }
Пример #28
0
        static public List <IPartialSnapshotCompression> NewInstances(ISensationSnapshot snapshot, FieldOfVisionTypes fieldOfVision, DirectionTypes direction, CompressionTypes maximumCompression)
        {
            var result = new List <IPartialSnapshotCompression>();

            ISensationSnapshot partialSnapshot = SensationSnapshot.ExtractSnapshot(snapshot, fieldOfVision, direction);

            // Single units for fieldOfVision.Single and fieldOfVision.ThreeByThree allows to find 0 and 9
            var unitCountDictonary = SensationSnapshot.CountUnits(partialSnapshot);


            result.AddRange(NewInstancesOfUnitCompression(unitCountDictonary, fieldOfVision));

            if (maximumCompression >= CompressionTypes.UnitSimpleTree)
            {
                // Find 1 and 8 if a field around is marked as Filled or Empty (two pattern with single unit) --> fieldOfVision.ThreeByThree
                result.AddRange(NewInstancesOfUnitSimpleTreeCompression(unitCountDictonary, partialSnapshot, snapshot, fieldOfVision, direction));
            }

            if (maximumCompression >= CompressionTypes.UnitCountTree)
            {
                // ToDo: Find 2-7 if 2-7 fields around are marked as Filled or Empty (two pattern with counted units) --> fieldOfVision.ThreeByThree
                result.AddRange(NewInstancesOfUnitCountTreeCompression(unitCountDictonary, partialSnapshot, snapshot, fieldOfVision, direction));
            }

            if (maximumCompression >= CompressionTypes.MultiUnitCountTree)
            {
                // ToDo: Find 1-5 fields at the boarder with combination of Empty and Outside  --> fieldOfVision.ThreeByThree
                result.AddRange(NewInstancesOfMultiUnitCountTreeCompression(unitCountDictonary, partialSnapshot, snapshot, fieldOfVision, direction));
            }

            return(result);
        }
Пример #29
0
        static public List <IPartialSnapshotCompression> NewInstancesOfMultiUnitCountTreeCompression(ISensationSnapshot snapshot, FieldOfVisionTypes fieldOfVision, DirectionTypes direction)
        {
            var result = new List <IPartialSnapshotCompression>();

            ISensationSnapshot partialSnapshot = SensationSnapshot.ExtractSnapshot(snapshot, fieldOfVision, direction);
            var unitCountDictonary             = SensationSnapshot.CountUnits(partialSnapshot);

            result.AddRange(NewInstancesOfMultiUnitCountTreeCompression(unitCountDictonary, partialSnapshot, snapshot, fieldOfVision, direction));

            return(result);
        }
Пример #30
0
        static public List <IPartialSnapshotCompression> NewInstancesOfMultiUnitCountTreeCompression(Dictionary <ISensoryUnit, int> unitCountDictonary, ISensationSnapshot partialSnapshot, ISensationSnapshot snapShot, FieldOfVisionTypes fieldOfVision, DirectionTypes direction)
        {
            var result = new List <IPartialSnapshotCompression>();

            // Find 2-7 if 2-7 fields around are marked as Filled or Empty (two pattern with counted units) --> fieldOfVision.ThreeByThree
            foreach (KeyValuePair <ISensoryUnit, int> unitCountEntry in unitCountDictonary)
            {
                var patterns = partialSnapshot.SensoryPatterns.Where(p => p.SensoryUnits.Contains(unitCountEntry.Key)).ToList();
                foreach (ISensoryPattern pattern in patterns)
                {
                    ISensationSnapshot partialSnapshot2 = SensationSnapshot.ExtractSnapshot(snapShot, fieldOfVision, PuzzleReferee.Addition(direction, pattern.DirectionType));
                    var unitCountDictonary2             = SensationSnapshot.CountUnits(partialSnapshot2);
                    List <ISensoryUnit> sortedUnits     = new List <ISensoryUnit>();
                    sortedUnits.AddRange(unitCountDictonary2.Keys.ToList());
                    sortedUnits.Sort();
                    for (int i = 0; i < sortedUnits.Count - 1; i++)
                    {
                        var unitKey1   = sortedUnits[i];
                        int unitValue1 = unitCountDictonary2[unitKey1];
                        if (unitKey1.Equals(unitCountEntry.Key))
                        {
                            unitValue1--;
                            if (unitValue1 < 1)
                            {
                                // If the same unit found one time in the field of view, it must be the exact same one.
                                continue;
                            }
                        }
                        for (int j = i + 1; j < sortedUnits.Count; j++)
                        {
                            var unitKey2   = sortedUnits[j];
                            var unitValue2 = unitCountDictonary2[unitKey2];
                            if (unitKey2.Equals(unitCountEntry.Key))
                            {
                                unitValue2--;
                                if (unitValue2 < 1)
                                {
                                    // If the same unit found one time in the field of view, it must be the exact same one.
                                    continue;
                                }
                            }
                            var unitCompression = new PartialSnapshotCompression(CompressionTypes.MultiUnitCountTree, fieldOfVision, DirectionTypes.Undefined);
                            var node            = new PartialSnapshotCompressionNode(unitCountEntry.Key);

                            for (int q = 0; q < unitValue1; q++)
                            {
                                node.ChildNodes.Add(new PartialSnapshotCompressionNode(unitKey1));
                            }
                            for (int q = 0; q < unitValue2; q++)
                            {
                                node.ChildNodes.Add(new PartialSnapshotCompressionNode(unitKey2));
                            }

                            unitCompression.ChildNodes.Add(node);
                            if (!result.Contains(unitCompression))
                            {
                                result.Add(unitCompression);
                            }
                        }
                    }
                }
            }
            return(result);
        }
Пример #31
0
 private RoomDirectionData GetExit(CharacterData character, DirectionTypes direction)
 {
     return _rooms[character.InRoom].DirectionOptions[(int)direction];
 }
Пример #32
0
        private bool PerformMove(CharacterData character, DirectionTypes direction, bool needSpecialsCheck)
        {
            int wasInRoom = 0;

            if (character == null || character.Fighting != null)
                return false;
            else if (GetExit(character, direction) == null || GetExit(character, direction).ToRoom == GlobalConstants.NOWHERE)
                SendToCharacter (character, "Alas, you cannot go that way...\r\n");
            else if (GetExit(character, direction).ExitFlagged(DirectionOptionFlags.Closed))
            {
                if (!String.IsNullOrEmpty(GetExit(character, direction).Keyword))
                    SendToCharacter (character, "The " + GlobalUtilities.FirstName(GetExit(character, direction).Keyword) + " seems to be closed.\r\n");
                else
                    SendToCharacter (character, "It seems to be closed.\r\n");
            }
            else
            {
                if (!character.HasFollowers)
                    return (DoSimpleMove (character, direction, needSpecialsCheck));

                wasInRoom = character.InRoom;

                if (!DoSimpleMove (character, direction, needSpecialsCheck))
                    return false;

                foreach (CharacterData follower in character.Followers)
                {
                    if ((follower.InRoom == wasInRoom) && follower.Position >= PositionTypes.Standing)
                    {
                        Act("You follow $N.\r\n", false, follower, null, character, GlobalConstants.TO_CHAR);
                        PerformMove (follower, direction, true);
                    }
                }

                return true;
            }

            return false;
        }
Пример #33
0
        private bool DoSimpleMove(CharacterData character, DirectionTypes direction, bool needsSpecialsCheck)
        {
            int needMovement;

            if (needsSpecialsCheck && Special (character, (int)direction + 1, String.Empty))
                return false;

            /* blocked by a leave trigger ? */
            //if (!leave_mtrigger (ch, dir))
            //	return 0;
            //if (!leave_wtrigger (&world[IN_ROOM (ch)], ch, dir))
            //	return 0;

            if (character.AffectFlagged (AffectFlags.Charm) && character.Master != null &&
                character.InRoom == character.Master.InRoom)
            {
                SendToCharacter (character, "The thought of leaving your master makes you weep.\r\n");
                Act("$n bursts into tears.", false, character, null, null, GlobalConstants.TO_ROOM);
                return false;
            }

            if ((GetRoomSector (character.InRoom) == SectorTypes.WaterNoSwim) ||
                GetRoomSector (GetExit (character, direction).ToRoom) == SectorTypes.WaterNoSwim)
            {
                if (!HasBoat (character))
                {
                    SendToCharacter (character, "You need a boat to go there.\r\n");
                    return false;
                }
            }

            needMovement = (MovementLoss[(int)GetRoomSector (character.InRoom)] +
                MovementLoss[(int)GetRoomSector (GetExit (character, direction).ToRoom)]) / 2;

            if (character.Points.Move < needMovement && !character.IsNPC)
            {
                if (needsSpecialsCheck && character.Master != null)
                    SendToCharacter (character, "You are too exhausted to follow.\r\n");
                else
                    SendToCharacter (character, "You are too exhausted.\r\n");

                return false;
            }

            if (_rooms[character.InRoom].RoomFlagged (RoomFlags.Atrium))
            {
                if (!HouseCanEnter (character, GetRoomVirtualNumber (GetExit (character, direction).ToRoom)))
                {
                    SendToCharacter (character, "That's private property -- no trespassing!\r\n");
                    return false;
                }
            }

            if (_rooms[GetExit (character, direction).ToRoom].RoomFlagged (RoomFlags.Tunnel) &&
                NumberOfPCInRoom (_rooms[GetExit (character, direction).ToRoom]) >= GlobalSettings.TunnelSize)
            {
                if (GlobalSettings.TunnelSize > 1)
                    SendToCharacter (character, "There isn't enough room for you to go there!\r\n");
                else
                    SendToCharacter (character, "There isn't enough room there for more than one person!\r\n");

                return false;
            }

            if (_rooms[GetExit (character, direction).ToRoom].RoomFlagged (RoomFlags.GodRoom) &&
                character.Level < GlobalConstants.LVL_GRGOD)
            {
                SendToCharacter (character, "You aren't godly enough to use that room!\r\n");
                return false;
            }

            if (character.Level < GlobalConstants.LVL_IMMORT && !character.IsNPC)
                character.Points.Move -= needMovement;

            if (!character.AffectFlagged (AffectFlags.Sneak))
            {
                Act("$n leaves "+GlobalConstants.Directions[(int)direction], true, character, null, null, GlobalConstants.TO_ROOM);
            }

            int wasInRoom = character.InRoom;
            CharacterFromRoom (character);
            CharacterToRoom (character, _rooms[wasInRoom].DirectionOptions[(int)direction].ToRoom);

            // Trigger Stuff
            /* move them first, then move them back if they aren't allowed to go. */
            /* see if an entry trigger disallows the move */
            //if (!entry_mtrigger(ch) || !enter_wtrigger(&world[IN_ROOM(ch)], ch, dir))
            //{
            //char_from_room(ch);
            //char_to_room(ch, was_in);
            //return 0;
            //}

            if (!character.AffectFlagged (AffectFlags.Sneak))
                Act ("$n has arrived.", true, character, null, null, GlobalConstants.TO_ROOM);

            if (character.Descriptor != null)
                //LookAtRoom (character, 0);

            if (_rooms[character.InRoom].RoomFlagged (RoomFlags.Death) && character.Level < GlobalConstants.LVL_IMMORT)
            {
                //LogDeathTrap (character);
                //DeathCry (character);
                //ExtractCharacter (character);
                return false;
            }

            //entry_memory_mtrigger (ch);

            //if (!greet_mtrigger (ch, dir))
            //{
            //	char_from_room (ch);
            //	char_to_room (ch, was_in);
            //	look_at_room (ch, 0);
            //}
            //else
            //	greet_memory_mtrigger (ch);

            return true;
        }
        public void StartPrintStatistics(DirectionTypes directionType)
        {
            _directionType = directionType;

              switch (directionType)
              {
            case DirectionTypes.Sender:
              _log.Info(GetSenderSummaryHeader());
              break;
            case DirectionTypes.Receiver:
              _log.Info(GetReceiverSummaryHeader());
              break;
            default:
              throw new ArgumentOutOfRangeException("directionType");
              }

              _printStatisticsTimer = new Timer(PrintStatisticsTask, this, 1000, 1000);
        }