Download Lecture 1 - LCC Home

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
LCC 6310
Computation as an Expressive Medium
Lecture 1
Overview
• Go over the syllabus
• Brief introduction to me and my work
• Art, programming and Java
Syllabus
Background
• Ph.D. in Computer Science
• Expressive AI: Artificial Intelligence-based art and
entertainment
• Worked in industrial research labs (Intel,
Tektronix) doing HCI research
• New at Georgia Tech – arrived in January
AI & Art
The Senster, 1970
Edward Ihnatowicz
Black and White, 2000
Peter Molyneux (Lionhead)
Work
Façade – interactive drama
Terminal Time – interactive video
Office Plant #1 – robotic sculpture
Façade
• Dramatic world inhabited by
computer controlled characters
(believable agents)
• The user (player) plays a
protagonist within the story,
first-person point of view
• The player experiences a story
with a dramatic arc
Collaborator: Andrew Stern, independent artist and researcher
Terminal Time
Goal trees (ideology)
Historical events
Audience feedback
Audio-visual
elements
Collaborators: Steffi Domike, Design Department, Chatham College
Paul Vanouse, Art Department, SUNY Buffalo
Office Plant #1
• Creates a background presence
• Sorts incoming email into social
and emotional categories
• Behavior is a function of the
email received
Collaborator: Marc Bohlen, Media Studies, SUNY Buffalo
Combine AI research and art
Expressive AI
Artistic practice
Wrestling with meaningful human
experiences suggests new AI
research directions…
AI research
AI methods and technology
suggest new audience
experiences…
Some directions
• I’m someone to chat with about…
• Interactive story (particularly procedural
approaches)
• Robotic sculpture
• Video games as a cultural practice (design and
technology)
• Meta-art (generative systems)
Introduce yourselves
Programming languages
• Abstract, “human understandable” language for
telling computer what to do
• The abstract language must be translated into
the low level language understood by the
machine
• This translation is accomplished by an
interpreter or compiler
• We will be learning the compiled language Java
A simple Java program
Human readable?!?
class PrintLoop {
public static void main(String[] args) {
for (int i = 0; i < 10; i++)
System.out.println("i = " + i);
}
}
Just prints the numbers 0 to 9 on the screen
“Human readable” is relative
class PrintLoop {
public static void main(String[] args) {
for (int i = 0; i < 10; i++)
System.out.println("i = " + i);
}
}
Java compiler translates this into…
Java VM assembly code
public static void
main(java.lang.String[]);
Code:
0:
iconst_0
1:
istore_1
2:
goto
30
5:
getstatic
8:
new
11: dup
12: ldc
14: invokespecial #23
17: iload_1
18: invokevirtual #27
21: invokevirtual #31
24:
27:
30:
31:
33:
36:
invokevirtual #34
iinc
1, 1
iload_1
bipush 10
if_icmplt 5
return
test.PrintLoop();
Code:
0:
aload_0
1:
invokespecial #43;
4:
return
Object Oriented vs. Procedural
Languages
Procedural (e.g. C)
• We create some data
representing an image
(array of pixels to draw
on the screen)
• We write a procedure
than can be passed the
image and will draw it
Object Oriented (e.g. Java)
• We create a class that
contains an image AND a
routine draw it
• The data and the behavior
(ability to draw) are in one
"container"
A couple of Java’s relatives
• Smalltalk 80
• Alan Kay and the Dynabook (PARC)
• C++
• Managing big C programs: Bjarne Stroustrup
Smalltalk 80
• Alan Kay and the Dynabook (PARC)
• Developed idea of a general purpose computer
to be used by normal people!
• Highly interactive interface
• Included concept of windows!
• Smalltalk 80 – end users could create their
own tools
Smalltalk 80
• Includes objects
• Objects contain data and procedures
• Procedures in objects are called methods
• All computing is done by sending a message to
an object asking it to perform one of its
method
• Objects are defined by classes
C++
• Managing big C programs: Bjarne Stroustrup
• Started as "C with Classes" idea borrowed from
Simula 67 & Smalltalk
• Goals
• Organize programs as classes with inheritance
• No performance penalty compared to C
• Thus somewhat dangerous!!!
• C++ is converted into C
Java
• Designers started with C++
• Smaller
• Simpler
• Safer
• Programming embedded systems
• Toasters, microwave ovens, TV set top boxes
• Reliability very important--avoid costly recalls
• Web programming
• Incorporated into web browsers at critical moment
The virtual machine
• Since Java was designed to run on embedded
systems, it was designed around a virtual
machine
• “Write once, run everywhere”
PC
Mac
Cell Phone
Java VM
Windows
Java VM
OS X
Java VM
x86
G3/4/5
Java Machine
“Java OS”
Java VM
Phone OS
Processor
Steps for running a Java program
“Source
Code”
HelloWorld.java
Execute
program
Java
compiler
javac HelloWorld.java
OS-specific
“Object
Code”
Generic
“Byte
Code”
HelloWorld.class
OS-specific
JVM
java HelloWorld
Structure of Java programs
• Create one or more Java source files
• Compile each source file into a class file
• An application consists of these class files (not a single
file like a .exe)
• To run the program, send one of the class files to
Java
• This entry file must have method called main
public static void main(String[ ] argv)
Sample application
public class HelloWorld {
File: HelloWorld.java
public void greet() {
System.out.println("Hello World!");
}
public static void main(String argv[]) {
HelloWorld hw = new HelloWorld();
hw.greet();
}
}
Java file and class names
• Source code files must have the ".java" extension.
• The file name should match the class name. The
class name should start with a capital letter. This
naming convention is enforced by most reasonable
compilers.
• A file containing
class HelloWorld {…}
must be named HelloWorld.java
• Compiled bytecode has the ".class" extension
Compiling HelloWorld
HelloWorld.java
HelloWorld.class
public class HelloWorld {
public void greet() {
System.out.println("Hello World!");
}
public static void main(String argv[]){
HelloWorld hw = new HelloWorld();
hw.greet();
}
}
javac HelloWorld.java
javac is the Java
Compiler
0xCAFEBABE ...
Executing HelloWorld
HelloWorld.class
java HelloWorld
java is the Java
Virtual Machine
0xCAFEBABE ...
C>java HelloWorld
Hello World!
C>
Object Oriented Programming
• OOP is all about programming using something
called an object.
• Objects are created from classes. An object is
called an instance of a class.
• Objects do useful stuff by calling methods on
them.
• Let’s look at classes and objects in more
detail.
Previously...
public class HelloWorld {
public void greet() {
System.out.println("Hello World!");
}
public static void main(String argv[]) {
HelloWorld hw = new HelloWorld();
hw.greet();
}
}
A Class
class Greeter {
A class will be used
to define how objects
made from this class
will operate
String greeting;
public Greeter(String newGreeting) {
greeting = newGreeting;
}
public void greet(String name) {
System.out.println(greeting + ", " +
name);
}
}
Field
class Greeter {
A class typically will
have one or more fields
which are the data items
which the object holds
String greeting;
public Greeter(String newGreeting) {
greeting = newGreeting;
}
public void greet(String name) {
System.out.println(greeting + ", " +
name);
}
}
A Constructor
class Greeter {
Classes can have Constructors
which contain code only run
when an object is created.
Useful for initialization
String greeting;
public Greeter(String newGreeting) {
greeting = newGreeting;
}
public void greet(String name) {
System.out.println(greeting + ", " +
name);
}
}
A Method
class Greeter {
Once created an object can be
asked to run a "method" which
will do something normally
involving data stored by the object
(plus sometimes data passed in.)
String greeting;
public Greeter(String newGreeting) {
greeting = newGreeting;
}
public void greet(String name) {
System.out.println(greeting + ", " +
name);
}
}
Another Class
This class is just being used to hold
a main method. Here we make two
Greeter objects and use them
class Driver {
public static void main(String args[]) {
Greeter g1 = new Greeter("Hello");
Greeter g2;
g2 = new Greeter("Good morning");
g1.greet("Bob");
C>java Driver
g2.greet("Mary");
Hello, Bob
g1.greet("Sam");
Good morning, Mary
g2.greet("Joan");
Hello, Sam
}
Good morning, Joan
}
C>
OOP
• OOP consists of designing a bunch of classes
most of which are used as templates to make
objects
• The objects are used to hold data
• They are initialized with constructors and
perform useful functions by being asked to run
their methods