On Narrative vs. Computer Programming Christos H. Papadimitriou UC Berkeley “christos” with many thanks to Martha Sideri.

Slides:



Advertisements
Similar presentations
The people Look for some people. Write it down. By the water
Advertisements

Fry’s Third 100 Phrases Read each phrase out loud in a soft voice.
A.
Recursion CS 367 – Introduction to Data Structures.
Chapter 1 Jim Hawkins’ Story I
Lesson 19 Day 2 You will need your book, journal, workbook and pencil.
Hamburger Paragraphs How to write a really great paragraph!
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
18-Jun-15 Arrays. 2 A problem with simple variables One variable holds one value The value may change over time, but at any given time, a variable holds.
Myth emati CS Christos H. Papadimitriou UC Berkeley : christos.
Program Design and Development
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
26-Jun-15 Arrays. 2 A problem with simple variables One variable holds one value The value may change over time, but at any given time, a variable holds.
Second Grade English High Frequency Words
Just Refresh Your Mind… How Many of U like to Play wit This.... By: Krishna H Nayak AM-HR, GRPL Chennai. M:
Lesson A How's your memory?Lesson B Strange dreams Vocabulary Link These people are at a college reunion. Read what the people are saying. Pay attention.
Turing Test From
ENGLISH THROUGH LITERATURE Unit 2 The Heart of the Matter Produced by Bruce Michael.
SLOW DOWN!!!  Remember… the easiest way to make your score go up is to slow down and miss fewer questions  You’re scored on total points, not the percentage.
I am ready to test!________ I am ready to test!________
Sight Words.
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Week 5 - Monday.  What did we talk about last time?  Linked list implementations  Stacks  Queues.
224 3/30/98 CSE 143 Recursion [Sections 6.1, ]
Sight words.
APCS Java AB 2004 Review of CS1 and CS2 Review for AP test #1 Sources: 2003 Workshop notes from Chris Nevison (Colgate University) AP Study Guide to go.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
1 Wright State University, College of Engineering Dr. T. Doom, Computer Science & Engineering CS 241 Computer Programming II CS 241 – Computer Programming.
Introduction to programming in the Java programming language.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Lesson 22 Day 2 You need your text book..
Review, Pseudocode, Flow Charting, and Storyboarding.
Sight Word List.
Design Studies 20 ‘Show Off’ Project How to make a computer monitor In Google Sketchup By: Liam Jack.
AP Computer Science edition Review 1 ArrayListsWhile loopsString MethodsMethodsErrors
Alice Learning to program: Part Two Writing Your Own Methods by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Introduction Chapter 1 8/31 & 9/1 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
High Frequency Words August 31 - September 4 around be five help next
1 Recursion Recursion is a powerful programming technique that provides elegant solutions to certain problems. Chapter 11 focuses on explaining the underlying.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
Sight Words.
High Frequency Words.
Identify Poetic Devices
Near the car. For example Watch the river. Between the lines.
The Third 100. Directions: Read each phrase. A left mouse click advances the slide show. Time yourself. Try to get faster and make fewer errors. Have.
Locked Out A child is locked out from his house, knocking on the front door saying 'Dad, Dad' but seeing his friends riding by on their bikes, he runs.
Recursion. Recursive Methods  A recursive method is a method that calls itself.  General Form of Simple Recursive Methods  Every recursive method has.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
CSE 143 Lecture 9 Recursion slides created by Alyssa Harding
Recursion in Java The answer to life’s greatest mysteries are on the last slide.
Chapter 7 Continued Arrays & Strings. Arrays of Structures Arrays can contain structures as well as simple data types. Let’s look at an example of this,
Figurative Language Metaphor In Lesson 32 you will: 1.Understand what is metaphor. 2.Know the purpose of metaphors. 3.Practice writing metaphors.
Understanding AI of 2 Player Games. Motivation Not much experience in AI (first AI project) and no specific interests/passion that I wanted to explore.
By: Megan Funk. I will: 1. Explain the binary number system How to: -Generate binary from a number -Add binary 2. Explain the base-b number system 3.
CSE 143 Lecture 9: introduction to recursion reading: 12.1.
Created By Sherri Desseau Click to begin TACOMA SCREENING INSTRUMENT FIRST GRADE.
CS 326 Programming Languages, Concepts and Implementation
Java Software Structures: John Lewis & Joseph Chase
Turing Test From
Subroutines Idea: useful code can be saved and re-used, with different data values Example: Our function to find the largest element of an array might.
Chapter 12 Recursion (methods calling themselves)
Fry Word Test First 300 words in 25 word groups
On Narrative vs. Computer Programming
slides created by Marty Stepp and Alyssa Harding
Recursion based on slides by Alyssa Harding
Turing Test From
Presentation transcript:

On Narrative vs. Computer Programming Christos H. Papadimitriou UC Berkeley “christos” with many thanks to Martha Sideri

2 outline what is computer programming? the elements of c.p. in narrative similarities, parallels and connections between c.p. and narrative interleaved with above: narratives of programming

3 what does a program do? defines its data types and the ways these interact with one another (through programs) a program changes the state of its data types it may branch conditionally or it may repeat until conditions are met or it may invoke other programs – or itself (!?)

4 class Fighter { static int count; // CLASS VARIABLE: how many fighters there are int strength = 1; // my strength int direction; // direction I'm facing Battleground place; // the Battleground that I fight on int row, column; // where I am int newRow, newColumn; // where I want to be int lastMoved = -1; // last turn that I did something Fighter (Battleground place, int row, int column) // Construct a Fighter. { direction = (int) (Math.random () * 4); // face in a direction 0 to 3 this.place = place; // remember my battleground this.row = row; // remember my location this.column = column; count++; // count me } data type attributes birth

5 void doSomething (int step) { // If I've already moved, don't move again if (step == lastMoved) return; else lastMoved = step; // sometimes change direction (about 10% of the time) if (Math.random () < 0.10) direction = (int) (Math.random () * 4); // figure out where I want to be newRow = row; newColumn = column; switch (direction) { case 0: newRow = (row + 1) % place.size; break; case 1: newRow = (place.size + row - 1) % place.size; break; case 2: newColumn = (column + 1) % place.size; break; case 3: newColumn = (place.size + column - 1) % place.size; break; } interaction

6 // if that space is occupied, fight for it, else just move there if (place.warzone [newRow][newColumn] != null) fight (newRow, newColumn); else move (newRow, newColumn); } void move (int newRow, int newCol) // Do a simple, uncontested move { place.warzone [row][column] = null; // Move from here place.warzone [newRow][newColumn] = this; // to here, and row = newRow; column = newColumn; // remember where I am now. } void fight (int newRow, int newColumn) // Fight someone in that location { Fighter opponent = place.warzone [newRow][newColumn]; invoke interactions

7 if (strength >= opponent.strength) // If I win, { strength += opponent.strength; // take my opponent's strength move (newRow, newColumn); // and position; Fighter.count--; // he's gone now, reduce count. } else { opponent.strength += strength; // But if I lose, place.warzone [row][column] = null; // erase myself Fighter.count--; // and count me gone. } public String toString () // Represent a fighter by just his strength { if (strength < 10) return " " + strength; // add a blank if < 10 else return "" + strength; // else just convert to String } conditional branching

8 public class Battleground { int size; // size of the battleground Fighter [][] warzone; // array representing the battleground Battleground (int size) // Construct a Battleground. { warzone = new Fighter [size][size]; // Make the array this.size = size; // and remember how big it is. for (int i = 0; i < size; i++) // Put a Fighter in 25% of for (int j = 0; j < size; j++) // squares (the rest are initially if (Math.random () < 0.25) // null). warzone[i][j] = new Fighter (this, i, j); } void print () // Print the Battleground. another data type birth repetition

9 void print () // Print the Battleground. { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (warzone[i][j] == null) System.out.print (" --"); else System.out.print (" " + warzone[i][j]); } System.out.println (); } public static void main (String args[]) { final int SIZE = 10; // Constant: size of battleground final int STEPS = 10; // Constant: number of steps to run simulation Battleground battleground = new Battleground (SIZE); // Make battleground. so we can see it action!

10 for (int step = 0; step < STEPS; step++) // Run for STEPS steps. { System.out.println ("Step " + step + ", " + Fighter.count + " fighters:"); battleground.print (); if (Fighter.count == 1) break; // Quit early if we have a winner, for (int i = 0; i < SIZE; i++) // else loop through battleground for (int j = 0; j < SIZE; j++) // and let each Fighter doSomething. if (battleground.warzone[i][j] instanceof Fighter) battleground.warzone[i][j].doSomething (step); } System.out.println ("At end (" + Fighter.count + " fighters left):"); battleground.print (); } …and that’s the whole program

11 recall: what does a program do? defines its data types and the ways these interact with one another (through programs) a program changes the state of its data types it may branch conditionally or it may repeat until conditions are met or it may invoke other programs – or itself (!?)

12 data types  characters their definition creates the diegesis (the “world” of the story) their complexity is that of the story polymorphism: same stimuli bring different responses

13 data types  characters (cont.) pure diegeses: computer games real life as pure diegesis: e.g, the banking world

14 programming narratives I “…The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination. Few media of creation are […] so readily capable of realizing grand conceptual structures…” Fred Brooks

15 repetition? branching? subroutine call? recursion? Repetition/iteration is a signature feature of the folk tale: “the first day, the older son tried to cross the river, but the dragon…”

16 narrative with branching: the interactive novel “if you want Guinevere to fall in love with Lancelot and leave Arthur click here” (nb: another form of pure diegesis)

17 program invocation: the nested narrative stories within stories (plays too…) e.g., The Blind Assassin The Blind Assassin Iris’s story The lovers’ story

18 program invocation: the nested narrative stories within stories (plays too…) e.g., The Blind Assassin The Blind Assassin Iris’s story The lovers’ story stack

19 program invocation: the nested narrative stories within stories (plays too…) e.g., The Blind Assassin The Blind Assassin Iris’s story The lovers’ story stack

20 program invocation: the nested narrative stories within stories (plays too…) e.g., The Blind Assassin The Blind Assassin Iris’s story The lovers’ story stack

21 program invocation: the nested narrative stories within stories (plays too…) e.g., The Blind Assassin The Blind Assassin Iris’s story The lovers’ story stack

22 program invocation: the nested narrative stories within stories (plays too…) e.g., The Blind Assassin The Blind Assassin Iris’s story The lovers’ story stack

23 program invocation: the nested narrative stories within stories (plays too…) e.g., The Blind Assassin The Blind Assassin Iris’s story The lovers’ story stack

24 program invocation: the nested narrative stories within stories (plays too…) e.g., The Blind Assassin The Blind Assassin Iris’s story The lovers’ story stack

25 recursion in narrative? self-referential and self-aware narrative not a new idea… If on a Winter’s Night a Traveler

26 so, what can programs and stories can have in common? programs must “compile and run” (i.e., be correct enough so they can be executed on a computer) stories must get published, be read, “work” programs usually contain bugs that prevent them from accomplishing these often so do novels bug or feature?

27 programming narratives II “A computer can execute millions of instructions in a second. The human brain, in comparison, is painfully slow. The memories of a single year, for instance, took me a full thirty seconds to recall…” Ellen Ullman The Bug

28 so, what else can programs and stories can have in common? programs are intentions, ploys; they only have a tentative existence until they are actually executed on a computer stories too: they are just the author’s intention to induce certain emotional reactions to a reader (by the way: genomes also…)

29 mythematiCS noun, plural but plural&singular in use, nlgsm/slpn from Gr myth (= story that serves to unfold a world view or explain a practice, belief, or natural phenomenon) 1: the use of story-telling in the teaching of computer science (CS) and mathematics stories can help in the teaching of programming

30 1.Historical/biographical context (e.g., Galois, Turing, Al Khwarizmi,…) 2.Storied illustration (e.g., Theseus and Ariadne; “Procopia”; Copenhagen; Incompleteness ) “There is no idea worth explaining that cannot be explained by a good story” 3.Extreme mythematics: Embedding the material in a story the three modes of Myth ematiCS

31 but aren’t they both just grammars? in computer programming, linguistic formalism has been rampant in the 1960s-70s it has only helped in program analysis, and there mostly with the superficial (syntactic) structure of programs in the theory of the narrative: ditto?

32 programming narratives III: the hacker crime story the Morris worm the takedown of Kevin Mitnick the “I love you” virus

33 both are “mind-bogglingly combinatorial” The creation of a more than minimally complex narrative appears to involve the same kind of puzzle-solving one needs to apply when writing programs (and proving theorems, by the way)

34 e.g., fill in the blanks… _ _ _ r _ _ _ _ _ r _ w s b _ _ _ q _ _ _ m _ _ r o _ c e f _ k m a underconstrained overconstrained puzzles!

35 the diagram constraints complexity “puzzles” underconstrainedoverconstrained

36 the diagram constraints number of solutions “puzzles” “phase transition”

37 finally: programs of narration (or: the heroes of NI : understanding language post 1990 : the new era –narrative interfaces and agents –story databases –story understanding –narrative memory/intelligence –story generation

38 Human or Computer Poet? 1.is beauty itself that they were walking there. All along the new world naked, cold, familiar wind - 2.Pink confused with white flowers and flowers reversed take and spill the shaded flame darting it back into the lamp's horn 3.The winds of the oozy woods which wear the ocean, with azure moss and flowers So sweet, the purple even I sleep in the arrows Of the dome of death. 4.O thou, Who moved among some fierce Maenad, even among noise and blue Between the bones sang, scattered and the silent seas. 5.She eyes me with an ingrown eye, in the rhythm of teacup tapping thinks of sweeping away crumbs

39 Human or Computer Poet? 6.At six I cannot pray: Pray for lovers, through narrow streets And pray to fly But the Virgin in their dark wintry bed 7.What seas what shores what granite islands towards my timbers and woodthrush calling through the fog My daughter. 8.Imagine now a tree in white sails still whirled About the leaves will be of silences Calm and angels 9.-and the sun, dipping into the avenues streaking the tops of the irregular red houselets,and the gay shadows dropping and dropping. 10.The morning and already a perfect if slightly paled old park turned with young women seized in amber

40 Answers (1-5) 1.is beauty itself that they were walking there. All along the new world naked, cold, familiar wind - 2.Pink confused with white flowers and flowers reversed take and spill the shaded flame darting it back into the lamp's horn 3.The winds of the oozy woods which wear the ocean, with azure moss and flowers So sweet, the purple even I sleep in the arrows Of the dome of death. 4.O thou, Who moved among some fierce Maenad, even among noise and blue Between the bones sang, scattered and the silent seas. 5.She eyes me with an ingrown eye, in the rhythm of teacup tapping thinks of sweeping away crumbs William Carlos Williams Computer Computer Computer Raymond Kurzweil

41 Answers (6-10) 6.At six I cannot pray: Pray for lovers, through narrow streets And pray to fly But the Virgin in their dark wintry bed 7.What seas what shores what granite islands towards my timbers and woodthrush calling through the fog My daughter. 8.Imagine now a tree in white sails still whirled About the leaves will be of silences Calm and angels 9.-and the sun, dipping into the avenues streaking the tops of the irregular red houselets, and the gay shadows dropping and dropping. 10.The morning and already a perfect if slightly paled old park turned with young women seized in amber Computer Computer T.S. Eliot William Carlos Williams Raymond Kurzweil