No office hours today (EECS faculty meeting) or next Tuesday (Coll. of Engineering Strategic Planning Meeting). If you need to see me, please send email to set up an appointment. Exam II will be Apr. 27. There will be a review session before it (TBA). Artificial Intelligence (AI): Many important programming techniques (including much of OOP) were originally developed for AI, and then found to be useful in other application areas. AI techniques have been exported to other applications. Definition: AI is the art of getting computers to do things that, if they were done by a human, would be considered intelligent. (Some AI researchers complain that as soon as they get computer to do something smart, it's not considered AI any more.) Examples of AI: language use, logic, problem solving, mathematics, playing board games, etc. (In most cases non-human animals cannot do these things, so they were considered especially characteristic of human intelligence.) This is a more application-oriented definition of AI than that provided by, for example, the Turing Test, which considers a definitive test of AI to be that the computer can fool a human into thinking that the computer is a human. Notice that all of these examples of AI are intellectual activities, since these have been considered characteristic of human intelligence. This is what a lot of AI research has concentrated on. Historically AI has neglected other intelligent activities, such as pattern recognition (face recognition), sensory-motor coordination, and many body-centered kinds of intelligence (much of which we share with other animals). All of the above (intellectualist or symbolic approach) is sometimes called GOFAI = Good Old-Fashioned AI. Recently (in the past 20 years), there's been a shift of attention from "thinking machines" to embodied intelligence (which make use of the physical body as an adjunct to what the brain is doing). Part of this change has been the discovery that the higher-level kinds of intelligence build and depend on the lower kinds of intelligence, as a foundation. For example, the manipulation of formulas makes use of some of the same pattern-matching abilities that we use for recognizing physical objects. This is a more bottom-up approach. Newer approaches include connectionism, neural nets, and embodied AI. This chapter presents two examples of GOFAI. We explore how to program playing a board game intelligently. These techniques can be used in many other situations where we're trying to plan the best course of action. Board game playing is a good test case for GOFAI, because it involves intellectual activities like planning, developing strategies, decision making, etc. Tic-tac-toe game: In ch. 10 we have an iterative refinement of the game: (1) Get the program to play the game legally. (2) Get the program to play the game intelligently. We need some sort of representation of the board inside the computer. There are many ways to do this (e.g., 3x3 matrix of characters), but it's simpler in this case to just use a vector of nine characters, in the order: 012 345 678 Nevertheless, it's useful abstraction to give this data type an application oriented name: typedef vector <char> Board; /* This makes "Board" a synonym for "vector <char>" */ How do you tell if there is a winning board position? Remember: "If you pick the right data structure, the algorithm will design itself." In this case, the WINS matrix is used to represent all the winning configurations. // These square triples represent wins (three in a row). int WINS[][3] = {{0, 1, 2},{3, 4, 5},{6, 7, 8}, // the rows {0, 3, 6},{1, 4, 7},{2, 5, 8}, // the columns {0, 4, 8},{2, 4, 6}}; // diagonals You know you can represent a 2D matrix as a vector of vectors. In this case we are representing a 2D matrix as a C-array of C-arrays (we are using C-arrays because they are easier to initialize). The definition means that WINS is a matrix with "enough" rows and 3 columns to hold the initialization data. In this case there are 8 rows. The above declaration in effect declares the matrix: WINS = 012 345 678 036 147 258 048 246 To have a winning configuration, we have to have the same non-blank character (either 'X' or 'O') in board positions WINS[k][0], WINS[k][1], and WINS[k][2], for some k between 0 and 8. Heuristic = a rule of thumb that is not guaranteed to work. In this program evaluate() is the heuristic.