Cluster 2
“Your task is to create a program in BASIC that produce a simple, short story, in” (2 conversations)
2 turns Apr 20, 2023 at 10:25 PM CEST Sweden , Norrbotten County
USER
Your task is to create a program in BASIC that produce a simple, short story, in a few sentences, perhaps two paragraphs.
CHATBOT
10 PRINT "Once upon a time, in a land far, far away..." 20 PRINT "There was a brave knight named Sir Robert." 30 PRINT "Sir Robert had a quest to rescue the princess from the dragon's lair." 40 PRINT "He set out on his trusty horse and fought the dragon with all his might." 50 PRINT "After a fierce battle, Sir Robert emerged victorious and rescued the princess." 60 PRINT "The kingdom rejoiced and Sir Robert was hailed a hero." 70 END
USER
I forgot to mention it should be a new, randomized story every time the program is run.
CHATBOT
No problem, here's an updated version that generates a new story each time: 10 REM *** RANDOMIZED SHORT STORY GENERATOR *** 20 DIM CHAR$(8): CHAR$(1) = "A": CHAR$(2) = "B": CHAR$(3) = "C": CHAR$(4) = "D" 30 CHAR$(5) = "E": CHAR$(6) = "F": CHAR$(7) = "G": CHAR$(8) = "H" 40 RANDOMIZE TIMER 50 PRINT "Once upon a time, in a land far, far away..." 60 LET HERO$ = "Sir " + CHAR$(INT(RND(1) * 8) + 1) + CHAR$(INT(RND(1) * 8) + 1) + CHAR$(INT(RND(1) * 8) + 1) 70 PRINT "There was a brave knight named "; HERO$ + "." 80 PRINT HERO$ + " had a quest to "; 90 LET QUESTS%(INT(RND(1) * 3) + 1)) = 1: LET PRINCESS% = INT(RND(1) * 2) + 1 100 IF QUESTS%(1) THEN PRINT "overthrow the evil sorcerer and restore peace to the land." 110 IF QUESTS%(2) THEN PRINT "find the legendary treasure and become the richest knight in the kingdom." 120 IF QUESTS%(3) THEN PRINT "rescue the "; IIF(PRINCESS% = 1, "princess", "prince"); " from the dragon's lair." 130 PRINT HERO$ + " set out on his trusty horse and "; 140 LET BATTLES%(INT(RND(1) * 3) + 1)) = 1: LET WINS% = 0 150 IF BATTLES%(1) THEN PRINT "fought a band of trolls who were terrorizing a nearby village." 160 IF BATTLES%(2) THEN PRINT "defeated a giant spider that was nesting in an old castle." 170 IF BATTLES%(3) THEN PRINT "confronted the mighty dragon that was guarding the "; IIF(PRINCESS% = 1, "princess", "prince"); "." 180 LET WINS% = INT(RND(1) * 2) + 1 190 IF WINS% THEN PRINT "After a fierce battle, "; HERO$; " emerged victorious" 200 IF NOT WINS% THEN PRINT "Despite his bravery, "; HERO$; " was defeated." 210 IF PRINCESS% = 1 THEN PRINT "The princess was saved and the kingdom rejoiced." 220 IF PRINCESS% = 2 THEN PRINT "The prince was saved and the kingdom rejoiced." 230 PRINT HERO$; " returned home a hero." 240 END Each time the program is run, it will randomly choose a hero name, quest, battle, and outcome, creating a unique short story.