public override string generateState(bool[] pokeysValues) { int valueIndex = 0; for (int i = 0; i < Pins.Count(); i++) { valueIndex = valueIndex + ((pokeysValues[Pins[i]] ? 1 : 0) << i); } return(Values[valueIndex]); }
public SimulationResult(IReadOnlyList <SchemeState> states) { Pins = states[0] .InputPins .Concat(states[0].OutputPins) .Where(x => x.IsSignificant) .Select(x => ExtractPinValuesFromStateList(x, states)) .ToArray(); foreach (var pin in Pins.Where(x => x.IsOutputPin)) { Score += pin.ActualValues.Zip(pin.CorrectValues, (a, c) => a == c ? 1.0 : 0).Sum(); } Score /= states.Count; Score /= Pins.Count(x => x.IsOutputPin); }