def ModelBasedReflexAgentProgram(rules, update_state):
def program(percept):<EOL><INDENT>program.state = update_state(program.state, program.action, percept)<EOL>rule = rule_match(program.state, rules)<EOL>action = rule.action<EOL>return action<EOL><DEDENT>program.state = program.action = None<EOL>return program<EOL>
This agent takes action based on the percept and state. [Fig. 2.12]