Anda di halaman 1dari 5

COMP222 ASSIGNMENT 2 ROBOCODE

Ruijiao Li 200750658 Email:sgrli@liv.ac.uk

Artificial Intelligence Computer Science Department, University of Liverpool

INTRODUCTION

My robot battle behaviour is designed with behaviour Tree model. The tank robot behaves by
different states. In the modelling, there are three main factors, gun, radar, body motivation.
The enemies` motivation and attack can be tracked by radar and get the event during the
battle. When the radar catches the information, the body and the gun generate associated
action. When the robot moves in the battle field, it needs to avoid wall and other robot, so the
robot should to take action when the distance is too small. When the enemies attack, the radar
can get the energy changing and be aware of the attacks and get to avoid the bullets. Different
events can cause the corresponded behaviour. In order to win, the robot should behave is to
survive and attack enemies. That is to move avoid collision with wall and other tanks and get
out of the enemies bullets area, get precise aiming and hit more. There is learning method to
help the robot to be smarter. The robot can write a log file to store the statistics of battle and
analyse the enemies` behaviour and configure the strategies. The Virtual Bullet technology
can make the robot ain precisely. Before launch a bullet, the robot can generate virtual bullets
to different direction and if it hit the enemy, sent a bullet to it, if not, change the direction and
sent another. If there are many robots in the battle field, my robot can use anti-gravity method
to get to the low power and less robots area. To make the robot can avoid collision with the
wall, a factor is used to act precise when it near the wall.

ROBOT DESIGN

The following figure is the behaviour tree of my robot.

1
The robot I designed can behaviour as the figure shows. The body, radar and gun can move
independently. The body need move to avoid hit enemy, hit wall, be hit by bullets. When
there is a single enemy, it will circumnavigate the enemy and if
the enemy stop sending bullet and moving, go ahead to it.
When there are multiple enemies, the robot will avoid stronger
first and get out of hot area. The robot body motivation
direction and gun ahead composes an angle, there can
effectively avoid attack when shooting. To avoid the wall
more, I use a factor to adjust the distance of wall and robot.

The radar has been set to work precisely. When the robot move and if there is a single enemy
at front, the radar keep scan that enemy and virtual bullet will help radar work. When there
are more than one enemies, the radar scans around and get the information and move to safe
area to take action of shooting.

The virtual bullet can be regarded as a radar. The robot sent virtual bullet and get the
direction and position of an enemy and the gun will be adjust to shooting accurately.

2
I have designed a feature for the robot to learn with the battle, it creates statistics of battle the
battle can robot will analyse the information and improve the behaviour.

ROBOT IMPLEMENTATION

The robot project contains the following class:

 A200750658.java
 VirualBullet.java
 TrackEnemy.java
 BotUil.java
 BattleStatus.java
1. VirtualBullet.java
This class create a virtual bullet for the robot to test the aiming. It include three
methods
public static double getComVal(Object o,Object o2,double
dir)
Created a virtual bullet and launch it in particular direction.
public void test(Point2D.Double enemyPoint,long time)
Test the virtual bullet and examine if it hit the enemy.
Public static double getAngle(Point2D.Double
p2,Point2D.Double p1)
The angle the gun will configure when the virtual bullet miss the target.
2. TrackEnemy.java
This class is to collect the information of an enemy.
3. BotUtil.java
This class contains some useful method with can make it convenient to calculate
some data such as the angle, direction, bearing, distance.
4. BattleStatus.java
This class is used to collect the battle information and write it in the local file.
public void Initialise()
initialise a format for write text
public void EndRound
the write strategy of the battle information.
public void Print()

3
write the information
5. A200750658.java
This class is the robot behaviour class. It contains the controller of gun, body and
radar.
Run()
Run() method is to start a thread for the tank robot. Robot properties are set here. The
print progress is called. Turn radar follows the virtual bullet.
public void onBulletHit(BulletHitEvent e)
Get the event when the enemy is hit by bullet
public void onHitByBullet(HitByBulletEvent e)
Get the event when my robot is hit by others

public void onHitRobot(HitRobotEvent e)


Get the event when my robot hit others.
public void onScannedRobot( ScannedRobotEvent e )
Scan the battle field and get the information of enemy and walls and take action
Put the enemies` information in a hashtable.
Put the virtual bullet in a vector.
public void moving()
This is the method for motivation of my robot body. When my robot is near the
enemy, keep around enemy, keep enemy be 90 angle bearing me. This can easy to
avoid the enemy`s attack. If my robot is away from others, take random
circumnavigate it. If there is many enemies or bullet within an area, get out of it and
set ahead to the safe area.

public void aiming()


The strategy of aiming is to use virtual bullet find the enemy around my robot and
pattern the appropriate direction to launch bullet to enemy. When the virtual bullet hit
the robot turn the gun, if not, adjust the angle to make the gun aim it.
public void onRobotDeath(RobotDeathEvent e)
get noticed when an enemy die.
public void reverseDirection()
reverse direction of the robot
private double adjustHeadingForWalls
adjust the robot head against the wall

public void setTurnLeftRadiansOptimal(double angle)


Optima the robot turn to make it turn precise.

4
Reference:

http://www.ibm.com/developerworks/library/j-robotips/index.html

http://www.ibm.com/developerworks/java/library/j-dodge/

http://www.ibm.com/developerworks/library/j-fwa/index.html

http://old.robowiki.net/robowiki?VirtualBullets

http://old.robowiki.net/robowiki?action=browse&id=Wave&oldid=Waves

Anda mungkin juga menyukai