Esempio n. 1
0
        public void SolveNext()
        {
            foreach (Bridge bridge in SubBridges.Where(b => !b.IsAllComplete()))
            {
                bridge.SolveNext();
            }
            Link[] avail;
            var    used = Used;

            if (!used.Any())
            {
                avail = _available.Where(a => a.HasFreeSide(0)).ToArray();
            }
            else
            {
                avail = _available.Where(a => a.HasFreeSide(used.Last().FirstFreeSide().Value)).ToArray();
            }

            if (avail.Length == 0)
            {
                IsComplete = true;
                return;
            }

            for (int i = 1; i < avail.Length; i++)
            {
                Bridge sub = new Bridge(_available, Used, new List <Bridge>(), IsComplete);
                sub.UsePart(avail[i]);
                SubBridges.Add(sub);
            }

            UsePart(avail[0]);
        }
Esempio n. 2
0
        public Bridge GetLongest()
        {
            var others = SubBridges.Select(b => b.GetLongest());

            Bridge[] vals = others.Append(this).ToArray();
            return(vals.OrderByDescending(b => b.Used.Count).ThenByDescending(b => b.MyScore).First());
        }