-
Notifications
You must be signed in to change notification settings - Fork 1
/
fluffies.py
executable file
·161 lines (144 loc) · 6.35 KB
/
fluffies.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/python3
import argparse
import json
import random
import sys
def parse_args():
parser = argparse.ArgumentParser(description='A string-generator of anthropomorphic creatures-encounters.')
parser.add_argument('range', metavar='N', type=int,
help='Number of fluffies to generate.')
return parser.parse_args()
class TermColors:
'''
Helper class to generate terminal control sequences.
'''
@staticmethod
def rgb(hh):
'''HTML color to terminal escape sequence'''
assert(hh[0] == '#' and len(hh) == 7)
rr = int(hh[1:3], 16)
gg = int(hh[3:5], 16)
bb = int(hh[5:7], 16)
return f'\x1b[38;2;{rr};{gg};{bb}m'
reset = '\x1b[0m' # reset to terminal defaults
def colorize(color):
'''
Convert a tuple (color, string) to a terminal-colorized string.
'''
return T.rgb(color[0]) + color[1] + T.reset
args = parse_args()
T = TermColors()
f = open("lists.json")
lists = json.load(f)
states = lists["states"]
colors = lists["colors"]
creatures = lists["creatures"]
at_actions = lists["at_actions"]
to_actions = lists["to_actions"]
on_actions = lists["on_actions"]
with_actions = lists["with_actions"]
towards_actions = lists["towards_actions"]
plain_actions = lists["plain_actions"]
in_actions = lists["in_actions"]
after_actions = lists["after_actions"]
from_actions = lists["from_actions"]
about_actions = lists["about_actions"]
for_actions = lists["for_actions"]
of_actions = lists["of_actions"]
whisper_stuff = lists["whisper_stuff"]
throwing_stuff = lists["throwing_stuff"]
talking_stuff = lists["talking_stuff"]
sharing_stuff = lists["sharing_stuff"]
music_genres = lists["music_genres"]
tv_series = lists["tv_series"]
f.close()
actions_lists = [whisper_stuff, talking_stuff, throwing_stuff, sharing_stuff, to_actions, on_actions, with_actions, towards_actions,
at_actions, in_actions, after_actions, from_actions, about_actions, for_actions, of_actions, plain_actions]
actions_paths = ["whispering", "talking", "throwing", "sharing", "to_actions", "on_actions", "with_actions", "towards_actions",
"at_actions", "in_actions", "after_actions", "from_actions", "about_actions", "for_actions", "of_actions", "plain_actions"]
total_actions = 0
actions_weighted = []
for action in actions_lists:
total_actions += len(action)
for action in actions_lists:
actions_weighted.append(len(action)/total_actions)
for fluff in range(args.range):
states_choice0 = random.choice(states)
states_choice1 = random.choice(states)
colors_choice0 = colorize(random.choice(colors))
colors_choice1 = colorize(random.choice(colors))
creatures_choice0 = random.choice(creatures)
creatures_choice1 = random.choice(creatures)
action_path = random.choices(actions_paths,actions_weighted)[0]
if states_choice0[0] in ["a", "e", "i", "o", "u"]:
prefix0 = "An "
else:
prefix0 = "A "
if states_choice1[0] in ["a", "e", "i", "o", "u"]:
prefix1 = "an "
else:
prefix1 = "a "
fixed_path = prefix0 + states_choice0 + " " + colors_choice0 + " " + creatures_choice0 + " and " + \
prefix1 + states_choice1 + " " + colors_choice1 + " " + creatures_choice1 + " are "
if action_path == "whispering":
whisper_choice = random.choice(whisper_stuff)
print(fixed_path + "whispering " + whisper_choice + " to you!")
elif action_path == "talking":
talking_subject = random.choice(talking_stuff)
if talking_subject not in ["music", "tv_series", "elephant in the room"]:
print(fixed_path + "talking about " + talking_subject + " with you!")
elif talking_subject == "music":
genre = random.choice(music_genres)
print(fixed_path + "talking about " + genre + " music with you!")
elif talking_subject == "tv_series":
series = random.choice(tv_series)
print(fixed_path + "talking about " + series + " with you!")
elif talking_subject == "elephant in the room":
colors_choice2 = colorize(random.choice(colors))
print(fixed_path + "talking about the " + colors_choice2 + " elephant in the room with you!")
elif action_path == "throwing":
throwing_object = random.choice(throwing_stuff)
if throwing_object != "blobs":
print(fixed_path + "throwing " + throwing_object + " at you!")
else:
colors_choice2 = colorize(random.choice(colors))
print(fixed_path + "throwing " + colors_choice2 + " blobs at you!")
elif action_path == "sharing":
sharing_object = random.choice(sharing_stuff)
print(fixed_path + "sharing " + sharing_object + " with you!")
elif action_path == "to_actions":
to_action = random.choice(to_actions)
print(fixed_path + to_action + " to you!")
elif action_path == "on_actions":
on_action = random.choice(on_actions)
print(fixed_path + on_action + " on you!")
elif action_path == "with_actions":
with_action = random.choice(with_actions)
print(fixed_path + with_action + " with you!")
elif action_path == "towards_actions":
towards_action = random.choice(towards_actions)
print(fixed_path + towards_action + " towards you!")
elif action_path == "at_actions":
at_action = random.choice(at_actions)
print(fixed_path + at_action + " at you!")
elif action_path == "in_actions":
in_action = random.choice(in_actions)
print(fixed_path + in_action + " in you!")
elif action_path == "after_actions":
after_action = random.choice(after_actions)
print(fixed_path + after_action + " after you!")
elif action_path == "from_actions":
from_action = random.choice(from_actions)
print(fixed_path + from_action + " from you!")
elif action_path == "about_actions":
about_action = random.choice(about_actions)
print(fixed_path + about_action + " about you!")
elif action_path == "for_actions":
for_action = random.choice(for_actions)
print(fixed_path + for_action + " for you!")
elif action_path == "of_actions":
of_action = random.choice(of_actions)
print(fixed_path + of_action + " of you!")
elif action_path == "plain_actions":
plain_action = random.choice(plain_actions)
print(fixed_path + plain_action + " you!")