Artificial Intelligence Intelligent Agents Chapter 2 & 27 What is an Agent? An intelligent agent perceives its environment with sensors and acts upon that environment through actuators 2 Examples of Agents Human agent Eyes, ears, skin, taste buds, etc. for sensors Hands, fingers, legs, mouth, etc. for actuators Powered by muscles Robot Camera, infrared, bumper, etc. for sensors Grippers, wheels, lights, speakers, etc. for actuators Often powered by motors Software agent Functions as sensors Information provided as input to functions in the form of encoded bit strings or symbols Functions as actuators Results deliver the output 3 1
Agents and Environment sensors environment percepts actions actuators? agent 4 Agents and Environment An agent perceives its environment through sensors The complete set of inputs at a given time is called a percept The current percept, or a sequence of percepts may influence the actions of an agent It can change the environment through actuators An operation involving an actuator is called an action Actions can be grouped into sequence of actions 5 Agent Program The agent function (f) maps from percept histories to actions: f : P * A The agent program is a concrete implementation of the respective function that runs on the physical architecture to produce f 6 2
Vacuum-Cleaner World Percepts: location and contents, e.g. [ [A, Dirty] Action: Left, Right, Suck, NoOp 7 A Vacuum-Cleaner Agent Percept sequence [A, Clean] [A, Dirty] [B, Clean] [B, Dirty] [A, Clean], [A, Clean] [A, Clean], [A, Dirty]... Right Suck Left Suck Right Suck Action function REFLEX-VACUUM VACUUM-AGENT AGENT ([location, status]) returns an action if status = Dirty then return Suck else if location = A then return Right elseif location = B then return Left 8 A Vacuum-Cleaner Agent Percept sequence [A, Clean] [A, Dirty] [B, Clean] [B, Dirty] [A, Clean], [A, Clean] [A, Clean], [A, Dirty]... Right Suck Left Suck Right Suck Action What is the right function to fill out the table? Can it be implemented in a small agent program? 9 3
How Should an Agent Act? A rational agent does the right thing! What is the right thing to do? The action that is most successful How should we measure how successful the agent is? We measure what we want, not how the agent should act? 10 How Should an Agent Act? A rational agent does the right thing! A performance measure is needed to say how successful a task has been achieved Rational agents try to maximize success 11 Performance of Agents Criteria for measuring the outcome and the expenses of the agent Often subjective, but should be objective Task dependent Time may be important 12 4
Performance Evaluation Examples Vacuum agent Number of tiles cleaned during a certain period Based on the agent s report, or validated by an objective authority Doesn t consider expenses of the agent, side effects Energy, noise, loss of useful objects, damaged furniture, scratched floor Might lead to unwanted activities Agent re-cleans clean tiles, covers only part of the room, drops dirt on tiles to have more tiles to clean, etc. 13 Rational Agent Considerations Performance measure for the successful completion of a task Complete perceptual history (percept sequence) Background knowledge Especially about the environment dimensions, structure, basic laws Task, user, other agents Feasible actions Capabilities of the agent 14 Ideal Rational Agent For each possible percept sequence, a rational agent should select an action that is expected to maximize its performance measure, given the evidence provided by the percept sequence and whatever built-in in knowledge the agent has 15 5
How Can We Know the Best Choice? One has to be omniscience to completely know! Impossible! A rational agent is not omniscient It doesn t know the actual outcome of its actions It may not know certain aspects of its environment 16 How Can We Know the Best Choice? Base decision on what is known until now! Rationality takes into account the limitations of the agent Percept sequence, background knowledge, feasible actions It deals with the expected outcome of actions 17 Task Environment (PEAS) How should we measure success? Performance What does the physical surrounding look like? Environment How can the agent effect the environment? Actuators How can the agent perceive the environment? Sensors 18 6
Task Environment (PEAS) Performance: Used to evaluate how well an agent solves the task at hand Environment: Surroundings beyond the control of the agent Actuators: Determine the actions the agent can perform Sensors: Provide information about the current state of the environment 19 Environment Properties Fully observable vs. partially observable An environment is fully observable if the agent is provided with full knowledge about the state of the world Sensors capture all relevant information from the environment Deterministic vs. stochastic (non-deterministic) An environment is deterministic if the next state of the world is completely determined by the current state and the agent s actions Changes in the environment are predictable Randomness and chance cause stochastic environments 20 Environment Properties Episodic vs. sequential (non-episodic) An environment is episodic if each percept-action episode does not depend on the actions in prior episodes independent perceiving-acting episodes Driving a car or playing a game are sequential Static vs. dynamic An environment is static if it doesn t change between the time of perceiving and acting no changes while the agent is thinking Time is an important factor in dynamic environments, since percepts are timesensitive and can become obsolete 21 7
Environment Properties Discrete vs. continuous An environment is discrete if there are a limited number of distinct, clearly-defined percepts and actions Single vs. multiple agents Solving a crossword puzzle is clearly a single agent environment Playing chess, driving a car, working with other robots to assemble a product are all multi-agent Some competitive and some cooperative multi-agent environments 22 Environments In practice there is often uncertainty due to partially observable, stochastic, and dynamic environments 23 Structure of Intelligent Agents Agent = Architecture + Program Architecture Operating platform of the agent computer system, specific hardware, possibly OS functions Program Function that implements the mapping from percepts to actions Emphasis in this course is on the program aspect, not on the architecture 24 8
Types of Agent Programs There are several kinds of agent programs which try to meet these conditions: Lookup table Simple reflex agent Model-based reflex agent Goal-based agent Utility-based agent Can be turned into learning agents 25 Lookup Table Map percepts to actions explicitly (An agent based on a prespecified lookup table. It keeps track of percept sequence and just looks up the best action) For interesting problems, the table would be too big to generate and store Not adaptive to changes in the environment; entire table must be updated if changes occur Matches only the current percept doesn t track its history Takes long time to build the table 26 From Table to Simple Agent Instead of a table, a simple function may also be used Can be conveniently used to describe simple agents that solve well-defined problems in a well-defined environment e.g. calculation of mathematical functions 27 9
Simple Reflex Agent Use if-then rules to match certain percepts to an action No need to consider all percepts Can generalize percepts by mapping them to the same action Can adapt to changes in the environment by adding new rules Reacts only the current percept still doesn t track its history 28 Simple Reflex Agent sensors Condition - action rules What the world is like now What action I should do now Actuators Environment function SIMPLE-REFLEX REFLEX-AGENT( AGENT(percept) returns action static: rules,, a set of condition-action rules state INTERPRET-INPUT INPUT (percept( percept) rule RULE-MATCH (state,rules( state,rules) action RULE-ACTION [rule[ rule] return action A simple reflex agent works by finding a rule whose condition matches the current situation (as defined by the percept) and then doing the action associated with that rule. 29 Simple Reflex Agent Table lookup of condition-action pairs defining all possible condition-action rules necessary to interact in an environment e.g. if car-in in-front-is-breaking then initiate breaking Problems Table is still too big to generate and to store (e.g. taxi) Takes long time to build the table No knowledge of non-perceptual parts of the current state Looping: Can t make actions conditional 30 10
Model-Based Reflex Agent Internally encode state (maintain a model) of the world based on past percepts and prior knowledge Actions can be based on a sequence of percepts; knowledge of non-perceptual world state Must be able to represent change in the world 31 Model-Based Reflex Agent State sensors How the world evolves What my actions do Condition - action rules What the world is like now What action I should do now actuators Environment 32 Model-Based Reflex Agent function REFLEX-AGENT AGENT-WITH-STATE (percept( percept) returns action static: state,, a description of the current world state rules,, a set of condition-action rules action,, the most recent action, initially none state UPDATE-STATE (state,( action, percept) rule RULE-MATCH (state,( rules) action RULE-ACTION [rule[ rule] return action A model-based reflex agent with internal state works by finding a rule whose condition matches the current situation (as defined by the percept and the stored internal state) and then doing the action associated with that rule. 33 11
Goal-Based Agent Actions chosen to reach a desired goal Goals help decide which actions are good Deliberative instead of reactive May have to consider long sequences of possible actions before deciding if goal is achieved: what will happen if I do this? (Search & Planning) More flexible than reflex agent. (e.g. rain/new destination) In the reflex agent, the entire database of rules would have to be rewritten 34 Goal-Based Agent State sensors How the world evolves What my actions do Goals What the world is like now What it will be like if I do action A What action I should do now actuators Environment 35 Utility-Based Agent Choose which alternative is best When there are multiple possible alternatives, how to decide which one is best? Utility function gives a measure of success or goodness for a given state Allows decisions comparing choice between conflicting goals, and choice between likelihood of success and importance of goal (if achievement is uncertain) A goal specifies a crude destination between a happy and unhappy state, but often need a more general performance measure that describes degree of happiness 36 12
Utility-Based Agent State sensors How the world evolves What my actions do Utility What the world is like now What it will be like if I do action A How happy I will be in such as a state Environment What action I should do now actuators 37 Learning Agents If the agent can learn then we will get more powerful agents 38 Performance standard Learning Agents Critic Sensors feedback learning goals Learning element changes knowledge Performance element Environment Problem generator Agent Actuators 39 13
Are We Going in the Right Direction? Perfect rationality Calculative rationality Bounded rationality Bounded optimality 40 What If We Succeed? What if you were right? AI is fascinating, and intelligent computers are clearly more useful than unintelligent computers, so why worry? We can expect that medium-level successes in AI would affect all kinds of people in their daily lives Computerized communication networks (cell phones and the Internet) - pervasive effect on society Useful personal assistants for the office or the home would have a large positive impact on people's lives - cause some economic dislocation A technological capability - applied to the development of autonomous weapons - an undesirable development Finally, it seems likely that a large-scale success in AI-would change the lives of a majority of humankind 41 What If We Succeed? AI systems could pose a more direct threat to: human autonomy, freedom, and even survival Therefore, cannot divorce AI research from its ethical consequence But so far AI seems to fit in with other revolutionary technologies (printing, plumbing, air travel, telephony) whose negative repercussions are outweighed by their positive aspects 42 14
Summary The problem solver A program OR The whole machine (a robot) Ideal rational agents: Always acts to maximize its performance measure, given its percepts and built in knowledge. The agents behavior can be viewed as mapping from percepts to actions We can t always look up the best action from a table of this mapping: ping: Complexity (chess: 35^100 lines in the table) 43 Summary Features of Environments Fully vs. partially observable Deterministic vs. stochastic Episodic vs. sequential Static vs. dynamic Discrete vs. continuous Single vs. multi-agent 44 Summary An agent perceives and acts in an environment to achieve specific goals Types of agents: Lookup table Simple reflex agent Model-based reflex agent Goal-based Utility-based 45 15
Summary Reflex agents Without internal states: if <percept> then <action> With internal states (memory): if <state> and <percept> then <action> Goal based agents Specify a goal and compute or search for action that lead to the goal: if f(<state>, <action>) then <action> Utility-based agents Specify one or several goals and combine them into a real number through the utility function. Select the actions which leads to the highest utility value 46 Next Time Solving Problem by Searching! 47 16