NVartolomeiRobot robot by Nicolae Vartolomei nvartolomei gmail com Cop

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
*
* NVartolomeiRobot - a robot by Nicolae Vartolomei <nvartolomei@gmail.com>
* Copyright (c) 2009 All rights reserved.
*
* @package ore
* @version 0.1 beta
*/
package nv;
import robocode.*;
//import java.awt.Color;
/**
* Clasul SysNv care reprezinta robotul creat
* extinde clasa Robot in care sunt declarate functiile de baza.
*/
public class SysNv extends Robot
{
/**
* run: SysNv robot default actions
*/
public void run() {
/**
* Ciclu infinit care se executa atita timp cit robotul e viu.
*/
while(true) {
doMove();
doRadarScan();
}
}
public void doMove() {
ahead(100);
}
public void onHitWall(HitWallEvent e) {
turnRight(20);
}
/**
* onScannedRobot (radar detected robot)
*/
public void onScannedRobot(ScannedRobotEvent e) {
setAdjustGunForRobotTurn(true);
setAdjustRadarForGunTurn(true);
double radarDirection, gunDirection, toTurnOn;
radarDirection = getRadarDirection();
gunDirection = getGunHeading();
toTurnOn = radarDirection-gunDirection;
turnGunRight(toTurnOn);
if (e.getDistance() < 100) {
fire(3);
} else {
fire(1);
}
}
/**
* Scaneaza perimetrul.
*/
public void doRadarScan() {
turnRadarLeft(10);
}
/**
* Intoarce directia radarului in grade fixe.
*/
public double getRadarDirection() {
return getRadarHeading();
}
/**
* Functie care face robotul ca sa danseze,
* imitind citeva miscari.
*/
public void letsDance() {
int i, max;
max = 10;
i = 0;
do {
i++;
turnLeft(10);
turnLeft(10);
turnRight(10);
turnRight(10);
} while (i<max);
turnRight(360);
turnLeft(360);
}
/**
* onHitByBullet (bullet hited robot)
*/
public void onHitByBullet(HitByBulletEvent e) {
}
}