Generating random words
Posted: Mon Aug 01, 2005 8:22 am
This sure is an ugly pug. It makes random "words" out of bargonaut's letters file (watch the filename in the include!) I used this to make a "word tree"
It can be used as an include file. After each word is displayed, the rule WORD_HOOK is called; you can use this in your own files to continue drawing at a point {x 1.1} after the end of the last letter.
The "words" remind me of something out of an IKEA catalogue.
It can be used as an include file. After each word is displayed, the rule WORD_HOOK is called; you can use this in your own files to continue drawing at a point {x 1.1} after the end of the last letter.
The "words" remind me of something out of an IKEA catalogue.
Code: Select all
startshape RAND_INIT
include bargonaut_font.cfdg
### scene set-up ###
rule RAND_INIT {
WORD{}
RAND_WORD_INIT_R {y -2}
RAND_INIT_R {x 16}
}
rule RAND_INIT_R 2 {
WORD{}
RAND_WORD_INIT_R {y -2}
RAND_INIT_R {x 16}
}
rule RAND_INIT_R {}
rule RAND_WORD_INIT_R 8 {
WORD{}
RAND_WORD_INIT_R {y -2}
}
rule RAND_WORD_INIT_R 8 {
WORD{}
RAND_WORD_INIT_R {y -2}
}
rule RAND_WORD_INIT_R 3 {
}
### Actual word grammar ###
rule WORD {
RAND_TRIPLE{}
WORD_R {x 3.3}
}
rule WORD {
RAND_QUAD{}
WORD_R {x 4.4}
}
rule WORD {
RAND_QUINT{}
WORD_R {x 5.5}
}
rule WORD {
RAND_SEXTUPLE{}
// don't recurse
RAND_SUFFIX {x 6.6}
}
#rule WORD_R {
# SQUARE{s 1 0.25}
# WORD_R {x 1.1}
#}
rule WORD_R {
RAND_TRIPLE{}
RAND_SUFFIX{x 3.3}
}
rule WORD_R {
RAND_QUAD{}
RAND_SUFFIX {x 4.4}
}
rule WORD_R {
RAND_QUINT{}
RAND_SUFFIX {x 5.5}
}
rule WORD_R 2 {
RAND_SUFFIX {}
}
rule RAND_TRIPLE {
START_CONSONANT{}
RAND_VOWEL{x 1.1} RAND_ACCENT{x 1.1}
END_CONSONANT{x 2.2}
}
rule RAND_QUAD {
START_CONSONANT{}
RAND_DOUBLE_VOWEL{x 1.1}
END_CONSONANT{x 3.3}
}
rule RAND_QUAD {
RAND_DIPTHONG{}
RAND_VOWEL{x 2.2}
END_CONSONANT{x 3.3}
}
rule RAND_QUAD {
START_CONSONANT{}
RAND_VOWEL{x 1.1}
RAND_DOUBLE_CONSONANT{x 2.2}
}
rule RAND_QUINT {
RAND_DIPTHONG{}
RAND_DOUBLE_VOWEL{x 2.2}
END_CONSONANT{x 4.4}
}
rule RAND_QUINT {
RAND_DIPTHONG{}
RAND_VOWEL{x 2.2}
RAND_DOUBLE_CONSONANT{x 3.3}
}
rule RAND_SEXTUPLE {
RAND_DIPTHONG{}
RAND_DOUBLE_VOWEL{x 2.2}
RAND_DOUBLE_CONSONANT{x 4.4}
}
rule RAND_SEXTUPLE {
START_CONSONANT{}
RAND_VOWEL{x 1.1}
RAND_DOUBLE_CONSONANT{x 2.2}
RAND_VOWEL{x 4.4}
END_CONSONANT{x 5.5}
}
rule RAND_ACCENT 0.2 {
SQUARE { s 0.25 y 0.8 x -0.25}
SQUARE { s 0.25 y 0.8 x 0.25}
}
rule RAND_ACCENT {}
### Ugly data blocks ###
rule RAND_BLOCK { A_BLOCK{}}
rule RAND_BLOCK { B_BLOCK{}}
rule RAND_BLOCK { C_BLOCK{}}
rule RAND_BLOCK { D_BLOCK{}}
rule RAND_BLOCK { E_BLOCK{}}
rule RAND_BLOCK { F_BLOCK{}}
rule RAND_BLOCK { G_BLOCK{}}
rule RAND_BLOCK { H_BLOCK{}}
rule RAND_BLOCK { I_BLOCK{}}
rule RAND_BLOCK { J_BLOCK{}}
rule RAND_BLOCK { K_BLOCK{}}
rule RAND_BLOCK { L_BLOCK{}}
rule RAND_BLOCK { M_BLOCK{}}
rule RAND_BLOCK { N_BLOCK{}}
rule RAND_BLOCK { O_BLOCK{}}
rule RAND_BLOCK { P_BLOCK{}}
rule RAND_BLOCK { Q_BLOCK{}}
rule RAND_BLOCK { R_BLOCK{}}
rule RAND_BLOCK { S_BLOCK{}}
rule RAND_BLOCK { T_BLOCK{}}
rule RAND_BLOCK { U_BLOCK{}}
rule RAND_BLOCK { V_BLOCK{}}
rule RAND_BLOCK { W_BLOCK{}}
rule RAND_BLOCK { X_BLOCK{}}
rule RAND_BLOCK { Y_BLOCK{}}
rule RAND_BLOCK { Z_BLOCK{}}
rule RAND_CONSONANT{ B_BLOCK{}}
rule RAND_CONSONANT{ C_BLOCK{}}
rule RAND_CONSONANT{ D_BLOCK{}}
rule RAND_CONSONANT{ F_BLOCK{}}
rule RAND_CONSONANT{ G_BLOCK{}}
rule RAND_CONSONANT{ H_BLOCK{}}
rule RAND_CONSONANT{ J_BLOCK{}}
rule RAND_CONSONANT{ K_BLOCK{}}
rule RAND_CONSONANT{ L_BLOCK{}}
rule RAND_CONSONANT{ M_BLOCK{}}
rule RAND_CONSONANT{ N_BLOCK{}}
rule RAND_CONSONANT{ P_BLOCK{}}
# rule RAND_CONSONANT{ Q_BLOCK{}}
rule RAND_CONSONANT{ R_BLOCK{}}
rule RAND_CONSONANT{ S_BLOCK{}}
rule RAND_CONSONANT{ T_BLOCK{}}
rule RAND_CONSONANT{ V_BLOCK{}}
rule RAND_CONSONANT{ W_BLOCK{}}
rule RAND_CONSONANT{ X_BLOCK{}}
rule RAND_CONSONANT{ Z_BLOCK{}}
rule START_CONSONANT{ B_BLOCK{}}
rule START_CONSONANT{ C_BLOCK{}}
rule START_CONSONANT{ D_BLOCK{}}
rule START_CONSONANT{ F_BLOCK{}}
rule START_CONSONANT{ G_BLOCK{}}
rule START_CONSONANT{ H_BLOCK{}}
rule START_CONSONANT 0.2 { J_BLOCK{}}
rule START_CONSONANT{ K_BLOCK{}}
rule START_CONSONANT{ L_BLOCK{}}
rule START_CONSONANT{ M_BLOCK{}}
rule START_CONSONANT{ N_BLOCK{}}
rule START_CONSONANT{ P_BLOCK{}}
rule START_CONSONANT{ R_BLOCK{}}
rule START_CONSONANT{ S_BLOCK{}}
rule START_CONSONANT{ T_BLOCK{}}
rule START_CONSONANT{ V_BLOCK{}}
rule START_CONSONANT{ W_BLOCK{}}
rule START_CONSONANT 0.2 { Z_BLOCK{}}
rule END_CONSONANT{ B_BLOCK{}}
rule END_CONSONANT{ D_BLOCK{}}
rule END_CONSONANT{ G_BLOCK{}}
rule END_CONSONANT{ M_BLOCK{}}
rule END_CONSONANT{ N_BLOCK{}}
rule END_CONSONANT{ P_BLOCK{}}
rule END_CONSONANT{ R_BLOCK{}}
rule END_CONSONANT{ T_BLOCK{}}
rule END_CONSONANT{ W_BLOCK{}}
rule END_CONSONANT{ X_BLOCK{}}
rule RAND_VOWEL { A_BLOCK{}}
rule RAND_VOWEL { E_BLOCK{}}
rule RAND_VOWEL { I_BLOCK{}}
rule RAND_VOWEL { O_BLOCK{}}
rule RAND_VOWEL { U_BLOCK{}}
rule RAND_DOUBLE_VOWEL 0.5 { E_BLOCK{} E_BLOCK{x 1.1}}
rule RAND_DOUBLE_VOWEL 0.5 { E_BLOCK{flip 90} E_BLOCK{x 1.1}}
rule RAND_DOUBLE_VOWEL { E_BLOCK{} A_BLOCK{x 1.1}}
rule RAND_DOUBLE_VOWEL { I_BLOCK{} E_BLOCK{x 1.1}}
rule RAND_DOUBLE_VOWEL { O_BLOCK{} A_BLOCK{x 1.1}}
rule RAND_DOUBLE_VOWEL { O_BLOCK{} O_BLOCK{x 1.1}}
rule RAND_DOUBLE_VOWEL { O_BLOCK{} U_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { C_BLOCK{} H_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { C_BLOCK{} K_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { F_BLOCK{} F_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { L_BLOCK{} K_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { L_BLOCK{} L_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { L_BLOCK{} P_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { L_BLOCK{} T_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { N_BLOCK{} D_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { N_BLOCK{} G_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { N_BLOCK{} K_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { N_BLOCK{} T_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { P_BLOCK{} P_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { R_BLOCK{} D_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { R_BLOCK{} F_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { R_BLOCK{} N_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { R_BLOCK{} T_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { S_BLOCK{} H_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { S_BLOCK{} T_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { S_BLOCK{} S_BLOCK{x 1.1}}
rule RAND_DOUBLE_CONSONANT { Z_BLOCK{} Z_BLOCK{x 1.1}}
rule RAND_DIPTHONG{ B_BLOCK{} L_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ B_BLOCK{} R_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ C_BLOCK{} H_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ C_BLOCK{} L_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ C_BLOCK{} R_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ D_BLOCK{} R_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ F_BLOCK{} L_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ F_BLOCK{} R_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ G_BLOCK{} L_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ G_BLOCK{} R_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ P_BLOCK{} L_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ P_BLOCK{} R_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ S_BLOCK{} C_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ S_BLOCK{} H_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ S_BLOCK{} L_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ S_BLOCK{} M_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ S_BLOCK{} N_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ S_BLOCK{} P_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ S_BLOCK{} W_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ T_BLOCK{} H_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ T_BLOCK{} R_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ T_BLOCK{} W_BLOCK {x 1.1}}
rule RAND_DIPTHONG{ W_BLOCK{} H_BLOCK {x 1.1}}
rule RAND_SUFFIX 2 {RAND_VOWEL{} WORD_HOOK{x 2.2}}
rule RAND_SUFFIX{A_BLOCK{} N_BLOCK{x 1.1} WORD_HOOK{x 3.3}}
rule RAND_SUFFIX {I_BLOCK{} N_BLOCK{x 1.1} G_BLOCK{x 2.2} WORD_HOOK{x 4.4}}
rule RAND_SUFFIX {I_BLOCK{} S_BLOCK{x 1.1} H_BLOCK{x 2.2} WORD_HOOK{x 4.4}}
rule RAND_SUFFIX{E_BLOCK{} D_BLOCK{x 1.1} WORD_HOOK{x 3.3}}
rule RAND_SUFFIX{E_BLOCK{} N_BLOCK{x 1.1} WORD_HOOK{x 3.3}}
rule RAND_SUFFIX{E_BLOCK{} R_BLOCK{x 1.1} WORD_HOOK{x 3.3}}
rule RAND_SUFFIX{O_BLOCK{} N_BLOCK{x 1.1} WORD_HOOK{x 3.3}}
rule RAND_SUFFIX{U_BLOCK{} S_BLOCK{x 1.1} S_BLOCK{x 2.2} WORD_HOOK{x 4.4}}
rule RAND_SUFFIX 6 { WORD_HOOK{x 1.1}}
rule WORD_HOOK 0.0000001 {}