C463/B551/I400 Artificial Intelligence
Dana Vrajitoru

C463/B551/I400 Homework 3

Due date: Wednesday, September 17, 2025.


Intelligent Agents

In this homework, we will explore the idea of simple reflex agents.


Ex. 1 Write a function called lifeAgent(thisAgent, prev, next) based on the model of simple reflex-based agent that implements a linear variation of the game of life. Here is a demo of the game of life:

https://academo.org/demos/conways-game-of-life/

Consider that the environment (world) is a list of integer numbers. The agent can perceive one element of the list at a time (thisAgent) and its closest neighbors left and right. The agent at position 0 also considers the agent at the end of the list as its neighbor and the other way around, so that each agent has 2 neighbors. The number to be examined is the one in the middle. This observation will result in the following conditions:

You must implement two additional functions. One of them tests the three numbers and returns the state, called interpret(n1, n2, n3), that takes the percept (the agent number and the two neighbors) and returns one of the 3 states (for now we can call them 1, 2, or 3). The second one called takeAction(n1, n2, n3, state), must take as parameters the three numbers and the state, perform the appropriate action, and return the result. The agent function must call these two functions and return the new value for the agent to be stored in the list as a result of the action function.

Add a test function where you input a size for the world from the user and a number of iterations. In this function, generate a list of that size containing random integers between 0 and 100. Then run the life function for that number of iterations, displaying the results in each iteration.

A function for playing the game of life on the whole list called nlife provided in the file
agent1.py

You can always add more functions to your program if you think it's necessary.

Complete the implementation by adding your functions to the file agent1.py. The file also contains a test example for the agent function to write.


Ex. 2 Design an agent acting as a spam filter. Describe the environment, the perception, the actions that it can take. Specify which type of agent it is (table based, reflex, etc.). Show a few examples of rules used by the agent function. If the agent has a learning component, what would it entail?

This part should be in pseudocode/plain English in a separate file (text or word doc).


Turn in: the updated file agent1.py and the file for the second exercise.