My first proper Leonardo sketch: Chatbot Revenge (Gibberish Language Generator)

Or, as I like to call it, "Never move mother night" - four words that randomly popped into my head one day as if they all meant something, that seemed to fit perfect with this gibberish engine I made.

First, I imported the word list from passphra.se, and found a way to pack it into the PROGMEM area without overrunning RAM. I decided on a null-spaced long string - basically an unindexed, unreferenced long block of strings back-to-back, with all the words with "\0" between them. Then, I would use strlen_P to "walk" through random positions to select random words (CPU time is not precious in this application, so wasting CPU to save space is OK).

Then, I'd "functionize" that word-selection mechanism, and work on the "sentence generator". It picks a random number of words to "pull", capitalizes the first letter, and ends with a period.

Total time, about 1 hour of coding. Hardest part was trying to remember how to perform arithmetic on pointers - turns out I had the "+1" in the wrong place, and it was "strlen"'ing a null value (always pulling the same word). That was a pain. After that, the rest flew, and adding the kill-switch revealed a lot of bugs in the Leonardo bootloader that I learned to work around but hope will be fixed some day :slight_smile:

Here's the video:

And here's how it's done:
(converted to attachment - see download below)
edit: updated to latest version below

RandomWordGenerator.ino (15.8 KB)

RandomWordGenerator.ino (17.2 KB)

I had a compile problem with "Keyboard"
Are there file imports you have not shown here?

No imports, but it's entirely likely you haven't upgraded to Arduino v1.0.1 which was just released Tuesday specifically for the Leonardo release. 1.0 doesn't support it at all.

Also, if you build this as it's posted now, it'll probably crash due to the word-count hard-code (it loops through a hardcoded number of iteration limits, and would run off into binary program space). I've attached the full proper ".ino" file to the original post so you can get the whole program - guess I should've done that to start :wink:

edit: If I'm feeling especially creative, I might add a few extra features the next time a spambot bugs me. I plan on adding random punctuation (like "Missile night! Chicken shorts, inside belt."), including proper capitalization... and also adding short common structural words like "or", ""and", "if", "not", etc., in a separate list and injected more frequently than the "base" words. Just for the lulz. :smiley:

I lied. I hate talking about potential improvements where I lay out the whole plan on the spot. I just end up doing them right away.

Here's a sample of the improved code:

Imagine least my older below individual, slowly branch grain date.
Else industry lie.
Scene television measure property garden active danger hall, operation! Physical belong baseball in itself my solve leaving left. Fought lady? Copper chamber time child powder farm, push.
Cheese cost stood my!
Finish rocket.
Regular military lead wave, certainly arrive brown rabbit! Forth nearby. Powder, worth off again. Mathematics friend pie your does, drawn stove, describe.
Open, trip according. Shut and people parallel length order the scientist couple, strike. Above fine regular silent, tide, hollow year many leader. Society announced pay arrow, dried immediately? Shade, jack, caught! Canal rocky apart instant? These rose at period exclaimed high guide popular cost different!
Local compare, molecular her pie cast.
Store my off strike once of printed elephant visit? Police finish grown your. Chicken tiny in market! Rain view wheel cost space bear possibly.
Especially building nearer whose addition this my increase, heat your write. Club garden scene author my spend lunch situation busy. Children author, scientist shape race. Chief everything did climb am personal alive her would met? Exchange five capital bean of pot in chart.
Won field is to together quietly magic your duck.
Halfway, think dark account my quick meant trade at night environment! Mirror storm at sudden simple. Rhyme yellow. Ear local experience. Clean its fierce tape use truth is indicate. During pleasant bottle fought fought gulf!
Bend blew. While buried new, wheel bear without shape again handsome! Airplane your highway surprise. Value dangerous soldier!
Picture forget center a pitch my maybe bean crack.
Mood alive agree! Straight happily after recognize, object lamp fast, nobody are his? Distance position unusual halfway near, night group? Method become period against grandfather suggest slave, shinning!
Eleven load shelter, fairly minerals running selection.
Frame animal met pass seems event!
Please cell. Education pupil they. Accurate universe bill become! Position, day cloud harder color school third! Such wore seen, hold. Typical at moon ground field terrible tropical tank the growth.
Cat of particularly.
Except extra bank shoe. Already prevent face am solid, clothing soap society.
Farmer garden carbon leg crowd compare and jar gate.
Your shade college pack a steam treated tobacco!

Attached is "v1.1" with "small words" and random punctuation. :slight_smile:

RandomWordGenerator.ino (17.2 KB)

haha, that's really funny! now just make it randomly generate a phrase as your signature to every forum post/email. That'll confuse 'em good. :wink:

Especially building nearer whose addition this my increase, heat your write. Club garden scene author my spend lunch situation busy. Children author, scientist shape race. Chief everything did climb am personal alive her would met? Exchange five capital bean of pot in chart.

This looks exactly like a lot of the spam I get. Except for the URL at the end. :wink: