Software apps and online services | ||||||
|
I'm a writer and creative writing teacher, and I lead a lot of writing exercises. Some of my favorite exercises combine unrelated data, ideas, or artifacts -- from the census, say, or the newspaper -- into flexible but useful prompts. I made Random Muse to help automate the process, both for my own writing and in the classroom. I thought other writers and artists might find it useful.
Random Muse combines three random elements that are specific enough to provide productive constraints but vague enough to allow for a variety of approaches. Users simply ask Random Muse for an idea and try to use the three elements in a story, poem, or whatever else they're trying to create.
Random Muse currently produces over 100,000 unique combinations. That number will rise as I continue to update the skill.
/**
Copyright 2016 Eric Gregory
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* App ID for the skill
*/
var APP_ID = "amzn1.echo-sdk-ams.app.446e94c5-4f5b-4301-bf53-578e80681820";
/**
* Array containing ideas.
*/
var IDEAS = [
"A vending machine. ",
"Flowers in the sand. ",
"Counter-clockwise motion. ",
"A dim star. ",
"A smile. ",
"A skull. ",
"The Moon. ",
"A mixed-use development. ",
"A lapsed friendship. ",
"The ocean at night. ",
"Unquestioning trust. ",
"Clapping hands. ",
"An unfair decision. ",
"An old ceremony. ",
"A house. ",
"Broken window shades. ",
"A journalist. ",
"Gravity. ",
"Graffiti. ",
"An anonymous letter. ",
"An envelope full of money. ",
"Hesitant goodbyes. ",
"A game with shifting rules. ",
"A cleanup. ",
"Fossils. ",
"A misinterpreted joke. ",
"A bus. ",
"A student. ",
"A theft. ",
"A mortgage. ",
"A teacher. ",
"The question. ",
"Cousins. ",
"An unsteady ladder. ",
"A lose-lose scenario. ",
"An auction. ",
"An unlikely number. ",
"The earliest known record. ",
"A game with no winner. ",
"Mutual influence. ",
"Oil. ",
"Ink. ",
"A last hurrah. ",
"The last, best chance. ",
"An unfair match-up. ",
"A revisionist history. ",
"A second iteration. ",
"A fortunate discovery. ",
"Excessive politeness. ",
"Thwarted ambition. ",
"Hapless regulation. ",
"A new job. ",
"Avoidable debt. ",
"Time in prison. ",
"A new world. ",
"A global project. ",
"A regrettable date. ",
"A disloyal animal. ",
"Special privileges. ",
"Dancers. ",
"Night life. ",
"The service industry. ",
"A waiter. ",
"A waitress. ",
"Life during wartime. ",
"A new law. ",
"Hunger. ",
"Irreconcilable differences. ",
"Salvaged oak. ",
"An umbrella. ",
"An eclipse. ",
"A blind spot. ",
"An invisible college. ",
"A pufferfish. ",
"A coded message. ",
"A landslide. ",
"Sunburn. ",
"A train station. ",
"An airport. ",
"An abandoned city. ",
"The unutterable. ",
"A secret room. ",
"Tax evasion. ",
"Absolute moral authority. ",
"Late-night fast food. ",
"A path through the forest. "
];
/**
* The AlexaSkill prototype and helper functions
*/
var AlexaSkill = require('./AlexaSkill');
/**
* RandomMuse is a child of AlexaSkill.
*/
var RandomMuse = function () {
AlexaSkill.call(this, APP_ID);
};
// Extend AlexaSkill
RandomMuse.prototype = Object.create(AlexaSkill.prototype);
RandomMuse.prototype.constructor = RandomMuse;
RandomMuse.prototype.eventHandlers.onSessionStarted = function (sessionStartedRequest, session) {
console.log("RandomMuse onSessionStarted requestId: " + sessionStartedRequest.requestId
+ ", sessionId: " + session.sessionId);
// any initialization logic goes here
};
RandomMuse.prototype.eventHandlers.onLaunch = function (launchRequest, session, response) {
console.log("RandomMuse onLaunch requestId: " + launchRequest.requestId + ", sessionId: " + session.sessionId);
handleNewIdeaRequest(response);
};
/**
* Overridden to show that a subclass can override this function to teardown session state.
*/
RandomMuse.prototype.eventHandlers.onSessionEnded = function (sessionEndedRequest, session) {
console.log("RandomMuse onSessionEnded requestId: " + sessionEndedRequest.requestId
+ ", sessionId: " + session.sessionId);
// any cleanup logic goes here
};
RandomMuse.prototype.intentHandlers = {
"GetNewIdeaIntent": function (intent, session, response) {
handleNewIdeaRequest(response);
},
"AMAZON.HelpIntent": function (intent, session, response) {
response.ask("You can ask me to give you a random idea, or, you can say exit... What can I help you with?", "What can I help you with?");
},
"AMAZON.StopIntent": function (intent, session, response) {
var speechOutput = "Goodbye";
response.tell(speechOutput);
},
"AMAZON.CancelIntent": function (intent, session, response) {
var speechOutput = "Goodbye";
response.tell(speechOutput);
}
};
/**
* Gets a random new idea from the list and returns to the user.
*/
function handleNewIdeaRequest(response) {
// Get a randomized set of ideas from the idea list
var ideaIndex = Math.floor(Math.random() * IDEAS.length);
var ideaIndexTwo = Math.floor(Math.random() * IDEAS.length);
var ideaIndexThree = Math.floor(Math.random() * IDEAS.length);
// Prevent the same idea from occurring more than once
while (ideaIndex == ideaIndexTwo) {
var ideaIndexTwo = Math.floor(Math.random() * IDEAS.length);
}
while (ideaIndexTwo == ideaIndexThree) {
var ideaIndexThree = Math.floor(Math.random() * IDEAS.length);
}
while (ideaIndex == ideaIndexThree) {
var ideaIndexThree = Math.floor(Math.random() * IDEAS.length);
}
var ideaOne = IDEAS[ideaIndex];
var ideaTwo = IDEAS[ideaIndexTwo];
var ideaThree = IDEAS[ideaIndexThree];
// Create speech output
var speechOutput = ideaOne + ideaTwo + ideaThree;
response.tellWithCard(speechOutput, "Random Muse", speechOutput);
}
// Create the handler that responds to the Alexa Request.
exports.handler = function (event, context) {
// Create an instance of the RandomMuse skill.
var randomMuseSkill = new RandomMuse();
randomMuseSkill.execute(event, context);
};
Comments