package main import ( "math/rand/v2" "strings" ) var ( // subagentAdjectives and subagentNouns are the words of the names of // the subagents. A name is an adjective and a noun, each capitalized, // joined, such as GreenOtter: 16,384 names. subagentAdjectives = strings.Fields(` red blue green yellow orange purple pink brown black white gray silver golden amber azure bronze copper jade lemon lime mint navy peach plum ruby violet cherry honey big small tiny huge giant little tall short long round flat thick thin deep soft hard smooth rough fuzzy fluffy shiny crunchy crispy leafy spiky hot cold warm cool icy frosty snowy rainy sunny cloudy windy stormy foggy misty sweet sour salty spicy juicy minty nutty creamy smoky tasty fresh bright dark quiet loud happy jolly merry calm brave bold clever wise kind gentle lucky proud quick swift fast slow eager busy sleepy silly funny shy neat noble grand royal mighty strong steady nimble lively cozy old new young ancient wooden stone paper iron magic cosmic lunar solar polar wild `) subagentNouns = strings.Fields(` ant bat bear bee beetle bird bison camel cat cheetah chicken clam cobra cougar cow crab crane crow deer dog dolphin donkey dove dragon duck eagle eel elk falcon finch fish flamingo fox frog gazelle gecko giraffe goat goose gorilla hamster hare hawk hedgehog heron hippo horse hyena iguana jaguar jay kangaroo kitten koala lamb lemur leopard lion lizard llama lobster moose moth mouse mule octopus orca otter owl ox oyster panda parrot pelican penguin pig pigeon pony puffin puma rabbit raccoon raven rhino robin salmon seal shark sheep shrimp skunk sloth snail snake sparrow spider squid squirrel swan tiger toad toucan trout tuna turkey turtle walrus wasp whale wolf wombat yak zebra apple banana bagel cookie mango melon muffin noodle pancake pepper potato pretzel radish taco waffle `) ) // subagentNameRandom returns a random name of a subagent. func subagentNameRandom() string { adjective := subagentAdjectives[rand.IntN(len(subagentAdjectives))] noun := subagentNouns[rand.IntN(len(subagentNouns))] return subagentWord(adjective) + subagentWord(noun) } // subagentNameValid tells if name is an adjective and a noun of the word lists, // each capitalized, joined. Only such a name can be a directory of a subagent. func subagentNameValid(name string) bool { for _, adjective := range subagentAdjectives { noun, found := strings.CutPrefix(name, subagentWord(adjective)) if !found { continue } for _, word := range subagentNouns { if subagentWord(word) == noun { return true } } } return false } // subagentWord returns word with its first letter in upper case. func subagentWord(word string) string { return strings.ToUpper(word[:1]) + word[1:] }