1
RANDOM STORY GENERATE GAME
CANDIDATE'S DECLARATION
2
I hereby declare that the project titled “Random Story
Generator" is my own work, and I have completed it under
the guidance and supervision of My Mentors at Indus
International University. The project has been developed
as part of my Bachelor’s Of Computer
Science program, and all the work presented in this
project is original and has not been copied from any
external sources without propercitations.
I further affirm that all the data, research, and findings
used in this report are authentic to the best of my
knowledge. Any assistance received in the preparation of
this report has been duly acknowledged. I also confirm
that this project has not been submitted
for any other degree or academic qualification.
This work was completed between [start date] and [end
date], and I am solely responsible for the content
presented here.
Signature: Harsh Choudhary
Date: 11/12/2024
3
Project: Random Story Generator
Objective:
Tocreate a web-based application that generates random,
short stories by combining elements from pre-defined
arrays.
Functionality:
1. User Interface:
o A simple, user-friendly interface with a clear heading.
o A prominent "Generate Story" button.
o A paragraph element to display the generated story.
2. Story Generation:
o Three arrays: beginnings, middles, and ends, each
containing a list of story segments.
o A JavaScript function triggered by the button click:
o Randomly selects one element from each array using
the Math.random) function.
o Concatenates the selected elements into a
complete story.
4
o Updates the paragraph element to display the
generated story.
Enhancements
1. Customization:
o Allow users to input their own story segments.
o Provide a form for users to add or modify elements in
the arrays.
2. Story Length:
o Implement options for generating stories of different
lengths (short, medium, long).
o Adjust the number of elements selected from each
array based on the chosen length.
4. Story Structure:
o Experiment with different story structures (e.g., linear,
branching, cyclical).
o Implement algorithms to generate stories with varying
plot twists and resolutions.
5. Visual Appeal:
o Customize the appearance of the generated stories
(e.g., font, color, formatting).
o Add animations or visual effects to enhance the user
experience.
5
6. User Feedback:
o Incorporate a feedback mechanism (e.g., rating
system, comments).
o Use user feedback to improve the story generation
algorithm and content.
Additional Considerations:
o Error Handling: Implement error handling to prevent
unexpected behavior, such as empty arrays or invalid
user input.
o Accessibility: Ensure the application is accessible to
users with disabilities by following web accessibility
guidelines (e.g., using appropriate HTML semantics,
providing alternative text for images).
o Performance: Optimize the JavaScript code to
minimize page load times and ensure smooth story
generation.
o Cross-Browser Compatibility: Test the application
on different browsers to ensure consistent behavior.
Code
6
o <!DOCTYPE html>
o <html>
o <head>
o <title>Random Story Generator</title>
o <link rel="stylesheet" type="text/css" href="sample.css">
o <meta name="viewport" content="width=device-width, initial-
scale=1.0">
o </head> <body>
o <div class="container">
o <h1>Random Story Generator</h1>
o <button id="generateButton">Generate Story</button>
o <p id="story"></p>
o </div>
o <script>
o document.getElementById('generateButton') addEventListener('click',
function() {
o var beginnings = ['Once upon a time', 'In a galaxy far, far away', 'In an
ancient land'];
o var middles = ['there lived a mighty dragon', 'a hero was born', 'an
adventure began'];
o var ends = ['and they all lived happily ever after', 'which changed the
world forever', 'marking the area'];
o var story = beginnings [Math. floor (Math, random() * beginnings.length)]
+', ' +
o middles [Math. floor (Math. random() * middles.length)] + ', ' +
o ends [Math. floor (Math. random () * ends. length)] + '.';
o document.getElementById ('story'). innerText = story;
o });
o </script>
o </body>
o </html>
7
8