Code
/*
What is your computer thinking right now? What would it say if it had a mind of its own?
Using that as a start point, this is a scenario where your
computer ‘talks’ to you – random questions, comments or even just expressing annoyance…
You are then given a chance to respond - at which time, the computer reverts with an answer
that can be clarity personified or (as one of my room mates put it) – obfuscated convolutions.
This project is inspired in part by an article I read on James Joyce’s last work – Finnegan’s Wake.
In the Wake, Joyce uses language like that of a dream – “full of meaning and yet, not conscious
or fully formed, shimmering with layers of possible meaning”
To me, the way this program functions, is a variation on that theme – to the same question, no
two people will respond the same way and the computer will never revert with the same answer –
and the interpretation of that unique conversation is well…unique.
*/
String displayedText = new String();
String temp;
Vector words=new Vector();
float r=random(1); //for questions
boolean flag1=false;
void setup()
{
size(700,500);
framerate(24);
fill(255,255,0);
stroke(255,255,0);
}
void loop()
{
background(0);
BFont m = loadFont("Futura-Light.vlw.gz");
textFont (m,30);
text("Talk to me. I will reply....", 30,50);
text("whether you can make sense of my obviously ", 30,80);
text("superior repartee remains to be seen", 30,110);
int len = displayedText.length();
for(int i = 0; i< len; i++)
{
text(displayedText,30,230); //The position of answers
}
String lines[] = loadStrings("question.txt"); //The Questions
text(lines[(int)(r*lines.length)],30,200);
line(10,430,690,430); //Instructions
textFont (m,20);
text("[ TO LIKE(?!!) THIS PROGRAM, IT HELPS IF YOUR RESPONSE HAS AT LEAST THREE WORDS ]", 60,450);
text("[ Press Enter after typing in response. Press Enter again to clear screen ] [ Left click & hold to see samples ]", 30,480);
if (mousePressed==true) //Examples
{
background(0);
textFont(m,20);
text("-- Responses From The Far Side --",30,40);
text("question: Why are you here?",30,70);
text("typed: because i need you to work",30,90);
text("response: need is amazing i am jolted",30,110);
text("question: What happened yesterday?",30,150);
text("typed: was dull and dead day",30,170);
text("response: was restless dead and was I",30,190);
text("question: Should you leave now?",30,230);
text("typed: yes i probably should go",30,250);
text("response: yes fantastic yes kicked go lost",30,270);
text("question: What is there for me now?",30,310);
text("typed: there is a fantastic view",30,330);
text("response: you called view a ugly is",30,350);
text("question: Is this the Starship Enterprise?",30,390);
text("typed: yes",30,410);
text("response: yes yes super yes yes yield",30,430);
}
}
void keyPressed() //Action Listener
{
char typedKey = (char)key;
if(typedKey != 8)
{
displayedText = displayedText+typedKey;
}
else
{
String add = "";
for(int k = 0 ;k < displayedText.length()-1 ; k++)
{
add += displayedText.charAt(k);
}
displayedText = add;
}
if(typedKey==10) //Actions to be performed on Enter
{
if(!flag1)
{
StringTokenizer wordFinder =new StringTokenizer(displayedText); //Viva Google. Breaks up typed answer into seperate words
while(wordFinder.hasMoreTokens())
{
temp = wordFinder.nextToken();
words.add(temp);
}
displayedText = "";
String starter[] = loadStrings("start.txt");
String insert[] = loadStrings("verb.txt");
String end[] = loadStrings("adjective.txt");
float m=random(words.size());
float c=random(1);
float d=random(1);
float e=random(1);
displayedText = displayedText.concat(starter[(int)(c*starter.length)])+ ' ';
displayedText = displayedText.concat(insert[(int)(d*insert.length)])+' ';
displayedText = displayedText.concat((String) words.get((int)m))+ '.'+' ';
m=random(words.size());
displayedText = displayedText.concat((String) words.get((int)m)) + ' ';
displayedText = displayedText.concat(end[(int)(e*end.length)]) + ' ';
m=random(words.size());
displayedText = displayedText.concat((String) words.get((int)m)) + ' ';
println(displayedText);
flag1 = true;
}
else
{
println(flag1);
displayedText = "";//Clears the previous answers
words.removeAllElements();//Empties the Vector object
r=random(1); //Choose the next question
flag1 = false;
}
}
}
Project 3: Create a literary machine.
Statement:Literary machines are potential literature, procedurally producing textual traces in response to interaction. Examples of literary machines include interactive fiction, nodal hypertexts, interactive poetry (often with animated typography), and chatterbots. Create a literary machine. The literary machine must include algorithmic elements, such as animated typography, generated text, conditional responses as a function of the previous interaction trace. It must respond to external inputs (e.g. user interaction). Your piece may include conjunctions of text and imagery.
The Literary Machine