示例#1
0
        public DieHard(int big, int small)
        {
            trace = new Trace("fact_trace");

            _jugs = new JugType(big, small);
            EmptyBigEmptySmallRange     emptyBigEmptySmallRange     = new EmptyBigEmptySmallRange();
            FullBigFullSmallRange       fullBigFullSmallRange       = new FullBigFullSmallRange();
            FullBigEmptySmallRange      fullBigEmptySmallRange      = new FullBigEmptySmallRange();
            EmptyBigFullSmallRange      emptyBigFullSmallRange      = new EmptyBigFullSmallRange();
            PartialBigEmptySmallRange   partialBigEmptySmallRange   = new PartialBigEmptySmallRange();
            PartialBigFullSmallRange    partialBigFullSmallRange    = new PartialBigFullSmallRange();
            FullBigPartialSmallRange    fullBigPartialSmallRange    = new FullBigPartialSmallRange();
            EmptyBigPartialSmallRange   emptyBigPartialSmallRange   = new EmptyBigPartialSmallRange();
            PartialBigPartialSmallRange partialBigPartialSmallRange = new PartialBigPartialSmallRange();

            _fillBig    = new FillBigAction(_jugs);
            _fillSmall  = new FillSmallAction(_jugs);
            _emptyBig   = new EmptyBigAction(_jugs);
            _emptySmall = new EmptySmallAction(_jugs);
            _big2Small  = new Big2SmallAction(_jugs);
            _small2Big  = new Small2BigAction(_jugs);

            _fillBig.SetTrace(trace);
            _fillSmall.SetTrace(trace);
            _emptyBig.SetTrace(trace);
            _emptySmall.SetTrace(trace);
            _big2Small.SetTrace(trace);
            _small2Big.SetTrace(trace);

            _fillBig.SetId("fillBig");
            _fillSmall.SetId("fillSmall");
            _emptyBig.SetId("emptyBig");
            _emptySmall.SetId("emptySmall");
            _big2Small.SetId("big2Small");
            _small2Big.SetId("small2Big");

            _emptyBigEmptySmall     = new State(_fillBig);
            _fullBigFullSmall       = new State(_emptyBig);
            _fullBigEmptySmall      = new State(_big2Small);
            _emptyBigFullSmall      = new State(_small2Big);
            _partialBigEmptySmall   = new State(_big2Small);
            _partialBigFullSmall    = new State(_emptySmall);
            _fullBigPartialSmall    = new State(_big2Small);
            _emptyBigPartialSmall   = new State(_small2Big);
            _partialBigPartialSmall = new State(_big2Small);

            _forbidden = new ForbiddenState();
            _desired   = new DesiredState();
            _forbidden.SetId("f1");
            _desired.SetId("d1");
            _emptyBigEmptySmall.SetTrace(trace).SetId("emptyBigEmptySmall");
            _emptyBigEmptySmall.Add(_fillSmall);
            _fullBigFullSmall.SetTrace(trace).SetId("fullBigFullSmall");
            _fullBigEmptySmall.SetTrace(trace).SetId("fullBigEmptySmall");
            _fullBigEmptySmall.Add(_fillSmall);
            _emptyBigFullSmall.SetTrace(trace).SetId("emptyBigFullSmall");
            _emptyBigFullSmall.Add(_emptySmall);
            _partialBigEmptySmall.SetTrace(trace).SetId("partialBigEmptySmall");
            _partialBigEmptySmall.Add(_emptyBig);
            _partialBigFullSmall.SetTrace(trace).SetId("partialBigFullSmall");
            _partialBigFullSmall.Add(_emptyBig);
            _fullBigPartialSmall.SetTrace(trace).SetId("fullBigPartialSmall");
            _emptyBigPartialSmall.SetTrace(trace).SetId("emptyBigPartialSmall");
            _emptyBigPartialSmall.Add(_fillBig);
            _partialBigPartialSmall.SetTrace(trace).SetId("partialBigPartialSmall");
            _forbidden.SetTrace(trace);
            _desired.SetTrace(trace);

            _jugs.AddRange(_emptyBigEmptySmall, emptyBigEmptySmallRange);
            _jugs.AddRange(_fullBigFullSmall, fullBigFullSmallRange);
            _jugs.AddRange(_fullBigEmptySmall, fullBigEmptySmallRange);
            _jugs.AddRange(_emptyBigFullSmall, emptyBigFullSmallRange);
            _jugs.AddRange(_partialBigEmptySmall, partialBigEmptySmallRange);
            _jugs.AddRange(_partialBigFullSmall, partialBigFullSmallRange);
            _jugs.AddRange(_fullBigPartialSmall, fullBigPartialSmallRange);
            _jugs.AddRange(_emptyBigPartialSmall, emptyBigPartialSmallRange);
            _jugs.AddRange(_partialBigPartialSmall, partialBigPartialSmallRange);
            DesiredRange desiredRange = new DesiredRange();

            _jugs.AddRange(_desired, desiredRange);

            _behavior = new JugBehavior(_jugs);
            _behavior.Add(_emptyBigEmptySmall);
            _behavior.Add(_fullBigFullSmall);
            _behavior.Add(_partialBigEmptySmall);
            _behavior.Add(_partialBigFullSmall);
            _behavior.Add(_fullBigPartialSmall);
            _behavior.Add(_emptyBigPartialSmall);
            _behavior.Add(_partialBigPartialSmall);
        }
示例#2
0
 public DieHard(JugBehavior behavior)
 {
     this.Add(behavior);
 }