* Generates a random slope setting value. * @protected * @param {Random} random Random instance * @param {Setting} setting Setting instance * @return {string} Random slope setting value
(random, setting)
| 202 | * @return {string} Random slope setting value |
| 203 | */ |
| 204 | randomizeSlopeValue (random, setting) { |
| 205 | const alphabetSetting = this.getSetting('alphabet') |
| 206 | if (alphabetSetting.isValid()) { |
| 207 | const alphabet = alphabetSetting.getValue() |
| 208 | const m = alphabet.getLength() |
| 209 | |
| 210 | // Create range based on alphabet and filter coprime values |
| 211 | // Don't use caesar cipher slope (a=1) if possible |
| 212 | const range = alphabet.getCodePoints().map((_, i) => i + 1) |
| 213 | const coprimes = range.filter(a => a > 1 && MathUtil.isCoprime(a, m)) |
| 214 | return coprimes.length > 0 ? random.nextChoice(coprimes) : 1 |
| 215 | } |
| 216 | return null |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Generates a random intercept setting value. |
nothing calls this directly
no test coverage detected