Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMPSCI 761

Assignment 3

due Sunday 29 October 2023

Due: by 11:59pm on the due date. Late assignments will not be marked.

Total mark: 10.

Worth: This assignment counts towards 10% of your final mark.

Background:

The Legend of Zelda is an epic fantasy serial of action-adventure video games.  It has been worldwide renowned for more than 35 years. The story happens in an ancient Kingdom called Hyrule. The series of games centre on the various incarnations of Link, a courageous knight of the kingdom, and Zelda, a magical princess of the kingdom.  They fight together to save Hyrule from Ganon, a devil that wants to destroy the kingdom.  At the end of each game of the series, Link uses a legendary sword, master sword, to defeat and seal the devil Ganon and successfully save the kingdom.

Now, consider the following scenario:  Princess Zelda is locked up by Ganon in a castle.  To save Zelda, Link must beat Ganon and open the castle ’s gate.  But he cannot beat Galon without the master sword.  This scenario is abstracted into a 3×4 grid world.  Initially, Link is at (1, 1), master sword at (3, 1), Ganon at (2, 2), and three gates at (1, 3), (2, 3) and (3, 3).  Each time step, Link can take an action from the following options:

.  Move to an adjacent grid.  (Note that Link cannot move across the gate without opening it.)

Description: Link will be at the next grid.

.  Pick up the master sword.

Description: Link will be with the sword.

. Attack Ganon.

Description: Ganon will be defeated if Link is with the master sword and is at the same grid as Ganon.

.  Open the gate.

Description: The corresponding gate will be opened if Ganon is defeated and Link is at the same grid as the gate.

The initial state is illustrated in the following figure.

The goal of Link is to reach the location of Zelda.

Questions

1.  [5 marks]

(a) Write a PDDL domain file monkey domain.pddl that specifies the four action schemas: Move, Pick, Attack and Open.  (Note: Each time Link can only move to a neighbour grid)

(b) Write a PDDL problem file monkey task.pddl that specifies the initial state and the goal.

2.  [5  marks] Implement a Q learning algorithm to solve the Zelda problem.  You are requested

to complete the function Q update() function in the attached Python source file zelda.py.

Notes:

.  See the Python source for detailed instructions and explanations

. Your code will run multiple times when testing. As long as the output path of one run is a valid solution (not necessarily optimal, i.e., rigorously maximising cumulative rewards), you will get full marks.

. Do NOT modify the other part of the code

. Your code may be checked for plagiarism