This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

update with probability

+26 -2
+26 -2
wolf-noise-generator.ts
··· 23 23 24 24 export function generateWolfNoiseString(): string { 25 25 const wolfNoises = getWolfNoises(); // Read JSON data 26 - const category = getRandomInt(0, Object.keys(wolfNoises).length - 1); // Pick a random category key 27 - const randomWords = wolfNoises[Object.keys(wolfNoises)[category]]; // Get words for that category 26 + const categoryProbabilities = { 27 + howl: 0.4, // 40% chance 28 + playful: 0.3, // 30% chance 29 + scared: 0.3 // 30% chance 30 + }; 31 + 32 + const random = Math.random(); 33 + let category; 34 + 35 + // Determine the category based on probabilities 36 + if (random < categoryProbabilities.howl) { 37 + category = "howl"; 38 + } else if (random < categoryProbabilities.howl + categoryProbabilities.playful) { 39 + category = "playful"; 40 + } else { 41 + category = "scared"; 42 + } 43 + 44 + const randomWords = wolfNoises[category]; // Get words for the selected category 28 45 29 46 let result = ""; 30 47 let currentSentenceLength = 0; ··· 47 64 // Break the loop if adding the word would exceed the maximum length 48 65 break; 49 66 } 67 + } 68 + 69 + // Optionally add punctuation based on the selected category 70 + if (wolfNoises.punctuation && wolfNoises.punctuation[category] && wolfNoises.punctuation[category].length > 0) { 71 + const punctuationLength = wolfNoises.punctuation[category].length; 72 + const randomPunctuation = wolfNoises.punctuation[category][getRandomInt(0, punctuationLength - 1)]; 73 + result += randomPunctuation; 50 74 } 51 75 52 76 return result.trim(); // Remove any leading/trailing whitespace