Beispiel #1
0
 public static bool StateSeenBefore(EquivalentState newState)
 {
     // make arequivalent(state1,state2) which for each material finds the int pairs of floors where its chip and gen are.
     // Then order these pairs by floor1,floor2
     // equivalence means the pairs are identical (including dups) - the actual material is not important but its pattern still is:
     //So these are equivalent:
     //
     //hydrogen - chip hydrogen - generator
     //lithium - chip
     //lithium - generator
     //
     //and
     //
     //lithium - chip lithium - generator
     //hydrogen - chip
     //hydrogen - generator
     //
     //however  if middle row in lower example above was cobalt-chip instead of hydrogen-chip it wouldn't be equivalent
     // because the lower 2 floors chip and gen are different materials now, whereas they were the same before
     if (Previous == null)
     {
         Previous = new List <EquivalentState>();
         return(false);
     }
     return(Previous.Any(s => s.Equals(newState)));
 }
Beispiel #2
0
 public override void Calculate()
 {
     if (Previous.Any(x => x.Value == Bit.HIGH))
     {
         Value = Bit.HIGH;
     }
     else
     {
         Value = Bit.LOW;
     }
 }
Beispiel #3
0
        public override void Calculate()
        {
            // TODO Support multiplle Input + Output for sub-boards
            if (Previous.Any())
            {
                Inputs.ForEach(input => input.Value = Previous.First().Value);
            }

            foreach (var cycle in Cycle())
            {
                cycle.ForEach(x => x.Calculate());
            }

            // Define the actuall value of the board by most occuring Probe value
            Value = Probes.GroupBy(x => x.Value).OrderByDescending(grp => grp.Count()).Select(group => group.Key)
                    .First();
        }
Beispiel #4
0
 public bool HasPrevious(SymbolicConstant <T> value) => Previous.Any(node => node.Constant.Equals(value) || node.HasPrevious(value));