Example #1
0
        public PathFinder(List <Node> nodesPt1)
        {
            // Convert to pt2-nodes
            nodes = new List <NodePt2>(nodesPt1.Count);
            foreach (var n in nodesPt1)
            {
                nodes.Add(NodePt2.From(n));
            }

            // Mark "walls", i.e. nodes that are too large to move
            int minSize = nodes.Min(n => n.Size);

            foreach (var n in nodes.Where(n => n.Used > minSize).ToList())
            {
                n.IsLarge = true;
            }

            // Mark node with the data we want to access
            nodes.Find(n => n.Y == 0 && n.X == nodes.Max(n2 => n2.X)).IsGoalNode = true;
        }
Example #2
0
        public static NodePt2 From(Node n)
        {
            var n2 = new NodePt2()
            {
                Filesystem  = n.Filesystem,
                Size        = n.Size,
                Used        = n.Used,
                Avail       = n.Avail,
                UsedPercent = n.UsedPercent
            };

            // Parse grid position (x/y)
            var xStart   = n.Filesystem.IndexOf("-x") + 2;
            var lastDash = n.Filesystem.LastIndexOf('-');

            n2.X = int.Parse(n.Filesystem.Substring(xStart, lastDash - xStart));
            n2.Y = int.Parse(n.Filesystem.Substring(lastDash + 2));

            return(n2);
        }