public PlayableEnv2DR Build_2DR(PlayableScheme scheme) { var env = new PlayableEnv2DR(); env.MinimalPlayablePLM = scheme.minimalPlayablePLM; env.Foreground = new Container2D_Rectangular(scheme.canvasConfig as CanvasConfig2DR, scheme.slotConfig); env.Background = new Container2D_Rectangular(scheme.canvasConfig as CanvasConfig2DR, scheme.slotConfig); env.MatchRules = scheme.matchRules.SchemeStyleMap <RuleMatchBasic, RuleMatchBasic2D_Rectangular>((r) => { var raw = r as RuleMatchBasic2D_Rectangular; var ret = new RuleMatchBasic2D_Rectangular(); ret.maskWidth = raw.maskWidth; ret.maskHeight = raw.maskHeight; ret.mask = raw.mask; ret.Compile(); return(ret); }).ToArray(); env.ExtensionRules = scheme.extensionRules.SchemeStyleMap <RuleMatchExtension, RuleMatchExtension2D_Rectangular>((r) => { return(r as RuleMatchExtension2D_Rectangular); }).ToArray(); env.RefillRule = scheme.refillRule as RuleRefill2D_Rectangular; env.OperationRules = scheme.operationRules.SchemeStyleMap <RuleOperation, RuleOperation2D_Rectangular>((r) => { return(r as RuleOperation2D_Rectangular); }).ToArray(); env.ScoreRules = scheme.scoreRules.SchemeStyleMap <RuleScore, RuleScore2D_Rectangular>((r) => { return(r as RuleScore2D_Rectangular); }).ToArray(); return(env); }
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(); }
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(); }