程序代写案例-COMP717-Assignment 2

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
Paper Code: COMP717
Artificial Intelligence
Lecturer: Ji Ruan
Assignment 2
Due Friday, 4 June 2021
Name ........................................ ID number..........................
Instructions:
Please attach this sheet to the front of your assignment.
• This assignment contributes 50% towards your final grade. The total mark is 100.
• Choose one of the options A or B and submit an electronic copy through Blackboard before 11:59 p.m.
on Friday, 4 June 2021. The submission requirement is specified at the end of each option.
• In option A: you can team up with another student. If you work as a team, both students should
sign this page, but only one submission is needed.
• In option B: it must be an individual work.
The School of Computer and Mathematical Sciences regards any act of cheating including plagiarism, unau-
thorised collaboration and theft of another student’s work most seriously. Any such act will result in a mark
of zero being given for this part of the assessment and may lead to disciplinary action.
Here is a quote from Richard Feynman, a well known scientist, “The first principle is that you must not
fool yourself and you are the easiest person to fool.”
Please sign to signify that you understand what this means, and that the assignment is your own work.
Signature: ........................................
1
Option A: Tiger vs. Dogs in GDL
The aim of this assignment is to develop your ability of formalising abstract concepts and enhance your
understanding of logical reasoning in General Game Playing.
Game Description
Here is a very ancient game originated from China: Tiger vs. Dogs.
In the above 5 × 5 board, there are one tiger (represented by a white stone in the center) and 16 dogs
(represented by black stones in the perimeter).
The tiger is controlled by the tiger player and the dogs are controlled by the dog player. The tiger player
goes first and then they take turns. Each player can go one step along the line to an adjacent position that
is not occupied.
When the tiger enters a position such that the following condition hold “two dogs are adjacent to this
position such that they three are in the same line, and also these two dogs have no adjacent dogs in the
same line”, then these two dogs are killed by the tiger. If 6 dogs are killed, then the tiger player wins and
the dog player loses.
When the dogs surrounded the tiger such that there is no unoccupied adjacent position for the tiger to
move, then the tiger player loses and the dog player wins.
Task 1 (20 Marks)
Describe this game mathematically (Refer to lecture slides). Here are some key points:
(a) The set of game states S. Give your estimation of the number of different states. (4 marks)
Hint: take the Tic-Tac-Toe for example, a state can be described using,
• 9 variables of Cell(1,1), Cell(1,2), Cell(1,3), Cell(2,1), Cell(2,2), Cell(2,3), Cell(3,1), Cell(3,2),
Cell(3,3), with possible values x, o, b to represent if cell is marked by xplayer, oplayer or is blank.
• 1 variable of control, with possible values xplayer and oplayer, to represent which player is in control
e.g., for the initial state, s0, it can be described as 〈 Cell(1,1)=b, Cell(1,2)=b, ... , Cell(3,3)=b, con-
trol=xplayer 〉
A very rough estimation of the number of states for Tic-Tac-Toe is: 39 × 2, because for each of 9 cells,
it has 3 possible values, and the control variable has 2 possible values. But you could be more precise
by removing some impossible states (the states are not reachable from the initial state), e.g.,
〈 Cell(1,1)=x, Cell(1,2)=x, Cell(1,3)=x, Cell(2,1)=o, Cell(2,2)=o, Cell(2,3)=o, Cell(3,1)=b, Cell(3,2)=b,
Cell(3,3)=b, control=xplayer 〉
In the above state both xplayer and oplayer have formed 1 line of their own markings, but this is not
possible as once one player manages to get 1 line of its own marking, then the game is over.
2
(b) Players P = {1, 2}. You may use 1 to represent the tiger player and 2 the dog player. Feel free to use
your own version. (0 marks)
(c) Actions A. You may use abstraction to get as few types of actions as possible. (4 marks)
Hint: use A1 for the tiger player, and A2 for the dog player. A = A1 ×A2.
Just list all possible actions for each player, e.g., you can use left as one action for tiger player. Note
that for a particular state, it is not necessary all actions are possible.
(d) Transition function S × A → S. This function is huge. What we ask you to present is not the entire
function but the effects of actions you described in (c) on different games states, in a general way, e.g.,
you may just select a few representative ones to describe. This serves the foundation of Task 2.
(6 marks)
Hint: You can just use the following format:
give a state s, and players’s joint action (a1, a2), then give the resulting state s
′.
(e) Terminal states and utilities.
Hint: When a game terminates, it is either because the tiger is captured or 6 dogs are killed. So describe
the conditions on a terminal state using the state representation you give in (a).
You may use a few representative ones to illustrate.
(6 marks)
To help you to understand this game, here are a few examples:
Example:
When the dog makes the move by red arrow, the tiger is 

surrounded.
Example:
When the tiger makes the move by red arrow, the marked two
dogs are killed.
Example:
When the tiger makes the move by red arrow, the marked two
dogs are killed.
Example:
When the tiger makes the move by red arrow, the marked two
dogs are not killed because there is a dog in the same line that
is next to dog 2 (as marked).
1 2
Task 2 (80 Marks)
(a) Write a game description in GDL (KIF form) for this game. Note that this involves in making the
concepts developed in Task 1 into GDL. The transition function in Task 1 is now succinctly represented
as a set of logical rules. Your GDL should be annotated for better readability, especially the new
predicates that you’ve created. Have a clear separation of the following sections: (60 Marks)
3
• Roles and the initial states;
• Legal moves;
• State transitions (next rules);
• Terminal conditions;
• Utilities (goal).
(b) Test and debug your game description using the game controller (refer to tutorials) to ensure that it
runs correctly. (20 Marks)
http://sourceforge.net/projects/ggpserver/files/gamecontroller/
In your submission, you need to include at least two execution traces generated by the game controller
with both players using the random type.
Extra marks (up to 10) will be given if you are able to do something extra, e.g., classifying and
visualising the transition function in 1(d) and the traces in 2(b). These extra marks can make up your loss
in other parts of this assignment. The total mark is capped at 100.
Submission
You can team up with a classmate to work on this assignment. One submission per team.
You are required to provide
(1) Your solution to Task 1,
(2) Your GDL file for Task 2(a), and
(3) Your test results for Task 2 (b).
We prefer that (1) and (3) are included in a single PDF file. Your submission should including everything
in a zip file with the following format: AI2021A2A-XY.zip, where XY is your student ID(s). The submission
is via Blackboard.
(Note that you might be able to find some online discussions on this problem, but you have to write your
own GDL code. )
4
1
Option B: Fuzzy Logic Control
This must be your individual work.
1. Your task is to implement a simple washing machine time controller based on the amount of dirt
and type of dirt on clothes. There are two input variables and one output variable. First, open
Matlab and enter ‘fuzzy’ in the Command Window.
2. The amount of dirt is specified by the following membership functions for ‘small’,
‘average/medium’ and ‘large’. Enter these membership functions using the graph in Figure 1 as a
guideline. You don’t have to be entirely accurate with respect to the figure below. You will need to
pay attention to the type of membership function and the range. You can interpret the range as a
percentage:
Figure 1: Membership functions for amount of dirt
3. The type of dirt is specified by the following membership functions for ‘not greasy’, ‘medium
greasy’ and ‘greasy’ (Figure 2). You can interpret the range as a percentage:
Figure 2: Membership functions for type of dirt
2
4. The wash time (output variable) has five membership functions (‘very short’, ‘short’, ‘medium’,
‘long’ and ‘very long’. You can interpret the range as minutes. You can specify your own output
membership function ranges if you are not happy with these below (Figure 3), but make clear in your
report what you have done.
Figure 3: Membership functions for wash time
5. The full set of rules for deriving output is:
1. If dirtiness_of_clothes is Large and type_of_dirt is Greasy then wash_time is VeryLong;
2. If dirtiness_of_clothes is Medium and type_of_dirt is Greasy then wash_time is Long;
3. If dirtiness_of_clothes is Small and type_of_dirt is Greasy then wash_time is Long;
4. If dirtiness_of_clothes is Large and type_of_dirt is Medium then wash_time is Long;
5. If dirtiness_of_clothes is Medium and type_of_dirt is Medium then wash_time is Medium;
6. If dirtiness_of_clothes is Small and type_of_dirt is Medium then wash_time is Medium;
7. If dirtiness_of_clothes is Large and type_of_dirt is NotGreasy then wash_time is Medium;
8. If dirtiness_of_clothes is Medium and type_of_dirt is NotGreasy then wash_time is Short;
9. If dirtiness_of_clothes is Small and type_of_dirt is NotGreasy then wash_time is VeryShort
6. Once you have implemented this fuzzy logic controller, answer the following questions:
Question set A:
(a) What is the rule surface for the system? Do you see any discontinuities? Are you happy with the
surface?
(b) What is the wash time, in minutes, for the following loads?
(i) Dirtiness=70; Type=50.
(ii) Dirtiness=0; Type=50.
(iii) Dirtiness=100; Type=100.
(iv) You have clothes that are 100% greasy. What is the minimum length of wash irrespective of
amount of dirt?
3
(v) You have clothes that are 100% dirty. What is the minimum length of wash irrespective of type of
dirt?
7. You will now add Temperature of water as a third input variable to your controller. The general
principle is: the colder the water, the longer the wash. So, the hotter the temperature, the less time
the wash. You can assume that water temperature has a range from 20 degrees C to 60 degrees C.
Add the following:
• A third input variable called ‘Temperature’;
• Three membership functions for ‘Temperature’: cold; warm; hot. You can specify these three
membership functions any way you wish (as triangular, trapezoidal, Gaussian…).
• Add at least one ’And’ rule involving all three antecedents Dirtiness, Type and Temperature,
with one rule consequent for Wash Time.
• Add at least one ‘Or’ rule involving all three antecedents Dirtiness, Type and Temperature,
with one rule consequent for Wash Time
• Add at least one rule using the ‘not’ option in the Rule Editor. You can use as many
antecedents as you wish (minimum one).
After you have implemented the third input variable Temperature as specified above, answer the
following questions:
Question set B:
(c) How plausible or intuitively correct are your added rules?
(d) What is the shape of your new rule surface and how does it compare with your previous rule
surface?
(e) What is the wash time for the following loads?
(v) Maximum amount of dirt, maximum greasiness, hottest water.
(vi) Maximum amount of dirt, maximum greasiness, coldest water.
8. Write a report consisting of 5 pages maximum (longer reports will be penalized by a direct
subtraction of 1% for every extra line over 5 pages). The report is to be structured as follows (after
your ID number at the top of the page):
• Part A: Membership function descriptions for each of your two input and one output
variable; answers to Question Set A.
• Part B: membership function description for your third input variable (water temperature);
answers to Question Set B;
• Part C: your conclusion and lessons learnt (if you could start the assignment again, would
you do anything differently?)
Submit your report in a single PDF file, with the following format AI2021A2B-yourID.PDF
An example report will be made available to you to help you construct your own report.
The marksheet for this assignment is on the next page.
(Note: this assignment is based on material taken from
http://softcomputing.tripod.com/sample_termpaper.pdf )
4
Marksheet for Artificial Intelligence Coursework – Assignment 2B (Fuzzy
Logic Controller)
1. Introduction and background to fuzzy logic controller architecture (20 marks)
2. Fuzzifier: Description, justification and explanation of input and output variables
membership functions (20 marks)
3. Inference engine and defuzzification: Description, justification and explanation (20
marks)
4. Simulations and example outputs: Description, presentation and explanation (20
marks)
5. Evaluation and conclusion (20 marks)
Marker’s summary of Assignment 1 (total mark out of 100 for assignment 2 which
will be converted to a mark out of 50 when calculating your overall paper mark):
Name:
Student Number:

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468