A Hundred Thousand Billion Poems

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

A Hundred Thousand Billion Poems

#1 Post by Aacini » 26 Jul 2022 13:09

A few days ago I found a French book, Cent mille milliards de poèmes (A hundred thousand billion poems) published by Raymond Queneau in 1961, I found it so interesting that it inspired me to create a program to generate poems from it. I don't write extensive descriptions about the book here; I try to keep this explanation as simple as possible. If you want more details, search the web.

The book contains 10 different poems, each composed of 14 lines in the form of a sonnet: two quatrains followed by two triplets. Each of the 10 poems can be combined with others by changing one line to the same line from another poem. For example, you can take the first poem and change its fourth line to the same fourth line from the sixth poem, resulting in a slightly different poem. This change can be made to any of the 14 lines of any poem. For example, you can take the first line of the seventh poem, the second line of the tenth, the third line of the first, and so on. The number of different poems that can be generated in this way is 1 followed by 14 zeros (10^14): 100,000,000,000,000 (one hundred thousand billion poems).

Let's number the 10 original poems with a digit from 0 to 9 (instead of 1 to 10). Thus, we need 14 digits to select any poem: one digit for each of the 14 lines of the final sonnet. For example, poem number 00000000000000 has its 14 lines taken from the first poem, making it the first poem in original form. Poem 11111111111111 is the second original poem and so on until poem 99999999999999 which is the tenth original poem (Smullyan Index).

When not all digits are the same, several poems are combined. For example, poem number 00050000000000 is the first poem with its fourth line taken from the sixth poem. In the poem 69000000000000 we take the first line of the seventh poem, the second line of the last poem and the rest of the lines of the first poem.

Code: Select all

@echo off
setlocal EnableDelayedExpansion

rem Generate poems based on "Cent mille milliards de poèmes" Raymond Queneau's 1961 book
rem English translation of original French poems taken from:
rem    http://bevrowe.info/Internet/Queneau/Queneau.html -> "basic poems"
rem Designed and written by Antonio Perez Ayala - 2022/07/26

rem Read base poems and load they in "line[0..9][1..14]" two-dimensional matrix:
cd "%~P0"
for /L %%i in (0,1,9) do (
   if not exist "Poem%%i*.txt" (
      echo File missing: "Poem%%i-*.txt"
      pause
      exit /B
   ) else (
      for /F "tokens=1-3 delims=-." %%a in ('dir /B Poem%%i*.txt') do (
         (for /L %%j in (1,1,14) do (
            set /P "line[%%i][%%j]="
         )) < "%%a-%%b.%%c"
         set "name[%%i]=%%b"
      )
   )
)
set "skip=/4/8/11/"
for /F %%a in ('echo prompt $H ^| cmd') do set "BS=%%a"
set "BSx15=" & for /L %%i in (1,1,15) do set "BSx15=!BSx15!!BS!"

title CENT MILLE MILLIARDS DE POEMES (English version) - Antonio Perez Ayala
color 1F

rem To start with a random poem, enable next line:
REM goto option-1

set "number=99999999999999"

:loop
set "title="
for /L %%i in (0,1,9) do (
   if "!number:%%i=!" equ "" set "title=: !name[%%i]!"
)
(
cls
echo/
echo               CENT MILLE MILLIARDS DE POEMES (English version^)
echo/
echo/
echo Line - Base - Poem number %number%%title%
echo/
for /L %%j in (1,1,14) do (
   set "j=  %%j"
   for /F %%i in ("!number:~0,1!") do (
      echo !j:~-3!  -   %%i  - !line[%%i][%%j]!
      set "number=!number:~1!%%i"
   )
   if "!skip:/%%j/=!" neq "%skip%" echo/
)
)
echo/
echo/
echo   -^>  Random poem, Next poem, Base poem, Assemble poem, change Line, Exit
echo/
choice /C RNBALE /M "Select an option: "
echo/
goto option-%errorlevel%


:option-1  Random
for /L %%i in (0,1,%time:~-1%) do set "n=!random!"
set "number="
for /L %%j in (1,1,14) do set "number=!number!!random:~-1!"
goto loop
rem To store generated random numbers, delete previous line
rem Modify date/time format in order to write: YYYY/MM/DD@HH:MM:SS 12345678901234
for /F "tokens=1-6 delims=/:.," %%a in ("%date%/%time%") do (
   >> GeneratedPoems.txt echo %%c/%%a/%%b@%%d:%%e:%%f %number%
)
goto loop


:option-2  Next
set "n="
set "i=1"
for /L %%j in (1,1,14) do (
   set /A "j=!number:~-%%j,1!+i, i=j/10"
   set "n=!j:~-1!!n!"
)
set "number=%n%"
goto loop


:option-3  Base
choice /C 0123456789 /N /M "Select the Base poem (0-9): "
set /A "n=%errorlevel%-1"
set "number="
for /L %%j in (1,1,14) do set "number=!number!%n%"
goto loop


:option-4  Assemble
set /P "=Enter the 14 base lines: [%number%]!BSx15!" < NUL
set "number="
for /L %%j in (1,1,14) do (
   choice /C 0123456789 /N > NUL
   set /A "n=!errorlevel!-1"
   set /P "=!n!" < NUL
   set "number=!number!!n!"
)
goto loop


:option-5  Line
set /P "=Enter the line to change (1-14): " < NUL
choice /C 123456789 /N > NUL
set "j=%errorlevel%"
set /P "=%j%" < NUL
if %j% gtr 1 goto lineOK
choice /C 01234E /N /T 2 /D E > NUL
if errorlevel 6 goto lineOK
set /A "jM1=%errorlevel%-1, j=10+jM1"
set /P "=%jM1%" < NUL
:lineOK
echo/
set /A "jM1=j-1"
set "i=!number:~%jM1%,1!"
set "aux[%i%]=!BS!!BS!!BS!>> "
set "n=  %j%"
set "n=%n:~-3%"
echo/
for /L %%i in (0,1,9) do (
   echo %n%  -   !aux[%%i]!%%i  - !line[%%i][%j%]!
)
echo/
set "aux[%i%]="
choice /C 0123456789 /N /M "Select the base of line %j% (in place of %i%): "
set /A "n=%errorlevel%-1"
set "number=!number:~0,%jM1%!%n%!number:~%j%!"
goto loop


:option-6  Exit
title C:\...^>_
color
cls
The Batch file above can generate anyone of the hundred thousand billion poems in a very simple way. To download it, use Notepad to create a text file in your computer with any name you want and .BAT extension, "SELECT ALL" the above code, copy it (Ctrl-C), select the file, paste the code (Ctrl-V) and save/close the file. Before run it, download and extract in the same folder the 10 data files from the .ZIP file below. When the program run a poem is displayed, and a selection menu appears with these options:
  • Random: generate a Random poem.
  • Next: select the poem Next to the displayed one. The poem next to 00000000000000 is 00000000000001.
  • Base: display one of the ten Base (original) poems; from 00000000000000 to 99999999999999.
  • Assemble: allows to Assemble your own poem with the 14 lines you wish.
  • Line: allows to change one Line of the displayed poem selecting it from the same line of the 10 base poems.
  • Exit
The 10 base poems included in the .zip file below are an English translation taken from the Beverley Charles Rowe page (click on "basic poems" underlined words); the "names" I use to call the base poems appear somewhere on Rowe's site. Of course, the program will work just the same with any set of 10 correctly written files in any language.

A hundred thousand billion poems.zip
Text files for 10 base poems in English
(4.61 KiB) Downloaded 351 times

One surprising point about Queneau's book is that every time you generate a random poem with this program, you are almost certainly the first person who is reading such a version of the poem. This is because the number of different poems is huge! The probability that the same version of the poem has been previously generated on any other computer in the world is very, very small. The total number of human beings on the planet is "barely" less than 8 thousand billion. The number of people who use computers is a very small fraction of all human beings, and the number of people who run any of Queneau's poem-generating programs is a very small fraction of computer users. This means that the 100 thousand billion total poems is a number much larger than the number of poems generated by all computers so far, and this situation will continue for many years to come.

Raymond Queneau, the author of the book, estimated that if you read the book at a rate of one poem per minute, and you read it 8 hours a day, 200 days a year, you have enough poetry to read for a million centuries. However, this estimation has a simple (magnitude of one order) error. 8 hours times 200 days is 60*8*200 = 96,000 minutes per year, so 10^14 minutes / 96,000 minutes/year = 1,041,666,666 years. That is, more than 10 million centuries! :shock:

Fascinating! Isn't it? :D


NOTE: Below the ":option-1 Random" label in the code is a small segment designed to store randomly generated numbers of poems. I encourage you to enable that segment. If a sufficient number of users store these random numbers, at some point we could collect all these files to have enough data for a statistical study about this matter.


Antonio Pérez Ayala

miskox
Posts: 630
Joined: 28 Jun 2010 03:46

Re: A Hundred Thousand Billion Poems

#2 Post by miskox » 27 Jul 2022 06:37

Great. And in a month you will remind us to upload/post the GeneratedPoems.txt?

Saso

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: A Hundred Thousand Billion Poems

#3 Post by aGerman » 27 Jul 2022 13:27

The time has come when I have to admit that I don't speak English. At least I have a hard time understanding anything in these poems (even in the 10 templates) :lol:

Steffen

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: A Hundred Thousand Billion Poems

#4 Post by Aacini » 27 Jul 2022 17:00

Don't worry Steffen, I'm pretty sure even native English speakers have trouble understanding these poems, even the 10 base ones. The reason is simple. As the author of the translation explains in Queneau > Backstories > Sonnets of Queneau:

Queneau's writing in general does not leave the reader with a sense of narrative comfort; these sonnets are no exception. Since the randomization would destroy whatever narrative there is this is no real problem. It also allows a translator some freedom but I have tried to stay close to the original.

. . . . .

(Sonnet 10) feels more like a conventional sonnet. It almost has a narative. The other sonnets are much more disconnected, already feeling random.

And in Queneau > Background Stories > My translations of Queneau:

My own translation accepts the same challenge faced by anyone tackling Cent mille milliards de poèmes (CMMP), which is to translate strict verse (ie with rhyme plus metre or fixed line length) into similar strict verse.

This is recognised as being very difficult. In fact, it is probably the case that it is not possible to make a strict formal translation that is also true to the full meaning of the lines. Some compromise is inevitable. The type of poetry has a bearing, too. We are dealing here with the sonnet and I will confine myself to that form.

. . . .

Given the restrictions I accepted, it is not surprising that my translation sometimes falls down on its accuracy in representing the meaning of the original. This is generally a problem for a translation.

I invite you to read full sections abouth Queneau sonnets and the translation. To do that, follow the BevRowe link I gave before, click on the menu circle and select Queneau > Background stories.

Antonio

Post Reply