- Reset Game
- Book
- BASIC
-
Poetry
Original Resources
Download the original BASIC code. Check out the original page the text below was taken from in the Book.
Instructions From the Book
"This program produces random verse which might loosely be considered in the Japanes Haiku style. It uses 20 phrases in four groups of five phrases each and generally cycles through the groups in order. It inserts commas (random -- 19% of the time), indentation (random -- 22% of the time), and starts new paragraphs (18% probability, but at least once every 20 phrase).
The phrases in POETRY are somewhat suggestive of Edgar Allen Po. Try it with phrases from computer technology, from love and romance, from four year-old children, or from some other subject. Send us the output.
Here are some phrases from nature to try:
- Carpet of ferns
- Morning dew
- Tang of dawn
- Swaying pines
- Entrances me
- Soothing me
- Rustling leaves
- Radiates calm
- Mighty Oaks
- Grace and beauty
- Slently singing
- Nature speaking
- Untouched, unspoiled
- Shades of green
- Tranquility
- . . . so peaceful
The original author of this program is unknown. It was modified and reworked by Jim Bailey, Peggy Ewing, and Dave Ahl at DEC."
Modifications For This Version
As stated in the original, it creates Haiku-esque poetry. This version, however, creates proper Haiku poetry with the proper 5-7-5 rhythm. Additionally, the original version just runs infinitely scrolling poem after poem after poem until you terminate the program. In my version, I've added a button to allow the users to generate a new one at their whim.
Technical Stuff
With modern advances in web programming and the fact that everything is database driven these days, this program ressembles its original B.A.S.I.C counterpart the least. As a class project for my PHP students, we built this together.
First, we found a text file that had the entire English dictionary along with the syllable count. It took me hours to find it. Luckily I downloaded it, because I cannot find the source online where I got it from.
Using that, we wrote a PHP script to parse it, figure out the syllable count, and word length and inserted everything into a database. If you're interested, here's a SQL code as a .txt file that you can use to import the entire database into your own system.
Once we got the database created and filled up, we wrote a simple PHP script that will randomly generate a 5-7-5 style poem. PHP is an excellent solution for this particular program because it only hits the server one time when generating a new poem. Therefore, this one will stay PHP, and will not be re-written in JavaScript (like some of the other ones will).
The Future
There's not much to do for future versions of this. I've got two ideas in mind, however. The first one, since we're already using a database, is to allow the user to save any poems that they found interesting. This would require creating an account, but then in the future they could view any of their past random poetry.
Additionally, due to the way the code is written, a parameter can be passed into the function that generates a line of whatever number of syllables I want. With that in mind, I'm considering modifying the user interface to let them choose how many lines of poetry and how many syllables for each line. For example, the user could say, make a poem that is 5 lines long where the first line is 9 syllables, the second line is 6, the third is 4, etc. Someday, you'll be able to make your own style of poem, but for now . . .
Enjoy Poetry!
Poetry
Puttying Knee Worth
Contaminate Blood Searcher
Physics Studbook Maim
New Haiku