using SimpleCore.Compiler;
using SimpleCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using SimpleCore.Library;
using SimpleCore.Traffic;

namespace StandardScene
{
    public class Heuristic:HeuristicsContainer
    {
        //[HeuristicDef]
        //public bool NoPassShelf(SegmentPlan.SearchStat stat)
        //{
        //    if (stat.sequence.Length > 2 &&
        //        SimpleLib.GetSite(stat.sequence[stat.sequence.Length - 2]).fields.ContainsKey("Shelf"))
        //        return false;
        //    return true;
        //}

        [HeuristicDef]
        public bool ToDestConstraint(SegmentPlan.SearchStat stat)
        {
            if (plan.Source.fields.TryGetValue("constraint", out var field))
            {
                foreach (var constraint in field.Split('|'))
                {
                    var (dstStr, idStr, _) = constraint.Split(':');
                    if (plan.Destination.id.ToString() == dstStr && stat.CurrentSite.id.ToString() == idStr)
                        return false;
                }
            }

            return true;
        }
    }
}
