Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
CSIT5900 2024-25 Fall Semester Assignment #1
Date assigned: Thursday, Sep 19, 2024
Due time: 23:59pm on Thursday, Oct 3, 2024
How to submit it: Submit your written answers as a pdf file on canvas.ust.hk. Submit your code for the last three programming questions as a zip file named YourStudentID.zip
Penalties on late papers: 20% off each day (anytime after the due time is considered late by one day)
Problem 1. (10%) Consider a 10x10 grid without any obstacles, and a robot with the same specification as our boundary following robot: eight sensors and four actions. Design a reactive production system to control the robot to go to one of the four corners, wherever its initial position is. Write a production system just for this task without calling the boundary following production system in the lecture note.
Problem 2. (10%) Which boolean function does the following TLU implement? The TLU has five inputs. Its weight vector is (1.1, 3.1, −1, −2, 0.5), and the threshold is 1. Give your answer as a boolean expression using the connectives “x + y” (x or y), “xy” (x and y), and “x” (not x).
- What’s your fitness function?
- What’s your crossover operator?
- What’s your copy operator?
- What’s your mutation operator, if you use any?
- What’s the size of the initial generation, and how are programs generated?
- When do you stop the evolution? Evolve it up to a fixed iteration, when it satisfies a condition on the fitness function, or a combination of the two?
- What’s the output of your system for the provided training set gp-training-set.csv in assign1-data27.zip (for Python 2.7) or assign1-data3.zip (for Python 3)?
The Pacman Game
Figure 1: The smallMap map
Environment Setup
Perception and Movement
The Pacman has eight sensors in eight directions: northwest, north, northeast, east, south east, south, southwest, and west. The sensor will return 1 if there is a wall in its direction, and 0 otherwise. You can use the getPacmanSensor function of the GameState class to get the list of return values of the sensors in the order described above. For example, if the getPacmanSensor function returns (s1, s2, ...s8) =[0, 0, 1, 1, 1, 0, 0, 0], it means that there are three walls in the northeast, east and southeast of the Pacman.
Figure 2: The testMap map
The movement of an agent is controlled by the getAction function, which is supposed to return one of the five actions at each step: NORTH, SOUTH, EAST, WEST and STOP. Open reactiveAgents.py to see the implementation of the NaiveAgent: it always returns WEST until it sensed that there is a wall on its west.
Below the NaiveAgent class in reactiveAgents.py, you will see the ECAgent class, which has also been implemented for your reference. The PSAgent is an agent that moves according to the production system we discussed in the lecture. You may run the agent in the smallMap map for the expected behaviour of the boundary following task.
Problem 4. (Programming) (25%)
In this problem, you are required to implement ECAgent, which is a boundary-following agent that uses the Error-Correction procedure to learn the action functions for the task.
Task
You are required to learn a perceptron for each of the actions using the Error-Correction procedure. You can use any programming language for training the perceptrons. You should initialize their weights to all 0 and use learning rate = 1.
- Give the boolean expression that corresponds to your perceptron for the move north action. (5%)
- Use your learned perceptrons to implement the ECAgent in reactiveAgent.py in this way: if exactly one of them outputs 1, then do the respective action; if more than one of them output 1, then use the following order: prefer going north, followed by east, south, and west; and finally if none of them outputs 1, then go north. (20%)
Marking Scheme
Notes
- If you have no experience with UNIX or Python before, please go through this tutorial first: http://ai.berkeley.edu/tutorial.html, which uses Python 2.7. You should be able to apply it to Python 3 as well.
- The program may also work in Windows but you will need to handle some dependency issues.
- There will be no tight spaces (see lecture slides for definition) in the test cases. (note that the testMap map is an instance of tight spaces)
- The order that your agent visits the foods does not matter.
- If your agent made an invalid move (e.g. move towards the wall), the program will throw an exception and exit. Be careful!
Problem 5. (Programming) (25%)
Task
The SMAgent can remember the previous action prevAction and the previous sensory input prevSense. The initial state of the SMAgent has been implemented for you.
To finish this task, you do not need any additional data member other than prevAction and prevSense. You are required to use getPacmanImpairedSensor instead of getPacmanSensor and we will disable the getPacmanSensor when we test the SMAgent.
- Complete the getAction function of the SMAgent. We will test your agent with four maps like the Problem 4.(20%)
- Denote ( ˜s2, s˜4, s˜6, s˜8), to be the previous sensory input and (N, E, S, W) to be the one-hot encoding of the the previous action. For example, if the previous action is moving north, then (N, E, S, W)=[1,0,0,0]. Can we train perceptrons on the feature vector (s2, s4, s6, s8, s˜2, s˜4, s˜6, s˜8, N, E, S, W, d) with the Error-Correction procedure as in the Problem 4? (5%)