IT114107留学生辅导、讲解Software留学生、Java编程调试、辅导Java
- 首页 >> Java编程 Hong Kong Institute of Vocational Education
Department of Information Technology
Higher Diploma in Game Software Development (IT114107)
Year 2 Semester TWO
(2018/19)
ITP4712 Logical and Artificial Intelligence in Games
ASSIGNMENT
Due Date: 15 April 2019
Robocode
Robocode is a Java programming game, where the goal is to develop a robot battle tank to battle
against other tanks. The robot battles are running in real-time and on-screen. The motto of Robocode
is: Build the best, destroy the rest!
In this assignment, you are required to build some Robocode robots to accomplish different tasks.
You will also need to have a design document on each robot you made.
TASK 1
Design a Chasing Robot using Finite State Machine Approach
In this task, you will need to model a robot as a Finite State Machine that chases and attacks 2 target
Robots of “lessons.Evader” until they died. Your robot should have at least FIVE different states
apart from the initial state. You may divide the states into sub-states if you want to. Here are some
state suggestions:
Finding a new Target (Find the target evader)
Finding previous Target (find the old target after avoiding an obstacle or wall)
Chasing the Target (going towards the target’s predicted future location)
Avoiding the Walls (turn away from the wall before it is too near)
Obstacle Avoidance (turn away from the obstacle (sitting ducks) before hitting it)
You can add other states to improve your robot. Your robot will use its senses (radar or hit events)
(i.e., onScannedRobot(),onBulletHit(), onHitByBullet() and etc.) and its own attributes (e.g.,
getBattleFieldWidth(), getBattleFieldWidth(), getX(), getY(), getOthers() and etc.) as the
condition of state transition. Your robot needs to consider the current status of battlefield and other
enemies to apply different strategies, such as, when to state away from others and when to apply
melee. You may also need to apply guessing and/or calculation to make your robot more robust.2
Your current state can be stored as an instance variable. Try using switch case statement in your
run() method. Each case represents the action for each state of your robot. The state transition should
be triggered by the onXXX() methods and/or inside your run() method when you are checking your
robot’s status.
While your robot is chasing the targets, it may also encounter obstacles (10 sample.SittingDuck
robots). You will need to figure some ways to avoid destroying the obstacles (not to shoot and ram
the obstacles intentionally, accidental shot at obstacles will not result in mark deduction) and try to
chase the target after passing the obstacle.
You may use direct line of sight technique in chasing your robot, but you will get extra marks if you
use the interception technique in this robot in additional to chasing.
Deliverables:
- A diagram representing the state transition of the robot.
- A brief description of the states and transition.
- A brief description how your robot avoids the obstacle and locks the same target while passing
the obstacle.
- The robot’s java file. You should try your best to implement the robot as the state machine
designed by yourself. Marks will be deducted if the robot does not implement as designed.
TASK 2
Design a group of Flocking Robot using TeamRobot class
In this task, you will need to model a robot using TeamRobot class. 10 units of your robot will form
a team in a battlefield. For the shooting and scanning part, the robot will turn its radar to scan for
enemies, turn its gun and shoot the scanned enemies (remember to avoid shooting at your
teammates!!). For the robot’s movement, it will continuously broadcast its name, location and
moving direction to the teammates using the boardcastMessage() method in your run() method. The
Serializable message can be a String object or any other Serialzable object. A Serialzable object is
created from a class that implements java.io.Serialzable and consists of attributes that can be written
to file only (Serialzable).
The messages will be received by the method onMessageReceived() method of TeamRobot class.
The sender and the message itself can be retrieved by the methods event.getSender() and
event.getMessage(). You will need to update the lists of locations and directional vectors of your
teammates inside your own robot. Inside your run() method, you need to broadcast your location and
direction; and then use the lists of others locations and directions to update your robot movement
according to the flocking rules. The robot should continue to move forward while avoiding collision
with wall if it is not influenced by other flocking units. 3
void broadcastMessage(Serializable message)
Broadcasts a message to all teammates.
void onMessageReceived(MessageEvent event)
This method is called when your robot receives a message from a teammate.
String[] getTeammates()
Returns the names of all teammates, or null there is no teammates.
boolean isTeammate(String name)
Checks if a given robot name is the name of one of your teammates.
Deliverables:
- A brief description how your robots use/calculate the cohesion, alignment and separation to form
a flock.
- The robot’s java file.
TASK 3
Design a Robot to Fight with your Classmates
In this task, you are free to use whatever approach to implement your robot. The ultimate goal is to
defeat all other robots made by your classmates to earn bonus. If you do not have enough time to
implement this part in your project, you may use the same robot in Task 1 or 2; but make sure you
have renamed the robot and the package before you hand in.
During the battle with your classmates, sampleSentry.BorderGuard robots will be added into the
battle mix. These BorderGuards will try to locate and attack the robots located in the sentry border
area (default size: 100 pixels from the walls). Robots outside the sentry border area will not get any
HP reduction even if it is hit by the BorderGuard bullets. On the other hand, your robots will not get
any bonus HP by hitting these BorderGuards. To avoid wasting HP on attacking BorderGuards, you
should use the method isSentryRobot()in ScannedRobotEvent class to check if the scanned
enemy is a BorderGuard and you should skip attacking it. Also, you may like to keep away from the
border area – to check the width of the border area, you can use getSentryBorderSize()inside
your Robot class.
Deliverables:
The robot’s java file. You can have any reasonable name for your robot, but the name of the package
of your robot must be your s+studentID, e.g., “s171819201”. If you need to have other supporting
classes to run your robot, you also need to submit the source code of such files, under the same
“s+studentID” package.4
Instructions to Students
1. The weighting of this assignment is 40% of Continuous Assessment.
2. This assignment is an individual assignment and each student has to submit his/her own work.
Plagiarism is a serious offence and any assignments that involve any plagiarism will be given
ZERO marks. The award of Zero marks will apply to all parties, regardless of whether or not a
student is the original author or the plagiarist. Further disciplinary action will follow.
3. All work is to be submitted through Moodle on or before 9:00 am on Monday 15 April 2019.
Late submission without valid reasons may be given ZERO marks.
4. You should use J2SDK 1.8.0 or above and Robocode 1.9.3 or above to develop the programs.
5. Your programs must follow the coding standard stated in Java coding standard published by Sun
Microsystems. Marks will be deducted if the coding standard is not followed.
6. You are required to hand in your deliverables in different tasks following these instructions:
Each task should have its own folder (Task 1, Task 2 and sXXXXXXXX, where
XXXXXXXXX is your student ID).
In each folder, it should contain the robot Java source code (the robot itself and all
supporting class you have written) and a Word document containing the written report as
described in each task (for Tasks 1 and 2 only).
The four folders should be zipped into a single zip file and submit to Moodle.
You must have one individual robot for each of your tasks; even if you want to use your
robot in Task 1 or 2 to join the competition in Task 3.
Students who do not have the folder for any task will be considered as forfeiting the mark
for that task.
7. Marks:
Task 1 max 45 marks
Design (with documentation) 10 marks
State Machine Implementation 10 marks
Chasing Implementation 10 marks
Obstacle and Wall Avoidance 10 marks
Efficiency 5 marks
Interception Bonus extra 5 marks
Task 2 35 marks
Design (with documentation) 10 marks
Implementation 25 marks
Task 3
Fighting against classmates’ robots 20 marks
(You will get some marks even you lost all battles)
Total 100 marks
Department of Information Technology
Higher Diploma in Game Software Development (IT114107)
Year 2 Semester TWO
(2018/19)
ITP4712 Logical and Artificial Intelligence in Games
ASSIGNMENT
Due Date: 15 April 2019
Robocode
Robocode is a Java programming game, where the goal is to develop a robot battle tank to battle
against other tanks. The robot battles are running in real-time and on-screen. The motto of Robocode
is: Build the best, destroy the rest!
In this assignment, you are required to build some Robocode robots to accomplish different tasks.
You will also need to have a design document on each robot you made.
TASK 1
Design a Chasing Robot using Finite State Machine Approach
In this task, you will need to model a robot as a Finite State Machine that chases and attacks 2 target
Robots of “lessons.Evader” until they died. Your robot should have at least FIVE different states
apart from the initial state. You may divide the states into sub-states if you want to. Here are some
state suggestions:
Finding a new Target (Find the target evader)
Finding previous Target (find the old target after avoiding an obstacle or wall)
Chasing the Target (going towards the target’s predicted future location)
Avoiding the Walls (turn away from the wall before it is too near)
Obstacle Avoidance (turn away from the obstacle (sitting ducks) before hitting it)
You can add other states to improve your robot. Your robot will use its senses (radar or hit events)
(i.e., onScannedRobot(),onBulletHit(), onHitByBullet() and etc.) and its own attributes (e.g.,
getBattleFieldWidth(), getBattleFieldWidth(), getX(), getY(), getOthers() and etc.) as the
condition of state transition. Your robot needs to consider the current status of battlefield and other
enemies to apply different strategies, such as, when to state away from others and when to apply
melee. You may also need to apply guessing and/or calculation to make your robot more robust.2
Your current state can be stored as an instance variable. Try using switch case statement in your
run() method. Each case represents the action for each state of your robot. The state transition should
be triggered by the onXXX() methods and/or inside your run() method when you are checking your
robot’s status.
While your robot is chasing the targets, it may also encounter obstacles (10 sample.SittingDuck
robots). You will need to figure some ways to avoid destroying the obstacles (not to shoot and ram
the obstacles intentionally, accidental shot at obstacles will not result in mark deduction) and try to
chase the target after passing the obstacle.
You may use direct line of sight technique in chasing your robot, but you will get extra marks if you
use the interception technique in this robot in additional to chasing.
Deliverables:
- A diagram representing the state transition of the robot.
- A brief description of the states and transition.
- A brief description how your robot avoids the obstacle and locks the same target while passing
the obstacle.
- The robot’s java file. You should try your best to implement the robot as the state machine
designed by yourself. Marks will be deducted if the robot does not implement as designed.
TASK 2
Design a group of Flocking Robot using TeamRobot class
In this task, you will need to model a robot using TeamRobot class. 10 units of your robot will form
a team in a battlefield. For the shooting and scanning part, the robot will turn its radar to scan for
enemies, turn its gun and shoot the scanned enemies (remember to avoid shooting at your
teammates!!). For the robot’s movement, it will continuously broadcast its name, location and
moving direction to the teammates using the boardcastMessage() method in your run() method. The
Serializable message can be a String object or any other Serialzable object. A Serialzable object is
created from a class that implements java.io.Serialzable and consists of attributes that can be written
to file only (Serialzable).
The messages will be received by the method onMessageReceived() method of TeamRobot class.
The sender and the message itself can be retrieved by the methods event.getSender() and
event.getMessage(). You will need to update the lists of locations and directional vectors of your
teammates inside your own robot. Inside your run() method, you need to broadcast your location and
direction; and then use the lists of others locations and directions to update your robot movement
according to the flocking rules. The robot should continue to move forward while avoiding collision
with wall if it is not influenced by other flocking units. 3
void broadcastMessage(Serializable message)
Broadcasts a message to all teammates.
void onMessageReceived(MessageEvent event)
This method is called when your robot receives a message from a teammate.
String[] getTeammates()
Returns the names of all teammates, or null there is no teammates.
boolean isTeammate(String name)
Checks if a given robot name is the name of one of your teammates.
Deliverables:
- A brief description how your robots use/calculate the cohesion, alignment and separation to form
a flock.
- The robot’s java file.
TASK 3
Design a Robot to Fight with your Classmates
In this task, you are free to use whatever approach to implement your robot. The ultimate goal is to
defeat all other robots made by your classmates to earn bonus. If you do not have enough time to
implement this part in your project, you may use the same robot in Task 1 or 2; but make sure you
have renamed the robot and the package before you hand in.
During the battle with your classmates, sampleSentry.BorderGuard robots will be added into the
battle mix. These BorderGuards will try to locate and attack the robots located in the sentry border
area (default size: 100 pixels from the walls). Robots outside the sentry border area will not get any
HP reduction even if it is hit by the BorderGuard bullets. On the other hand, your robots will not get
any bonus HP by hitting these BorderGuards. To avoid wasting HP on attacking BorderGuards, you
should use the method isSentryRobot()in ScannedRobotEvent class to check if the scanned
enemy is a BorderGuard and you should skip attacking it. Also, you may like to keep away from the
border area – to check the width of the border area, you can use getSentryBorderSize()inside
your Robot class.
Deliverables:
The robot’s java file. You can have any reasonable name for your robot, but the name of the package
of your robot must be your s+studentID, e.g., “s171819201”. If you need to have other supporting
classes to run your robot, you also need to submit the source code of such files, under the same
“s+studentID” package.4
Instructions to Students
1. The weighting of this assignment is 40% of Continuous Assessment.
2. This assignment is an individual assignment and each student has to submit his/her own work.
Plagiarism is a serious offence and any assignments that involve any plagiarism will be given
ZERO marks. The award of Zero marks will apply to all parties, regardless of whether or not a
student is the original author or the plagiarist. Further disciplinary action will follow.
3. All work is to be submitted through Moodle on or before 9:00 am on Monday 15 April 2019.
Late submission without valid reasons may be given ZERO marks.
4. You should use J2SDK 1.8.0 or above and Robocode 1.9.3 or above to develop the programs.
5. Your programs must follow the coding standard stated in Java coding standard published by Sun
Microsystems. Marks will be deducted if the coding standard is not followed.
6. You are required to hand in your deliverables in different tasks following these instructions:
Each task should have its own folder (Task 1, Task 2 and sXXXXXXXX, where
XXXXXXXXX is your student ID).
In each folder, it should contain the robot Java source code (the robot itself and all
supporting class you have written) and a Word document containing the written report as
described in each task (for Tasks 1 and 2 only).
The four folders should be zipped into a single zip file and submit to Moodle.
You must have one individual robot for each of your tasks; even if you want to use your
robot in Task 1 or 2 to join the competition in Task 3.
Students who do not have the folder for any task will be considered as forfeiting the mark
for that task.
7. Marks:
Task 1 max 45 marks
Design (with documentation) 10 marks
State Machine Implementation 10 marks
Chasing Implementation 10 marks
Obstacle and Wall Avoidance 10 marks
Efficiency 5 marks
Interception Bonus extra 5 marks
Task 2 35 marks
Design (with documentation) 10 marks
Implementation 25 marks
Task 3
Fighting against classmates’ robots 20 marks
(You will get some marks even you lost all battles)
Total 100 marks