Classic Computer Magazine Archive ANTIC VOL. 6, NO. 4 / AUGUST 1987

Haiku Poet

"The swiftly computing Atari dreams nameless beyond your dragonfly"

by Albert Baggetta

Haiku Poet makes your Atari start rhapsodizing about the wonders of nature like a single white rose glimmering under a misty rainbow You even get simulated bamboo flute music in the background and a pseudo-oriental character set. This BASIC program works on 8-bit Atari computers with a minimum of 48K memory and disk drive.

Having long been fascinated by the Japanese mystique as interpreted by Western pop art, I decided to try my hand at a program that generates haiku poems, those magnificent short word-sketches that philosophize in a very spiritual way about nature, animals and the meaning of life.

Japanese haiku poems "paint" realistic images that can be symbols for other things. Snow might represent death, for example—or purity. The Sun, because it rises in the morning, might suggest life's eternal renewal.


Haiku Poet has two listings that will let your Atari take its rightful place in the centuries-old tradition of Japanese haiku masters. Listing 1 is the main program and Listing 2 creates the special Japanese-style character set.

Type in Listing 1, HAIKU.BAS, check it with TYPO II and SAVE a disk copy. Next, type NEW and type in Listing 2, MAKER.BAS, check it with TYPO II and SAVE a disk copy before you RUN it.

When RUN, Listing 2 creates the Japanese-style character set and writes it to a disk file called JAPAN.FNT-which will automatically be loaded each time Listing 1 is RUN.

HAIKU.BAS and JAPAN.FNT are on the back of the monthly disk, so they do not need MAKER.BAS.

You can also use JAPAN.FNT with most programs that will use redefined character set files (such as HomeTerm or Lister Plus). You may also examine and edit JAPAN.FNT with any character set editor.


As a program, Haiku Poet is primarily an experiment in emulating Artificial Intelligence (AI) on the 8-bit Atari. This program creates new patterns from an assortment of data, using fundamental rules of language. This is not easy in slow-paced BASIC, but careful programming creates the interesting illusion of computer-as-poet.

I gave the 8-bit Atari the raw materials for language communication. It knows where to find parts of speech such as articles, nouns, verbs, adjectives, pronouns, adverbs and prepositions—but it doesn't know what they are. A little help was needed here, so I set up potential patterns for the computer to choose from. Through random choices it selects not only the final order of the poem but the contents as well.

Two programming devices were used to add variety to the computer's output—RND (BASIC's random command) and a type of bank switching. Because of RND the program can choose randomly between different formats for a poem's structure. Sometimes it starts with an article, sometimes with a noun, sometimes it modifies these words with adjectives or constructs phrases that will modify. This creates a free form of verse, reminiscent of the works of great haiku poets such as Basho, Issa and Shiki.

Along with the RND function, I use a random-access searching technique to skip over inappropriate words in the DATA statements. The words in the DATA statements are arranged into grammatic categories such as personal pronouns, verbs and adjectives.

Each category begins at a "key" line number. The prepositions, for example, begin at line 1850. To find a preposition, the program simply bypasses all the other categories and begins its search at line 1850.

To further increase the degree of randomness, the program will often begin its search one line after the key line number. The program bases its choice on a random value stored in a variable named BANK. In the previous example, the program would begin its search at line 1850 when BANK=1, and at line 1860 when BANK=2.


Haiku poetry at its purest is a three-line form, where each line must have a specific number of syllables. Line one must have five syllables, line two must have seven and line three must have five again. English haiku translations usually try to stick close to this "official" format, but it is not absolutely required. That is fortunate, because Haiku Poet has a problem with producing an exact syllable count every time. Most of the poems created by this program will simply capture the essence of haiku imagery.

Ambitious programmers who want to generate Haiku poetry with the traditional 5-7-5 syllable count can add the syllable-counting routine from The San Francisco Fogger (Antic, February 1987). This routine begins at line 510 in the FOGGER.BAS listing.

Haiku Poet is not totally foolproof, which can regularly lead to amusing results. Some of its images will not be realistic, and others are downright foolish. But once in a while a real glimmer of truth and perception is displayed by the program. This still does not violate the original concept of the haiku too much. Some of the greatest haiku writers had a comic streak—they would sometimes juxtapose two unrelated objects to create a humorous effect.

(To our deepest shame, we must admit that certain irreverent members of the Antic staff got lots of cheap laughs out of changing the words in the DATA strings after the key lines—so that silly images were guaranteed. If you are the kind of low-life who enjoys doing this sort of thing just remember that you cannot change the total number of words in each DATA line.-ANTIC ED)


I added some graphic and sound features to give the program a more lifelike quality. As Haiku Poet is loading, it redesigns the standard Atari character set to look like oriental script. Some control characters are used for decorating a Japanese-looking screen with a sky-blue background.

After the screen is dressed up with bonsai trees and soaring birds, soft oriental "flute" music drifts into the background, adding to the tranquil effect of the haiku text being displayed.

If you see a verse that seems worthy of saving in print, just switch on your printer and hold down the [START] key. If your printer can load an oriental character set, you'll get a very impressive-looking set of poems.

The haiku will stay onscreen for a few minutes while the background tune plays. But to speed things up, you can call up a new poem by pressing any key—except the [SELECT] key, which ends your haiku session.

Albert Baggetta teaches English in Massachusetts and published Verbot Commander in the June 1987 Antic.

Listing 1  HAIKU.BAS Download

Listing 2  JAPAN.FNT Download