-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_meta.rb
317 lines (268 loc) · 7.8 KB
/
generate_meta.rb
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
CATEGORIES = {
'base' => [
'maxibiz',
'black',
'default',
'dark',
'light',
'albino',
'orange',
'zombie',
'orc',
'alien',
'pink',
],
## use for maxibiz/black/default
'hair_black' => [
'mohawk', 'mohawk2',
'wildhair',
'peakspike',
'bob', ## exclusive
],
'hair' => [
'mohawk', 'mohawk2',
'mohawk purple', 'mohawk2 purple',
'mohawk red', 'mohawk2 red',
'mohawk blonde', 'mohawk2 blonde',
'wildhair',
'wildhair blonde',
'wildhair red',
'wildhair purple',
'peakspike',
],
## use for pink (barbie)
'hair_blonde_f' => [
'mohawk blonde', 'mohawk2 blonde',
'peakspike blonde', ## exclusive
'bob blonde', ## exclusive
['bob blonde', 'cap small'], ## exclusive
['bob blonde', 'headband'], ## exclusive
],
'hat' => [
'tophat',
'knittedcap',
'beanie',
'capforward',
'headband',
'hoodie',
'cap mcb',
'cap',
'cowboyhat',
'wizardhat',
'jesterhat',
'bandana',
'bandana2',
'crown',
],
'hat_blonde_f' => [
'knittedcap',
'beanie',
'cap small',
'cowboyhat',
'jesterhat',
'bandana',
'hoodie',
'frenchcap', # exclusive
## no tophat, capforward, headband why? why not?
],
'lasereyes_black' => [
'lasereyes red', 'lasereyes2 red',
'lasereyes green','lasereyes2 green',
'lasereyes blue', 'lasereyes2 blue',
'lasereyes gold', 'lasereyes2 gold',
],
'lasereyes' => [
'lasereyes3 red',
'lasereyes3 green',
'lasereyes3 gold',
],
'lasereyes_blonde_f' => [
'lasereyes3 blue', # exclusive
],
'eyewear' => [
'eyemask',
'3dglasses',
'polarizedshades',
'classicshades',
'coolshades', ## exclusive (to non-blondes)
'eyepatch',
'vr',
['clowneyes','clownnose'],
],
'eyewear_blonde_f' => [
'eyemask',
'3dglasses',
'polarizedshades',
'classicshades',
'eyepatch',
'vr',
['clowneyes blue', 'clownnose'], ## exclusive
'bigshades', ## exclusive
],
'beard_black' => [
'luxuriousbeard',
'beard',
'chinstrap',
],
'beard' => [
'luxuriousbeard',
'luxuriousbeard light',
'beard',
'beard light',
'chinstrap',
'chinstrap light',
'goat',
],
'ear_neck' => [
'earring',
'goldchain',
],
'mouth_prop' => [
'pipe',
'bubblegum',
],
}
pp CATEGORIES
def random_attributes( base )
attributes = []
style = if ['maxibiz', 'black', 'default'].include?( base ) ## maxibiz/black/default
:black
elsif ['pink'].include?( base ) ## pink (barbie)
:blonde
elsif ['alien'].include?( base ) ## alien
:alien
else ## "standard" humans incl. orc
:default
end
hair_attributes = case style
when :black then CATEGORIES['hair_black']
when :blonde then CATEGORIES['hair_blonde_f']
else CATEGORIES['hair'] ## alien # def
end
hat_attributes = case style
when :blonde then CATEGORIES['hat_blonde_f']
else CATEGORIES['hat']
end
eyewear_attributes = case style
when :black then CATEGORIES['eyewear']+CATEGORIES['lasereyes_black']
when :blonde then CATEGORIES['eyewear_blonde_f']+CATEGORIES['lasereyes_blonde_f']
else CATEGORIES['eyewear']+CATEGORIES['lasereyes']
end
beard_attributes = case style
when :blonde,
:alien then nil
when :black then CATEGORIES['beard_black']
else CATEGORIES['beard']
end
ear_neck_attributes = case style
when :alien then nil
else CATEGORIES['ear_neck']
end
mouth_prop_attributes = case style
when :blonde then nil
else CATEGORIES['mouth_prop']
end
if beard_attributes
beard = rand( 10 )
## 30% w/ beard
if [0,1,2].include?( beard )
attributes << beard_attributes[ rand( beard_attributes.size ) ]
else
## none; continue
end
end
## 0,1,2 - hair (30%)
## 3,4,5,6,7,8 - hat (60%)
## 9 -none (10%)
hair_dist, hat_dist = case style
when :blonde then [[3,4,5,6,7,8],[0,1,2]] ## more hair
else [[3,4,5,6,7,8],[0,1,2]] # more hats
end
hair_or_hat = rand( 10 )
if hair_dist.include?( hair_or_hat )
attributes << hair_attributes[ rand( hair_attributes.size ) ]
elsif hat_dist.include?( hair_or_hat )
attributes << hat_attributes[ rand( hat_attributes.size ) ]
else
## none; continue
end
if ear_neck_attributes
ear_neck = rand( 10 )
ear_neck_dist = style == :blonde ? [0,1,2,3,4 ] : [0,1]
if ear_neck_dist.include?( ear_neck )
attributes << ear_neck_attributes[ rand( ear_neck_attributes.size ) ]
else
## none; continue
end
end
if mouth_prop_attributes
mouth_prop = rand( 100 )
mouth_prop_dist = [0] # 1%
if mouth_prop_dist.include?( mouth_prop )
attributes << mouth_prop_attributes[ rand( mouth_prop_attributes.size ) ]
else
## none; continue
end
end
## 70% if hair or hat
## 90% if no hair or hat
eyewear = rand( 10 )
eyewear_dist = hair_or_hat == 9 ? [0,1,2,3,4,5,6,7,8] : [0,1,2,3,4,5,6]
if eyewear_dist.include?( eyewear )
attributes << eyewear_attributes[ rand( eyewear_attributes.size ) ]
else
## none; continue
end
## note: might included nested attributes (combos) - flatten
attributes.flatten
end
def generate_meta( max=1000, seed: 4242 )
srand( seed ) ## make deterministic
recs = []
backgrounds = [
'bitcoin orange',
'bitcoin pattern',
'red',
'green',
'dollar pattern',
'blue',
'euro pattern',
'aqua',
'classic',
'rainbow',
'ukraine',
'usa',
]
bases = CATEGORIES['base']
max.times do |id|
base = bases[ id % bases.size ]
accessories = random_attributes( base )
background = if base.index( 'default' )
'default'
else
backgrounds[id % backgrounds.size ]
end
attributes = [background, base] + accessories
print "==> #{id}: "
pp attributes
rec = []
rec << id.to_s ## add id - starting at one
rec << base
rec << accessories.join(' / ')
rec << background
recs << rec
end
recs
end
recs = generate_meta( 5000 )
## pp recs
headers = ['id', 'type', 'accessories', 'background']
File.open( "./tmp/welovepunks.csv", "w:utf-8" ) do |f|
f.write( headers.join( ', '))
f.write( "\n")
recs.each do |values|
f.write( values.join( ', ' ))
f.write( "\n" )
end
end
puts "bye"