The code for the essay generator is in Notes and Credits. The code is written in Lua. Copy the code and run it on Online Compiler (Browser). Copy the entire code and run it in online compiler. To change the topic of the essay, change the "local topics"
-- Offline Lua Essay Generator (Simulated AI) -- Generates ~2000 words of random essay-like text without internet or login. math.randomseed(os.time()) -- Some sample words and phrases to simulate essay writing local phrases = { "In the modern world", "It is important to note that", "Furthermore", "On the other hand", "This demonstrates that", "As a result", "From a historical perspective", "In conclusion", "Therefore", "One could argue that", "It is widely believed that", "In many cases", "The significance of this", "This leads us to consider", "Moreover", "In recent years", "It is evident that", "Consequently", "From this viewpoint", "Ultimately" } local topics = { "technology", "education", "environment", "history", "science", "philosophy", "economics", "culture", "politics", "health" } -- Function to generate a random sentence local function randomSentence() local phrase = phrases[math.random(#phrases)] local topic = topics[math.random(#topics)] local sentence = phrase .. " the topic of " .. topic .. " has been discussed extensively." return sentence end -- Function to generate essay text local function generateEssay(wordTarget) local essay = {} local wordCount = 0 while wordCount < wordTarget do local sentence = randomSentence() table.insert(essay, sentence) -- Count words in the sentence local count = 0 for _ in sentence:gmatch("%S+") do count = count + 1 end wordCount = wordCount + count end return table.concat(essay, " ") end -- Main program local targetWords = 2000 print("Generating a simulated essay of about " .. targetWords .. " words...\n") local essay = generateEssay(targetWords) print(essay) print("\n=== Word count: ~" .. targetWords .. " words ===")