Esempio n. 1
0
        bool backward_chain()
        {
            int act_cost = m_Candidates.Keys.Min();
            var cache    = m_Candidates[act_cost];
            var working  = new List <Actions.ActionChain>();
            int ub       = cache.Count;

            while (0 <= --ub)
            {
                var dest  = cache[ub];
                var setup = CanBackwardPlan(dest);
                if (null == setup)
                {
                    throw new ArgumentNullException(nameof(setup));             // invariant failure
                }
                foreach (var x in setup)
                {
                    var test = new Actions.ActionChain(x, dest);
                    if (!test.IsSemanticParadox())
                    {
                        working.Add(test);
                    }
                }
                cache.RemoveAt(ub);
                if (0 >= working.Count)
                {
                    continue;
                }
                foreach (var chain in working)
                {
                    splice(chain);
                }
                return(true);
            }
            return(false);
        }