You are on page 1of 80

AI-CODE

z
z
z

AI-CODE

...............................................................................................................................................5
1 ................................................................................................................... 5
2 AI-CODE ................................................................................................................ 5
3 ....................................................................................................................... 8
4 ........................................................................................................ 9
5 ............................................................................................................. 10
6 ................................................................................................................. 11

..................................................................................................................13

......................................................................................................................... 13
................................................................................................................................. 13
1.1 ............................................................................................... 13
1.2 .............................................................................................................. 16
1.3 ................................................................................................... 21
1.4 .............................................................................................................. 22
......................................................................................................................... 22
................................................................................................................................. 23
................................................................................................................................. 24

..........................................................................................................................25

......................................................................................................................... 25
................................................................................................................................. 25
2.1 .................................................................................................................. 25
2.2 .................................................................................................................. 26
2.3 ................................................................................................................... 28
......................................................................................................................... 29
................................................................................................................................. 30
................................................................................................................................. 30

..................................................................................................................................31

......................................................................................................................... 31
................................................................................................................................. 31
3.1 .......................................................................................................... 31
2

3.2 ....................................................................................................... 34
......................................................................................................................... 35
................................................................................................................................. 37

......................................................................................................................38

......................................................................................................................... 38
................................................................................................................................. 38
4.1 ................................................................................................................... 38
4.2 ........................................................................................... 39
4.3 ............................................................................................... 40
......................................................................................................................... 42
................................................................................................................................. 44
................................................................................................................................. 44

..........................................................................................................................45

......................................................................................................................... 45
................................................................................................................................. 45
5.1 .......................................................................................................... 45
5.2 ............................................................................................................... 46
5.3 ........................................................................................................... 50
......................................................................................................................... 52
................................................................................................................................. 52
................................................................................................................................. 52

..................................................................................................................53

......................................................................................................................... 53
6.1 ....................................................................................................... 53
6.2 .......................................................................................................... 56
......................................................................................................................... 58
................................................................................................................................. 59
................................................................................................................................. 59

..................................................................................................................60

......................................................................................................................... 60
................................................................................................................................. 60
7.1 ............................................................................................... 60
3

7.2 ....................................................................................................... 61
7.3 .......................................................................................................... 62
................................................................................................................................. 64
................................................................................................................................. 64

......................................................................................................................65

......................................................................................................................... 65
................................................................................................................................. 65
8.1 ............................................................................................... 65
8.2 ................................................................................................... 67
................................................................................................................................. 68
................................................................................................................................. 68

..............................................................................................................................69

......................................................................................................................... 69
................................................................................................................................. 69
9.1 ............................................................................... 69
9.2 ................................................................................... 70
................................................................................................................................. 73
................................................................................................................................. 74
1 ..............................................................................................................75
2 ..................................................................................................................................76
3 ..........................................................................................................................78

1
AI-CODE

AI-CODE AI-CODE
AI-CODE

AI-CODE

2 AI-CODE
AI-CODE ,

AI-CODE

AI-CODE

AI-CODE

AI-CODE
AI-CODE AI-RCJ

----

CodeCanvas

RoboEXP

CodeCanvas

AI-RCJ
>

expbook
Shooter
Shooter
KickMoveBall

AI-CODE
9

Nikiklaus Wirth

+ =

(1)
(2)

AI-CODE

10

CDelphi, FoxProC

CUNIXDennis RitchieKen Thompson


1970 BC
UNIXMS-DOSMicrosoft WindowsLinuxC
C
C++JavaJavaScriptC#

11

12

1.1
RoboExp-> 1.1

13

1.1

1.2

14


1.2

1.2
JMApp1

FirstPlayer

1.3

1.3

1.4

15

1.4

1.2

1.

2.

16

1.5

1.5

1.6

17

1.6

xy
x y
300300

1.7
x 300 y 300 1.8

18

1.7

1.8

1.9

1.9

300
300

19

20

1.3

F9 1.10

1.10

FirstPlayer

default AI-RCJ ->

F5

21

1.4

300300
(300300)

1200*800
x 600 y 400

22

int mainvoid{}DoMoveTo
300300 main
DoMoveTo300300
main
600400
DoMoveTo300300

23

2
1000750 AI-RCJ

24

AI-RCJ

AI-RCJ
AI-RCJ

(100,100)(400,400)

2.1

25

100100

400400
2.1

MoveStop

2.2

AI-RCJ AI-RCJ
000
0 0
90

26

2.2

xy
100

(100100)

27

2.3
(100100)
AI-RCJ AI-RCJ

10
/ AI-RCJ 10
(100100)
AI-RCJ

50
time 50

(100100) 50

AI-RCJ

28

ANSI(American National Standard


Institute)

29

20
30 ()

50
40

2.3

AI-RCJ

1 100300 150 250100


150
400300V
2 V AI-RCJ

30

3.1
100100
100100

xy 100100100

x y
AttackRobot
31

double ballX ballY

ballX ballY
ballX ballY
double
x ballX
ballX y
ballY
ballX ballY double

xy ballX, ballY
ballX ballY
ballX, ballY

(100, 100 )

100
AttackRobot AttackRobot

-> 3.2

32

3.2

AttackRobot
200ballYCalculateballX=200

xy ballX ballY

Calculate ballX ballX=200


=

CalculateballX 200 ballX ballY


200ballY
33

3.2

KeepAttack

while while
ballX ballY
while x x
ballX y ballY

34

ballX

ballY

3.3

KeepAttack

1.

35

int

long

float

double

char

double double
long

double ballXCalculate
ballX 100 double ballY y
ballY
2
x
y

36

, x y

37

While
For

4.1

z
z
z

38

4.2

>0

JudgeHeading

heading,courtHeight,courtWidth

courtHeight courtWidth
CalculatecourtHeight=courtHeight/2

heading
heading 0
heading 0

.....

If If heading>0
If If

If
39

heading>0

4.3

do
uble double

40

X
0 X
180 0 90
270 360 90 270
JudgeAttack expbook

double
ballX ballY int heading
double ballHeading

heading while
41

while x y
ballX ballY ballHeading
If if if if
If-Else If Else If-Else
If If If If If-Else
If
ballHeading >= 90 && ballHeading <= 270 If
If heading>0

If
If heading>0

1.1
heading>0
>

6
>

<

>=

<=

==

!=

1.2

ballHeading >= 90 && ballHeading <= 270&&

z &&
42

z
z

||

2
If If
If

3
3.1 While
While While

While 4.2

43

4.2

3.2 For
While For
For 100For
100

If If

For

1.

44

5.1
EdgeAttack

45

100750600750
1000750
600750

5.2

EdgeAttack

46

DoMoveOnAttack

->
DoMoveOnAttack

double goalYgoalX

47

double ballX ballY


xy goalX goalY x y
ballX ballY xy
ballX ballY

DoMoveOnAttack AdvancedEdgeAttack
48

DoMoveOnAttack
.rcu AdvancedEdgeAttack
DoMoveOnAttack
DoMoveOnAttack AdvancedEdgeAttack
int heading
DoMoveOnAttack
DoMoveOnAttack

DoMoveOnAttack

DoMoveOnAttack void
DoMoveOnAttack double
goalX goalY

DoMoveOnAttack goalX goalY

1006007501000

49

Half double double


x Return x/2.0 x

Half
Center expbookdouble courtWidth courtHeight
double goalX goalY x y
courtWidth courtHeight
Half courtWidthgoalX courtHeightgoalY
goalX goalY

Center

5.3

JudgeAttack
JudgeDanger
JudgeDanger int int heading
50

double ballHeading
1
1 0

JudgeDanger AdvancedJudgeAttack
JudgeDanger int danger
JudgeDanger double ballX ballY
While JudgeDanger
JudgeDanger danger
danger 1

51

2
AdvancedJudgeAttack shoot
shoot 1
shoot shoot
1

1
2

52

bug

6.1

AI-RCJ

Println
CodeEditor
println
This is a debug output! 6.1

53

6.1

println
printlnThis is a debug output

This is a debug output


6.2

6.2

6.3

54

6.3

():

x>50,

55

6.2
println

x
DebugRobot
x 0 double 6.4

6.4
X x
6.5

56

6.5

6.6

CodeEditorprintlnThe x
value of the robot in the coordinate

d x 6.6
6.7

6.7

6.8

57

6.8

1.
double
printSDprintSD
x double 0
x x
CodeEditorprintSD(the x value of the robot
in the coordinate:x);
x 900.000000the x value of the robot in
the coordinate900.000000
58

59

delay

7.1

AI-RCJ
1
2

60

DoMoveAhead
DoTurnLeftDegrees
DoMoveTo Do
DoMoveAhead(100)
100 100
1 1

8 SetMoveVelocity(8)
8 5

SetMoveVelocity (8) SetTurnVelocity (1)


1

AI-RCJ

AI-RCJ

0,1,2,3.

8 8
8

7.2

AI-RCJ 3

0
61

Circle
While

7.1

7.1

while

7.3

KickMoveBall expbook
ballX double 0
ballY double 0
X Y
X ballX
Y ballY
7.3 7.4
62

7.3

7.4

x ballX
y ballY
7.5

7.5

while
SetMoveTo

SetMoveVelocity

SetTurnVelocity
ballXBallY

while getBallXgetBallY

63

DoMoveTo

SetMoveVelocity

SetTurnVelocity ,
DoMoveAhead

DoTurnLeft

DoMoveTo
SetMoveVelocity
SetTurnVeleocity

DoMoveAhead

DoTurnLeftDoMoveTo
DoMoveAhead
DoTurnLeft
SetMoveVelocity
SetTurnVelocity delay
DoMoveToDoMoveTo

1
SetMoveVelocity
SetTurnVelocity
2
SetMoveVelocity
SetTurnVelocity
3 SetMoveTo
SetMoveVelocitySetTurnVelocity delay

64

8.1

8.1

65

8.1

G1 G2 courtWidth
courtHeight 0,courtHeight/2
courtWidth,courtHeight/2
getCourtWidthgetCourtHeight
getAttack

goalX

double

goalY

double

attackRight

double

66

int

attackRight

If

attackRight>0

double

goalX

double

goalY

Calculate

goalX0

Calculate

goalYgoalY/2

8.2

8.3

getAttack 0
0

8.2
C
8.3

67

8.3

while

1 8.1

2 C

68

9.1
9.1

69

9.1

B A AC
C

9.2

9.1 C C
9.2

9.2
70

C y
y x BC
x x,y

attackRight

double

goalieX

double

goalieY

double

courtWidth

double

Calculate(1)

gap=50+RADIUS+5

Calculate(2)

goalieX=gap

Calculate(3)

goalieY=courtWidth-gap

If

attackRight>0

While

attackRight

courtWidth

goalieY

x:goalieX
y:goalieY
71

9.3

while x x
keepX=gapgap
5
9.4

72

9.4
A x
gap B x gap
Bgap
5 While
y y (goalieX,goalieY)

73

2 y

74

expbook.FirstPlayer

expbook.MoveStop

expbook.AttackRobot
expbook.KeepAttack

expbook.JudgeHeading
expbook.JudgeAttack

expbook.EdgeAttack
expbook.AdvancedEdgeAttack
expbook.AdvancedJudgeAttack

expbook.Println
expbook.DebugRobot

expbook.Circle
expbook.KickMoveBall

expbook.Shooterr

expbook.Goalie

75

1.1

1.2

1.3
1.4
1
2.1
2.2
2.3
2

1
1
2

1
1

1
1
1

1
1
2
1
2
3
4

3.1
3.2
3

4.2

4.3

if

76

AICODE

X
Y

5.1
5.2

5.3
5

6.1
6.2
6

println

7.1

7.2
7.3

Delay

8.1

8.2

9.1
9.2

double

77

If

While

For

Calculate

Continue

Break

Return

CodeEditor

Start

(
)

void DoMoveAhead(double dis);

(
)

void DoMoveBack(double dis);

(
)

void DoMoveTo(double x, double y);

void DoTurnLeft (double angle);

void DoTurnRight (double angle);

angle>0
angle<0

void DoTurn(double angle);

void DoTurnTo (double hea);

void SetMoveVelocity double


velocity;

78

X
Y

X
Y

void SetTurnVelocity(double velocity);

void SetMoveTo(double x,double y)

void SetKickBallTo(double x, double


y);

X
Y

0 0

double GetX();
double GetY();
double GetHeading();
double GetMoveVelocity();
int GetAttack();
double GetSorce();
double GetLose();

X
Y

double GetBallX();
double GetBallY();

double GetBallHeading();

double GetBallVelocity();
double GetCourtWidth(void);
double GetCourtHeight(void);
double GetGoalSize();
int IsHitRobot();
int IsHitWall();
int IsHitBall();

long GetTime();
void DelayTimes(long time);

void PrintLong(long l)
79

void PrintDouble(double d)
void AddLineView(
long showTime, int color,
double beginX, double beginY,
double endX, double endY);
void AddEllipseView(
long showTime, int color,
double xRadius, double yRadius,
int fill, double x, double y);
void AddRectangleView(
long showTime, int color,
double width, double height,
int fill, double x, double y);

double GetDistance(double x1, double


y1, double x2, double y2);

(x1,y1)
(x2,y2)

double GetLineHeading(double
double y1, double x2, double y2);

heading base

double GetBearing(double
double base);

angle

double Sin(double angle)

angle

double Cos(double angle)

angle

double Tan(double angle)

angle

double Asin(double angle)

angle

double Acos(double angle)

angle

double Atan(double angle)

80

x1,

heading,