Your task is to create a program in BASIC that produce a simple, short story, in a few…
- User
Your task is to create a program in BASIC that produce a simple, short story, in a few sentences, perhaps two paragraphs.
- Assistant
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.
- Assistant
No problem, here's an updated version that generates a new story each time:
10 REM *** RANDOMIZED SHORT STORY GENERATOR *** 20 DIM CHAR(1) = "A": CHAR(3) = "C": CHAR(5) = "E": CHAR(7) = "G": CHAR = "Sir " + CHAR(INT(RND(1) * 8) + 1) + CHAR + "." 80 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; " 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