enough code to build the next bit of the animatic

This commit is contained in:
John Bintz 2021-07-28 07:55:28 -04:00
parent 3b72db01ee
commit 96d24f3777
1 changed files with 41 additions and 0 deletions

41
generate.rb Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env ruby
# basic: scramble 26 letters so that none are the same
LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@scrambled_letters = ""
def is_scrambled?
@scrambled_letters.split(//).each_with_index do |letter, index|
return false if letter == LETTERS[index]
end
true
end
done = false
while !done
@scrambled_letters = LETTERS.split(//).shuffle.join
done = is_scrambled?
end
@scrambled_letters.split(//).each_with_index do |letter, index|
puts "#{LETTERS[index]} - #{letter}"
end
# advanced: add symbols that mean common letters that also modify
# the prior letter
#
# order based on http://pi.math.cornell.edu/~mec/2003-2004/cryptography/subs/frequencies.html
COMMON_LETTERS = "ETAOINSRH"
SYMBOLS = "!@#$%&*+="
adjustments = COMMON_LETTERS.split(//).shuffle.each_with_index.each_with_object({}) do |(letter, index), obj|
obj[SYMBOLS[index]] = { letter: letter, prior_adjustment: rand(7)-3 }
end
pp adjustments