public void DoBan(int index, int pattern) { var frequencySet = weightSetCollection.Get(index); if (entropyValues[index].Decrement(frequencySet.priorityIndices[pattern], frequencySet.frequencies[pattern], frequencySet.plogp[pattern])) { PriorityReset(index); } }
public int GetRandomPossiblePatternAt(int index, Func <double> randomDouble) { var fs = weightSetCollection.Get(index); // Run through the groups with descending prioirty for (var g = 0; g < fs.groups.Length; g++) { var patterns = fs.groups[g].patterns; var frequencies = fs.groups[g].frequencies; // Scan the group var s = 0.0; for (var i = 0; i < patterns.Length; i++) { if (wave.Get(index, patterns[i])) { s += frequencies[i]; } } if (s <= 0.0) { continue; } // There's at least one choice at this priority level, // pick one at random. var r = randomDouble() * s; for (var i = 0; i < patterns.Length; i++) { if (wave.Get(index, patterns[i])) { r -= frequencies[i]; } if (r <= 0) { return(patterns[i]); } } return(patterns[patterns.Length - 1]); } return(-1); }