Exemplo n.º 1
0
    public void InitPlayableContainer()
    {
        foreground.InitBlocks();
        background.FlushAsFirmware();

        foreground.RecreateSubjects(true);

        MakeContainerStable(foreground);

        plmRecords = MakeContainerPlayable(foreground);
    }
Exemplo n.º 2
0
    private List <PLMRecord2D_Retangular> MakeContainerPlayable(Container2D_Rectangular container)
    {
        var records = SeekContainerPLM(container);

        if (records.Count >= minimalPlayablePLM)
        {
            return(records);
        }
        else
        {
            container.RecreateSubjects(true);
            MakeContainerStable(container);
            return(MakeContainerPlayable(container));
        }
    }
Exemplo n.º 3
0
    private static bool DryRun(PlayableScheme scheme, out string reason)
    {
        reason = "";
        if (scheme.canvasConfig is CanvasConfig2DR)
        {
            var container = new Container2D_Rectangular(scheme.canvasConfig as CanvasConfig2DR,
                                                        scheme.slotConfig);
            container.InitBlocks();

            var count1 = 0;
            var count2 = 0;
            for (int i = 0; i < 20; i++)
            {
                container.RecreateSubjects(true);
                var ctx1 = new LMSeeker2D_Retangular.SeekContext();
                ctx1.container  = container;
                ctx1.matchRules = scheme.matchRules.SchemeStyleMap <RuleMatchBasic, RuleMatchBasic2D_Rectangular>((r) => {
                    var raw        = r as RuleMatchBasic2D_Rectangular;
                    var ret        = new RuleMatchBasic2D_Rectangular();
                    ret.mask       = raw.mask;
                    ret.maskWidth  = raw.maskWidth;
                    ret.maskHeight = raw.maskHeight;
                    ret.Compile();
                    return(ret);
                }).ToArray();
                ctx1.result = new List <LMRecord2D_Retangular>();
                LMSeeker2D_Retangular.Seek(ctx1);
                if (ctx1.result.Count > 0)
                {
                    count1++;
                }

                var ctx2 = new PLMSeeker2D_Retangular.SeekContext();
                ctx2.container  = container;
                ctx2.matchRules = scheme.matchRules.SchemeStyleMap <RuleMatchBasic, RuleMatchBasic2D_Rectangular>((r) => {
                    var raw        = r as RuleMatchBasic2D_Rectangular;
                    var ret        = new RuleMatchBasic2D_Rectangular();
                    ret.mask       = raw.mask;
                    ret.maskWidth  = raw.maskWidth;
                    ret.maskHeight = raw.maskHeight;
                    ret.Compile();
                    return(ret);
                }).ToArray();
                ctx2.operationRules = scheme.operationRules.SchemeStyleMap <RuleOperation, RuleOperation2D_Rectangular>((r) => {
                    return(r as RuleOperation2D_Rectangular);
                }).ToArray();
                ctx2.result = new List <PLMRecord2D_Retangular>();
                PLMSeeker2D_Retangular.Seek(ctx2);
                if (ctx2.result.Count >= scheme.minimalPlayablePLM)
                {
                    count2++;
                }
            }

            if (count1 < 2 || count2 < 2)
            {
                reason = "Scheme is NOT playable!";
                return(false);
            }

            return(true);
        }
        throw new NotImplementedException();
    }
Exemplo n.º 4
0
	private static bool DryRun(PlayableScheme scheme, out string reason)
	{
		reason = "";
		if (scheme.canvasConfig is CanvasConfig2DR)
		{
			var container = new Container2D_Rectangular(scheme.canvasConfig as CanvasConfig2DR,
			                                            scheme.slotConfig);
			container.InitBlocks();

			var count1 = 0;
			var count2 = 0;
			for (int i = 0; i < 20; i++)
			{
				container.RecreateSubjects(true);
				var ctx1 = new LMSeeker2D_Retangular.SeekContext();
				ctx1.container = container;
				ctx1.matchRules = scheme.matchRules.SchemeStyleMap<RuleMatchBasic, RuleMatchBasic2D_Rectangular>((r)=>{
					var raw = r as RuleMatchBasic2D_Rectangular;
					var ret = new RuleMatchBasic2D_Rectangular();
					ret.mask = raw.mask;
					ret.maskWidth = raw.maskWidth;
					ret.maskHeight = raw.maskHeight;
					ret.Compile();
					return ret;
				}).ToArray();
				ctx1.result = new List<LMRecord2D_Retangular>();
				LMSeeker2D_Retangular.Seek(ctx1);
				if (ctx1.result.Count > 0)
				{
					count1++;
				}

				var ctx2 = new PLMSeeker2D_Retangular.SeekContext();
				ctx2.container = container;
				ctx2.matchRules = scheme.matchRules.SchemeStyleMap<RuleMatchBasic, RuleMatchBasic2D_Rectangular>((r)=>{
					var raw = r as RuleMatchBasic2D_Rectangular;
					var ret = new RuleMatchBasic2D_Rectangular();
					ret.mask = raw.mask;
					ret.maskWidth = raw.maskWidth;
					ret.maskHeight = raw.maskHeight;
					ret.Compile();
					return ret;
				}).ToArray();
				ctx2.operationRules = scheme.operationRules.SchemeStyleMap<RuleOperation, RuleOperation2D_Rectangular>((r)=>{
					return r as RuleOperation2D_Rectangular;
				}).ToArray();
				ctx2.result = new List<PLMRecord2D_Retangular>();
				PLMSeeker2D_Retangular.Seek(ctx2);
				if (ctx2.result.Count >= scheme.minimalPlayablePLM)
				{
					count2++;
				}
			}

			if (count1 < 2 || count2 < 2)
			{
				reason = "Scheme is NOT playable!";
				return false;
			}

			return true;
		}
		throw new NotImplementedException();
	}