Tiny Woodlands
As I get closer to locking down the final set of features for the 1.0 release of Calyx, Iβm starting to spend a bit more time thinking about how to document examples of what it can do.
One example that Iβm quite happy with is tiny_woodland. Itβs a generator that prints random emoji forest scenes, influenced by the constellation of brilliant little Twitter bots based on @tiny_star_field.
π² π±π±π» π³π±πΏ π²πΏ π²πΏ π²πΏ πΏπ±π± π²π²π³ π±π²πΏ π³πΏ π² πΌ πΏπ³πΏ πΏ π± π± π² π±π² π² πΏ πΏπ²π²π² π± πΏπ² π³π» π² πΏ π³ πΏπ²πΏπ± π³πΏ πΏ π± π³ π» π³π»πΏπΌπΏπΌπ±π± πΏ π²πΏπ±π»πΏπΏπ³πΏ π±πΏπ±π² π³π²
The code for generating the scenes is very simple and readable. It spreads out a couple of ranges and loops over them to automate the repetition of setting up the grid of rows and points. It then uses weighted choices to distribute a selection of trees, foliage and flowers, with whitespace being selected 50% of the time to balance things out.
require "calyx"
tiny_woodland = Calyx::Grammar.new do
start :field
field (0..7).map { "{row}{br}" }.join
row (0..18).map { "{point}" }.join
point [:trees, 0.2], [:foliage, 0.25], [:flowers, 0.05], [:space, 0.5]
trees "π²", "π³"
foliage "πΏ", "π±"
flowers "π·", "π»", "πΌ"
space " "
br "\n"
end
puts tiny_woodland.generate
Hopefully this method of building generators with a grammar is reasonably approachable for beginners and artists who arenβt full-time coders to understand.
This would be a great starting point for building a Twitter bot (or other bots, or fun little toys in general).
πΏ π» π²π»πΌ πΏ πΏ πΏπ² π±π²π±π³πΏ π³ π² πΏπ±π± π³ π²π·π² π³ π² π² π² π± π±πΏπ³ π³ π·π±π³π±π³ π± π²πΏ πΏ π±π³π²π±π³πΏπ³ π»π³π³ π± π³ πΏ π³ π»πΌπ² πΏπ²π²π± π± π²π±π± π²πΏπ± π²π² πΏπ³ πΏπ²π±π² π³ π³ π± π³π³
Update: This is now a Twitter bot, periodically posting these little emoji scenes at @tiny_woodland.