예제 #1
0
        static Matrix()
        {
            int directionsCount = Walk.ValidlDirections;
            steps = new Walk[directionsCount];

            for (int i = 0; i < directionsCount; i++)
            {
                steps[i] = new Walk((Directions)i);
            }
        }
예제 #2
0
        public void RotatingWalk()
        {
            this.Clear();

            int count = 1;
            Position position = new Position(0, 0);
            Walk walk = new Walk(Directions.SE);

            while (true)
            {
                this.matrix[position.Row, position.Column] = count;

                if (!this.CanWalkToPosition(position))
                {
                    bool positionAvailable = this.FindAvailablePosition(out position);
                    if (positionAvailable)
                    {
                        count++;
                        this.matrix[position.Row, position.Column] = count;
                        walk.Direction = Directions.SE;
                    }
                    else
                    {
                        break;
                    }
                }

                while (!this.CheckIfPositionIsValid(position.Row + walk.Vertical, position.Column + walk.Horizontal))
                {
                    walk.ChangeDirection();
                }

                position.UpdatePosition(walk);
                count++;
            }
        }