Пример #1
0
 public OptionSelectedCondition(OptionSelectedCondition src)
     : base(src._lineNumber, src._linePosition)
 {
     Source   = src.Source;           // can share paths, but not resolved references
     Require  = src.Require;
     Prohibit = src.Prohibit;
 }
Пример #2
0
 public DocTagCondition(DocTagCondition src)
     : base(src._lineNumber, src._lineNumber)
 {
     Source   = src.Source;           // can share paths, but not resolved references
     DocTag   = src.DocTag;
     Require  = src.Require;
     Prohibit = src.Prohibit;
 }
Пример #3
0
 public PhotoCountCondition(PhotoCountCondition src)
     : base(src._lineNumber, src._linePosition)
 {
     Source  = src.Source;            // can share paths, but not resolved references
     Context = src.Context;
     RefType = src.RefType;
     RefId   = src.RefId;
     Minimum = src.Minimum;
     Maximum = src.Maximum;
 }
Пример #4
0
        public static Population CreatePopulation(Path.Path path, int populationSize)
        {
            var pathList = new List <Path.Path>();

            for (int i = 0; i < populationSize; ++i)
            {
                pathList.Add(path.Shuffle());
            }
            return(new Population(pathList));
        }
Пример #5
0
        /// <summary>
        /// Resolve a path into zero or more concrete objects. The returned
        /// list is sorted by ordinal.
        /// </summary>
        /// Resolution into an object involves a call into the database.
        internal List <T> ResolveMany <T>(Path.Path path, Reference context) where T : class, IContentSource
        {
            List <Reference> references = ResolveMany(path, context);
            List <string>    ids        = references.Select(r => r.Id).ToList();

            return(_unitOfWork.Repository <T>()
                   .Query(t => ids.Contains(t.Id))
                   .Get()
                   .ToList());
        }
Пример #6
0
        /// <summary>
        /// Resolve a path into zero or one concrete object.
        /// </summary>
        /// Resolution into an object involves a call into the database.
        /// <exception cref="AmbiguousPathException"></exception>
        internal T ResolveOne <T>(Path.Path path, Reference context) where T : class, IContentSource
        {
            Reference reference = ResolveOne(path, context);

            if (reference == null)
            {
                return(null);
            }
            return(ResolveOne <T>(reference));
        }
Пример #7
0
        public void findTest()
        {
            IFinder finder = new Permutation(CreateGraph());

            Path.Path path = finder.FindPath(_places[0]);
            Assert.AreEqual("A", path.Steps[0].StartPlace.Id);
            Assert.AreEqual("B", path.Steps[1].StartPlace.Id);
            Assert.AreEqual("C", path.Steps[2].StartPlace.Id);
            Assert.AreEqual("D", path.Steps[3].StartPlace.Id);
            Assert.AreEqual("A", path.Steps[3].EndPlace.Id);
        }
Пример #8
0
 public LivingObject()
     : base()
 {
     this.healthPoints = 20;
     this.maxHealthPoints = 20;
     this.aggroRange = 300;
     this.isDead = false;
     tasks = new List<LivingObjectTask>();
     aggroSystem = new Task.Aggro.AggroSystem<LivingObject>();
     MovementSpeed = 1f;
     currentTask = null;
     this.canBeEffected = true;
     this.interactions = new List<LivingObjectInteraction>();
     this.path = null;
 }
Пример #9
0
 public LivingObject()
     : base()
 {
     this.healthPoints    = 20;
     this.maxHealthPoints = 20;
     this.aggroRange      = 300;
     this.isDead          = false;
     tasks              = new List <LivingObjectTask>();
     aggroSystem        = new Task.Aggro.AggroSystem <LivingObject>();
     MovementSpeed      = 1f;
     currentTask        = null;
     this.canBeEffected = true;
     this.interactions  = new List <LivingObjectInteraction>();
     this.path          = null;
 }
Пример #10
0
        private async Task MarkEatTo(Path.Path path, bool ignoreValidateMovement)
        {
            if (CurrentChessPiece != null)
            {
                if (CurrentChessPiece.IsWhite() != path.StartCell.CurrentChessPiece?.IsWhite() &&
                    (ignoreValidateMovement || await Board.ValidateMovement(path.StartCell, this)))
                {
                    CanEatHere.Add(path);
                }
                return;
            }

            if (Movements[path.GetNextStep()] != null)
            {
                await Movements[path.GetStep()].MarkEatTo(path, ignoreValidateMovement);
            }
        }
Пример #11
0
        private async Task MarkMoveTo(Path.Path path, bool ignoreValidateMovement)
        {
            if (CurrentChessPiece != null)
            {
                return;
            }

            if (ignoreValidateMovement || await Board.ValidateMovement(path.StartCell, this))
            {
                CanMoveHere.Add(path);
            }

            if (Movements[path.GetNextStep()] != null)
            {
                await Movements[path.GetStep()].MarkMoveTo(path, ignoreValidateMovement);
            }
        }
Пример #12
0
        /// <summary>
        /// Resolve a path into zero or one reference.
        /// </summary>
        /// Resolution into a reference is done in the in-memory
        /// document structure, and does not call into the database.
        /// <exception cref="AmbiguousPathException"></exception>
        internal Reference ResolveOne(Path.Path path, Reference context)
        {
            List <Reference> resolved = path.Resolve(context, _resolver);

            switch (resolved.Count)
            {
            case 0:
                return(null);

            case 1:
                return(resolved[0]);

            default:
                throw new AmbiguousPathException(
                          $"Path resolves to {resolved.Count} objects",
                          path.ToString(), context.ToString(), path.LineNumber, path.LinePosition);
            }
        }
Пример #13
0
 public static void Save(Graph.Graph graph, Path.Path path)
 {
     using StreamWriter outputFile = new StreamWriter("../../../../../Result/result.txt");
     foreach (var pathPart in path.Steps)
     {
         if (graph.ChosenPlaces.Exists(item => item.Id.Equals(pathPart.StartPlace.Id)))
         {
             outputFile.Write($"{pathPart.StartPlace.Name}\n->");
         }
     }
     outputFile.WriteLine(path.EndPlace.Name);
     outputFile.Write("Czas:");
     if (!path.TotalLength.Days.Equals(0))
     {
         outputFile.Write($"{path.TotalLength.Days} dni ");
     }
     outputFile.WriteLine($" {path.TotalLength.Hours} godzin {path.TotalLength.Minutes} minut");
     outputFile.WriteLine($"Koszt: {path.Cost} zł");
 }
Пример #14
0
        private async Task CheckJumpEatTo(Path.Path path, bool ignoreValidateMovement)
        {
            if (path.GetNextStep() == Movement.Direction.Final)
            {
                if (CurrentChessPiece == null && (ignoreValidateMovement || await Board.ValidateMovement(path.StartCell, this)))
                {
                    CanMoveHere.Add(path);
                }
                else if (CurrentChessPiece?.IsWhite() != path.StartCell.CurrentChessPiece?.IsWhite() &&
                         (ignoreValidateMovement ||
                          await Board.ValidateMovement(path.StartCell, this)))
                {
                    CanEatHere.Add(path);
                }
                return;
            }

            if (Movements[path.GetStep()] != null)
            {
                await Movements[path.GetStep()].CheckJumpEatTo(path, ignoreValidateMovement);
            }
        }
Пример #15
0
        private Path.Path CreatePath(List <Place> places)
        {
            Path.Path?outPath = new Path.Path();

            List <Path.Path?> innerPath = new List <Path.Path>();

            for (int j = 0; j < places.Count - 1; j++)
            {
                string id = places[j].Id + "|" + places[j + 1].Id;
                innerPath.Add(_allPaths.AllPathsList[id]);
            }

            if (!innerPath.Contains(null))
            {
                foreach (var path in innerPath)
                {
                    outPath.Steps.AddRange(path.Steps);
                    outPath.ChosenSteps.Add(new Edge(path.StarPlace, path.EndPlace, path.TotalLength, path.Cost));
                }
            }
            return(outPath);
        }
Пример #16
0
 /// <summary>
 /// Resolve a path into zero or more references. The
 /// returned list is sorted by ordinal.
 /// </summary>
 /// Resolution into a reference is done in the in-memory
 /// document structure, and does not call into the database.
 internal List <Reference> ResolveMany(Path.Path path, Reference context)
 {
     return(path.Resolve(context, _resolver));
 }