Skip to content

Instantly share code, notes, and snippets.

@tra38
Last active May 26, 2016 12:23
Show Gist options
  • Save tra38/b2a839e4aff6f5b643ab92358d8da9e6 to your computer and use it in GitHub Desktop.
Save tra38/b2a839e4aff6f5b643ab92358d8da9e6 to your computer and use it in GitHub Desktop.

Copyright (c) 2016 Tariq Ali

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#Here, we'll import the latest version of Calyx, to help organize our text generation.
#This can help us avoid needless boilerplate and make our code look far neater.
#Calyx: https://github.com/maetl/calyx
require 'calyx'
#Then, let's use Faker 1.6.3 to help us generate random words for us to use. Certainly,
#we can come up with the random words ourselves, but that would defeat the purpose
#of procedural generation. We want to stay as close to the metal as needed, but no
#closer.
#Faker: https://github.com/stympy/faker
require 'faker'
#At the time of writing, the latest version of Faker on RubyGems did not have the Faker::Educator module,
#so I had to download directly from the GitHub source. I used the specific-install gem to compile
#the latest version of the Ruby gem and to install it onto my local machine.
#Specific-Install: https://github.com/rdp/specific_install
# Finally, to handle a slight edge case of a/an confusion for the robot, I used this RubyGem to append
# indefinite articles properly to the beginning of certain words.
# indefinite_article: https://github.com/rossmeissl/indefinite_article
require 'indefinite_article'
#Already, a lot of work is being done by other algorithms, right off the bat.
#How could I claim credit for any of the stuff they did?
# Here is the array where we'll store our story.
story = []
#You can specify raw data that Calyx can then use to generate a story. I'm using Faker to generate
#the raw data for me, but I could have provided the data myself if I choose so.
mary_sue_bio = { university: Faker::Educator.university, degree: Faker::Educator.course, job_duty: Faker::Company.bs, job_title: Faker::Name.title, new_company: Faker::Company.name }
# Then we write out the template using Calyx.
introduction = Calyx::Grammar.new do
start "Tonight, I ran into a local AI shop, hoping to find a warbot that could kill me. Either someone would stop me, or I would succeed in my final, self-assigned mission. I couldn't care.\r\n\nMy name is Lt. Mary Sue. I graduated from the {university} with {degree.with_indefinite_article}, with a scholarship paid for by the American military. I served in the military as {job_title.with_indefinite_article}, where I {job_duty}. The job was fun...people really liked me...I felt like had a purpose, serving the world, one form at a time. But I wanted something more. I wanted glory, fame, recognition.\r\n\nAnd then, one day, the military started laying people off. 'Budget cuts', they claimed. They were profusely thanking me for my service while kicking me out of the door. I even saw the new robot that will serve as the replacement {job_title}...and I laughed so hard. I went home, grabbed my {degree}, and torn it up into shreds.\r\n\nThe only consoldiation prize in this whole ordeal was that the military promised me a reference to this great organization who was responsible for building that replacement robot: {new_company}..."
end
# After generating the introductory paragraph, we shovel it into the Story Array. We'll store it there until later.
introductory_section = introduction.generate(mary_sue_bio)
story << introductory_section
# These three paragraphs represent different episodes in Mary Sue's life, as she moves from company to company. These three paragraphs will later on be randomly shuffled in the actual story, since it doesn't really matter the 'order' of the jobs Mary Sue had.
robot_create_jobs = Calyx::Grammar.new do
start "{company} was an pro-AI lobbying firm funded by massive AI juggernauts. {company}'s main goal is to convince other people that AI was good. While most sane people believed that AI was good for humanity, a few 'free-thinkers' believed otherwise. They thought that AI would take away jobs! An absurd thought (though one that I agreed with, privately). So I went the beggars, the recently laid-off, the permanently unemployed, and told them the good news.\r\n\nAI doesn't kill jobs, it only makes people more efficent (which incidentally causes less efficent people to get laid off temporarily during an adjustment phase). Not only that, but AI would happily create new jobs, some time in the distant future! And even if it doesn't create new jobs, the increased productivity would create a society where no jobs are needed and you could still be considered a useful and worthy part of humanity! Hear the good news, hear it loud and clear!\r\n\nSurprisingly, nobody ever believed me. Instead, their eyes were glazed with cynicism. The idealistic few were instead gazing wistfully at a 'We're Hiring!' poster by {new_company}.\r\n\nEventually, {company} fired me and built a robot instead. The robot was much better at convincing the masses than I ever could. However, this time, I was prepared for this layoff. I submitted my resume over to {new_company}..."
end
basic_income = Calyx::Grammar.new do
start "{company} is a nonprofit organization that supported a Basic Income. Every person would receive a check every month, allowing humans to live a basic lifestyle. This safety net would alleviate social turmoil while promoting efficency in the welfare space. I served as a brilliant lobbyist, convincing politicians of the need to implement a Basic Income. And finally, a bill was proposed! The Basic Income Act, mandating that every American would receive $416.67/month.\r\n\nAnd suddenly, there was outcry from the poor. Only $416.67/month? That's not enough to survive! And they were horrified at the fact that the Basic Income Act would also abolish all welfare programs (Medicare, Medicaid, Social Security, Food Stamps, etc.), and that a $416.67/month check would not be enough to protect a person through times of emergency.\r\n\nInstead, demogagues within the mob argue for a Basic Income of $1005.92/month, enough to lift a poor person out of poverty. They also argued for this Basic Income to be funded by higher taxes on the wealthy elite. These demogagues were funded by 'donations' from a power-hungry and ruthless corporation named {new_company}.\r\n\n{company} expressed utter horror and disgust at such demagoguery, as it would ruin all the political compromises they made with Congress to pass this Basic Income. To supress this radical movement, {company} commissioned warbots. However, {new_company} also built warbots to protect the protesters. D.C. turned into a burning charnel-house.\r\n\nI had to choose between loyalty to the nonprofit or my own survival. I chose survival. In return for selling secrets about {company}'s warbots to the demogagues, the demogagues gave me a good reference to work at {new_company}. ({new_company} would eventually win the war and compel the government at gunpoint to implment the higher Basic Income.)"
end
ai_winter = Calyx::Grammar.new do
start "{company} is a venture capitalist firm dedicated to investing in new AI startups. I was their headhunter, finding startups and throwing money at them to let them grow bigger and bigger. It was very easy to find new AI startups, as everyone wanted to build AI startups. It was so easy and fun...all you have to do is create a regular startup, and then add AI to the front of the name. Why write boring old CSS when you can have AI-generated CSS? Why use an Excel Spreadsheet when you can instead use an AI Spreadsheet?\r\n\nWe didn't care about revenues...we only cared about innovation, and everything was so innovative. See, in the past, we used to produce music manually, but now we have machines that can produce music *almost as good as a human*! That's a real revolution, and {company} knew that eventually, one or two of these AI revolutions will lead to real profits. For us, I mean. We only make their money when we sell their shares off to the greater fools.\r\n\nI had lots of fun networking with wealthy founders whose only notable skill was networking with other wealthy founders. However, at one party, one of these wealthy founders said that he has left the startup scene to join up with an established corporation: {new_company}. This shocked me, and I asked him why. He said, 'Because the AI Winter has begun.'\r\n\nIt turns out that most of these startups were creatively mis-stating the capabilities of their AIs. Certainly, in a few decades, AI will be good enough to do everything they were promising. But not yet, and these startups didn't want to wait that long for academia to realize their dreams. So these startups were instead lying about their performance, to cheat investors out of their hard-owned cash. {company} closed down, having lost all of their wealth to these lying investors.\r\n\nAdmittingly, we weren't innocent either...near the end of this AI bubble, we realized that we were cheated. We still tried to sell off shares of these silly companies off to any greater fools we could find. But all the other greater fools were already bankrupt. So we too have to declare bankrupcy.\r\n\nA few of the wealthy founders I networked with had to plea guilty to fraud and were sentenced to prison...but most of the scammers had plausible deniability and escaped. Many of them landed jobs at {new_company}, and so I blackmailed one of my networked wealthy founders, in return for a good reference at {new_company}."
end
# These global variables will change as Mary Sue moves from job to job. Her starting company is the company that was originally generated in her introductory paragraph.
company = mary_sue_bio[:new_company]
new_company = Faker::Company.name
[ai_winter, basic_income, robot_create_jobs].shuffle.each do |paragraph|
# First, create a paragraph and append it to the story
story << paragraph.generate({ company: company, new_company: new_company })
# Now, Mary Sue changes jobs. The 'new_company' is now her old company, and another new_company is
# generated, for when she chaanges jobs again.
company = new_company
new_company = Faker::Company.name
end
#Now comes the epic conclusion.
ending = Calyx::Grammar.new do
start "And, as I walked over to {company} to get my shiny new job, I realized that there wouldn't be much point to doing so. I'd just stay there for a few months, and then have to leave that job to go elsewhere to some other absurd place. All I have done is just run from place to place, trying to avoid the inevitable fate of obsolescence. Society didn't need me. It never needed me. It loved its machines more.\r\n\nIt's time to end this farce. If society hated humans so much, then I will force it to be honest about its hatred.\r\n\nTonight, I ran into a local AI shop, hoping to find a warbot that could kill me. Either someone would stop me, or I would succeed in my final, self-assigned mission. I couldn't care.\r\n\nAt that AI shop, there was a research scientist. He stopped me from finding an AI warbot, by telling me that he had a plan. A plan to eliminate human suffering by building a superintelligence. If he succeeded, he would not only save all of mankind...he would also save me. I sighed and accepted his job offer. I would, once again, be dragged into the endless rat race."
end
# Append that story to the array.
story << ending.generate({ company: company })
# Print the whole story to the console.
puts story.join("\r\n\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment