Hanaz Writers

Imagine Story Continuations

function generateConditionalScenarios() { const storyInput = document.getElementById('storyInput').value.trim(); const outputContainer = document.getElementById('outputContainer'); const scenario1 = document.getElementById('scenario1'); const scenario2 = document.getElementById('scenario2'); const loadingMessage = document.getElementById('loadingMessage'); const generateButton = document.getElementById('generateButton'); // Reset output and show loading outputContainer.style.display = 'none'; scenario1.innerText = ''; scenario2.innerText = ''; loadingMessage.style.display = 'block'; generateButton.disabled = true; if (!storyInput) { alert("Please enter a story snippet."); loadingMessage.style.display = 'none'; generateButton.disabled = false; return; } // Simulate a delay for analysis setTimeout(() => { const scenarios = createConditionalScenarios(storyInput); scenario1.innerText = `Scenario 1:\n\n${scenarios[0]}`; scenario2.innerText = `Scenario 2:\n\n${scenarios[1]}`; outputContainer.style.display = 'block'; loadingMessage.style.display = 'none'; generateButton.disabled = false; }, 1500); // Simulate delay } function createConditionalScenarios(input) { const keywords = extractKeyElements(input); // Generate conditional continuations based on the story input return [ `If ${keywords.character || 'the main character'} chooses to ${keywords.action || 'continue forward cautiously'}, then they may ${keywords.challenge || 'encounter a hidden danger that tests their resolve'}. But if they ${keywords.alternativeAction || 'decide to retreat'}, then they risk losing the chance to ${keywords.goal || 'achieve their objective'}.`, `If ${keywords.character || 'the protagonist'} allies with ${keywords.support || 'a mysterious stranger'}, then they could ${keywords.benefit || 'gain valuable knowledge about their quest'}. However, if they mistrust ${keywords.support || 'the stranger'}, then they may ${keywords.risk || 'face the challenges ahead without critical information'}.` ]; } function extractKeyElements(input) { const sentences = input.split(/[.?!]/).map(s => s.trim()).filter(Boolean); const words = input.toLowerCase().split(/\s+/); const frequencyMap = {}; // Count word frequencies words.forEach(word => { const cleanWord = word.replace(/[^a-z0-9]/g, ''); if (cleanWord) { frequencyMap[cleanWord] = (frequencyMap[cleanWord] || 0) + 1; } }); // Define priorities for key elements const context = { character: findInSentences(sentences, ['hero', 'protagonist', 'adventurer', 'leader']), action: findInSentences(sentences, ['explore', 'investigate', 'approach', 'search']), alternativeAction: findInSentences(sentences, ['retreat', 'hide', 'avoid']), goal: findInSentences(sentences, ['find', 'save', 'rescue', 'defeat']), challenge: findInSentences(sentences, ['danger', 'trap', 'enemy', 'challenge']), support: findInSentences(sentences, ['ally', 'companion', 'stranger', 'guide']), benefit: findInSentences(sentences, ['gain', 'learn', 'find']), risk: findInSentences(sentences, ['lose', 'fail', 'endanger']) }; // Return extracted context return context; } function findInSentences(sentences, keywords) { for (let sentence of sentences) { for (let keyword of keywords) { if (sentence.toLowerCase().includes(keyword)) { return sentence; } } } return ''; }

AI Hanaz Writers version 1.0 is currently available. Version 2.0, a more advanced and purchasable upgrade, is currently being designed and prepared.