alpha
Login
or
Join now
ewancroft.uk
/
bluesky-awoo-bot
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
update with probability
author
Ewan Croft
date
2 years ago
(May 19, 2024, 10:44 PM +0100)
commit
511ae373
511ae373b9f21b5216a4c8264f1df6331a779ad5
parent
17cdcfe2
17cdcfe2b8bc3151d30744440330c4dd0dbcff97
+26
-2
1 changed file
Expand all
Collapse all
Unified
Split
wolf-noise-generator.ts
+26
-2
wolf-noise-generator.ts
Reviewed
···
23
23
24
24
export function generateWolfNoiseString(): string {
25
25
const wolfNoises = getWolfNoises(); // Read JSON data
26
26
-
const category = getRandomInt(0, Object.keys(wolfNoises).length - 1); // Pick a random category key
27
27
-
const randomWords = wolfNoises[Object.keys(wolfNoises)[category]]; // Get words for that category
26
26
+
const categoryProbabilities = {
27
27
+
howl: 0.4, // 40% chance
28
28
+
playful: 0.3, // 30% chance
29
29
+
scared: 0.3 // 30% chance
30
30
+
};
31
31
+
32
32
+
const random = Math.random();
33
33
+
let category;
34
34
+
35
35
+
// Determine the category based on probabilities
36
36
+
if (random < categoryProbabilities.howl) {
37
37
+
category = "howl";
38
38
+
} else if (random < categoryProbabilities.howl + categoryProbabilities.playful) {
39
39
+
category = "playful";
40
40
+
} else {
41
41
+
category = "scared";
42
42
+
}
43
43
+
44
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
67
+
}
68
68
+
69
69
+
// Optionally add punctuation based on the selected category
70
70
+
if (wolfNoises.punctuation && wolfNoises.punctuation[category] && wolfNoises.punctuation[category].length > 0) {
71
71
+
const punctuationLength = wolfNoises.punctuation[category].length;
72
72
+
const randomPunctuation = wolfNoises.punctuation[category][getRandomInt(0, punctuationLength - 1)];
73
73
+
result += randomPunctuation;
50
74
}
51
75
52
76
return result.trim(); // Remove any leading/trailing whitespace