Playing with dice

Home Forums Browsing the Hexes Playing with dice

This topic contains 2 replies, has 2 voices, and was last updated by  Delengroth 1 week, 2 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #31398 Reply

    Ray

    I’d say my favorite part of the Library of Babel was the description of the shunned practice of using dice, paper, and a writing utensil to effectively do the exact same thing the library is doing, as the chance of getting any information out of reading a page in the library is about the same as if you wrote a page according to the random selection of characters.

    Out of respect for this notion, I’ve been considering writing a code to generate a random page, with the intention of posting about one a day if I find the time (I’ll be using Java, as it’s the program I’m most familiar with).

    Current model:

    • Characters will be determined by Math.random multiplied by 29, truncated into an integer.
    • A function will index all 29 of the library’s characters into if statements that can be referred to by the random integer.
    • All characters will be stored in Strings representing individual lines.
    • Since I don’t believe I can include escape characters, a page will be represented by an ArrayList paramatized to store Strings.
    • Nested for loops will generate the page according to the 40 line 80 character parameters.
    • A for each loop will print the page.
    #31399 Reply

    Ray

    Program? The language I’m most familiar with*

    #31400 Reply

    Delengroth
    Participant

    Hm, I thought I had already done this, but only did so as a proof of concept of extending the search capability to include more than one search term.

    At any rate, I’d advise against using 29 if-statements. It’d be easier to just define an alphabet string, and then extracting a portion of it with your dice roll. The rest seems solid.

    If you’d like something to refer to, I wrote a quick Javascript example page generator. Good luck!
    https://jsfiddle.net/rvm0ofb3/

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Playing with dice
Your information: