The
team at Robot Soccer Simulator Inc. would like to thank the many people who
have helped in putting this program together. First and foremost we would
like to thank John Thornton for his patience, help and invaluable knowledge
in helping us understand technical aspects of the Yujin Robots. Without the
time and effort he spent with us many of physical aspects of the simulated
robots would have missed their mark by a mile. With his help, we have, hopefully,
achieved as close to the actual characteristics of the Yujin robots as electronically
possible.
We
would also like to thank Moon, Dr Jun Jo, Michael Pagano, Anthony, Greg Cranitch,
Karen Noller (in no particular order) and any other academic staff that we
may have forgotten, for their time, patience and humor in dealing with us
and our Robots.
The
Robot Soccer Simulator developed by the RSS Development team is for the exclusive
use of the client and has been issued without any express or implied warranties
including, but not limited to, the implied warranties of merchantability or
fitness for a particular purpose. The entire risk as to the quality and performance
of the data, software or services supplied is with the client. Should the
data, software or service prove defective, you assume the cost of all necessary
servicing, repair or correction. In no event unless required by applicable
law will the RSS Development Team, be liable to you for damages, including
any lost profits, lost monies, or other special, incidental, exemplary or
consequential damages arising out of the use or inability to use the data,
software or services provided by the RSS Development Team.
The
use of this software is also meant for those with a background or some understanding
of the applicable technologies. It is expressly suggested that all individuals
meaning to develop this program further or develop strategies of their own
have a working knowledge of Director and its programming language, Lingo.
Programming of strategies is covered in this manual, however it is assumed
that the user has knowledge in Lingo and the basic understanding of object
orientated programming in general. The design of this program was meant as
an engine for others to develop strategies on, and as such, the programming
team itself does not yet begin to comprehend the endless possible ways of
programming the robots. The team does, however, provide the basic building
blocks to develop strategies, some that are required and other suggestions
based on our research and testing to date.
Robot
soccer, a high-tech scientific sport, was developed by professor Jong-Hwan
Kim of KAIST (Korean Institute of Technology) in October of 1995 as a multi
purpose testing ground for learning and application of high-tech technology
field such as image analysis, artificial intelligence, sensors, communication,
electronic precision control, drive motors as well as software and hardware.
Since then and until now it has grown steadily as more and more young scientists
participate.
The
first international robot soccer world cup, which can be referred to as the
formal event for robot soccer, was held in KAIST in November of 1996, and
the second was played in June of 1997 at the same venue.
Only
after three years since the birth of robot soccer in June 5th 1997 an international
robot soccer federation composed of 34 countries (FIRA: Federation of International
Robot-soccer Association) was founded. After the official inauguration of
the FIRA all international matches where called "FIRA Robot World Cup.
Also
as the enthusiasm for FIRA international world cup competition is growing
every day and now that robot soccer has made its mark, it will expand into
a high calibre international science competition.
The
concept and purpose behind The Robot Soccer Simulator is to simulate the
physical workings of the Yujin Robots in every possible way in an electronic
cyber-based environment. The intended end uses of The Robot Soccer Simulator
include the development of strategies that can be used on the physical Yujin
Robots in future FIRA Robot World Cup competitions, and the start of a new
cyber-based FIRA World Cup. Any other applications that come out of the development
of this program are a welcome bonus to the design team.
It is recommended that The Robot Soccer Simulator be run on a computer of equal or greater specs than the following:
Pentium
III 600 MHz
256 megabytes of ram
TNT2 3d Graphics accelerator with 32 megabytes of ram
24x CD-ROM
Screen resolution of 800 x 600
16 bit Sound card
Microsoft Windows 98
Direct X 8.0
10 megabytes of free hard drive space
To install
The Robot Soccer Simulator insert the game CD into your CD-ROM, the autorun
screen will then appear. Click on Install and it will launch the installation
program. Choose the location on your hard drive that you would like the program
to be installed to and click continue. We suggest that all users install the
program to the C drive. Once installation is complete a program group will
be added to the start bar called Robot Soccer Simulator and an Icon will
be placed on the desktop.
To launch the
game simply double click on the icon on your desk top or go to your start
menu and under programs find the Robot Soccer Simulator program group and
click on the icon within.
--Before Start
of Play and During Stoppage of Play
ฌ key
is used to rotate a selected robot counter clockwise.
ฎ key
is used to rotate a selected robot clockwise.
--During Replay
in Stop Frame
ฌ key
is used to go back a single frame.
ฎ key
is used to go forward a single frame.
Upon starting
The Robot Soccer Simulator you will be presented with the following screen:
Figure 1
The field is
displayed, along with the menu bar and game information.
The user can
select robots to place in positions on the field for the start of play, instructions
on this will be covered in Starting Play.
The user can click on anything on the menu bar to open a list of options.
This menu is also shown when there is a stoppage of play and the referee must
call fouls and make decisions.
Below the menu
is the amount of time that has been played and below that is the score.
Figure 2 |
|
|
Strategies are written either in lingo code and placed in a text file
or in a C++ DLL. These are then placed in their correct places as described
below before use. How to code the strategies is discussed in Programming
guide.
|
|
Should the time or score need to be changed for any reason, the referee can use this interface to make adjustments.
|
Figure 6
|
|
|
The view bar, located on the right of the replay screen is where the user selects what view point they want to use while viewing a replay.
G. & H. Both choose different side views, one with the blue goal on the left and the yellow on the right and the other with the blue goal on the right and the yellow goal on the left. |
Figure 8 |
|
To get a game
started is quite simple and can be done by following the following steps.
During play you can use the menus to take action. To go to the replay click on the replay button, to stop the game for penalties, change of time or score, calling a penalty kick etc, click the stop button, and you will be shown all of the menus. If you wish to pause play for any reason simply click the pause button.
|
|
Blue Team
Back
|
|
|
B1 is the global variable for this robot in the strategy. Its position can be obtained from the dot syntax as B1.pos.x and B1.pos.y. Its rotation can be obtained from the dot syntax as B1.rot.z By default this robot is the goalie and its position is in the goal. |
|
B2 is the global variable for this robot in the strategy. Its position can be obtained from the dot syntax as B2.pos.x and B2.pos.y. Its rotation can be obtained from the dot syntax as B2.rot.z By default this robot is in a defending position however this position can be changed. |
|
B3 is the global variable for this robot in the strategy. Its position can be obtained from the dot syntax as B3.pos.x and B3.pos.y. Its rotation can be obtained from the dot syntax as B3.rot.z By default this robot is in a defending position however this position can be changed. |
|
B4 is the global variable for this robot in the strategy. Its position can be obtained from the dot syntax as B4.pos.x and B4.pos.y. Its rotation can be obtained from the dot syntax as B4.rot.z By default this robot is in an attacking position however this position can be changed. |
|
B5 is the global variable for this robot in the strategy. Its position can be obtained from the dot syntax as B5.pos.x and B5.pos.y. Its rotation can be obtained from the dot syntax as B5.rot.z By default this robot is in an attacking position however this position can be changed. |
Yellow Team Back |
|
|
Y1 is the global variable for this robot in the strategy. Its position can be obtained from the dot syntax as Y1.pos.x and Y1.pos.y. Its rotation can be obtained from the dot syntax as Y1.rot.z By default this robot is the goalie and its position is in the goal. |
|
Y2 is the global variable for this robot in the strategy. Its position can be obtained from the dot syntax as Y2.pos.x and Y2.pos.y. Its rotation can be obtained from the dot syntax as Y2.rot.z By default this robot is in a defending position however this position can be changed. |
|
Y3 is the global variable for this robot in the strategy. Its position can be obtained from the dot syntax as Y3.pos.x and Y3.pos.y. Its rotation can be obtained from the dot syntax as Y3.rot.z By default this robot is in a defending position however this position can be changed. |
|
Y4 is the global variable for this robot in the strategy. Its position can be obtained from the dot syntax as Y4.pos.x and Y4.pos.y. Its rotation can be obtained from the dot syntax as Y4.rot.z By default this robot is in an attacking position however this position can be changed. |
|
Y5 is the global variable for this robot in the strategy. Its position can be obtained from the dot syntax as Y5.pos.x and Y5.pos.y. Its rotation can be obtained from the dot syntax as Y5.rot.z By default this robot is in an attacking position however this position can be changed. |
In your strategy the minimum that you must include just to be able to move the robots is to declare the global variables of the robots for your team, for instance, in the Blue team b1,b2,b3,b4,b5, or for the Yellow team Y1,Y2,Y3,Y4,Y5. You must also include ball in the list of global variables to be able to access its position in the game. You should also include Global FTop,FBot,FrightX Global FLeftX,GTopY,GBotY These are useful to reference positions on the field.
You may also
include 2 new variables, Game
WhosBall can have 1 of 3 values:
For the robots to access their
positional values you would use .x and .y. The syntax for accessing B1s (robot
1) positional values is b1.pos.x or b1.pos.y and to access its rotational
value b1.rot.z. The ball is accessed differently. It has only positional
values so you access it with ball.x or ball.y no pos or rot definition is
required. The field positions FTop,FBot,FrightX Global
FLeftX,GTopY,GbotY only contain an x or y coordinate.
Ftop
is the y coordinate for the top of the field that is the wall closest to the
top of your screen.
Fbot
is the y coordinate for the bottom of the field that is the wall closest to
the bottom of your screen.
FrightX
is the x coordinate for the right wall of the field that is the wall closest
to the right side of your screen
FLeftX
is the x coordinate for the Left wall of the field that is the wall closest
to the Left side of your screen
GtopY
is the y coordinate for the opening of the goal closest to the top of the
screen for either goal
Gbotx
is the x coordinate for the opening of the goal closest to the bottom of the
screen for either goal.
If you wanted to determine
the xy position of the top corner of the right hand goal you would use FrightX
for the x position and GtopY for the y coordinate.
To describe a point at the
centre of the right hand goal youd use the x position as FrightX and the
y coordinate would be (GtopY-GbotY)/2. Any position on the field can now be
determined by referencing relative to these positions. Although the field
dimensions are the same as the five a side robot soccer competition these
values are in inches and you need to develop a centimetres function by multiplying
these values by 2.54 to use them as centimetres. In future releases of the
robot soccer simulator this function will be included. For now you may create
a centimetres handler
On cm(cmValue)
cmValue=cmValue*2.54
return cmValue
End
Next you must create the handler "on StrategyY"
or on "StrategyB" , depending on which is your team (blue or yellow).
This handler is called by the game sixty times a second. In order to move
any of the robots you must call the handler "velocity". This handler
is built into the game and controls the physical forces applied to the robots.
This handler accepts three arguments
Any other handlers
you include must be called from within "on StrategyY" or "on
Strategy B" for instance if you had a strategy called mystrategy that
called a number of other handlers you could either rename mystrategy to
on strategyY
or on strategyB or simply call it from on strategyY or on strategyB.
Your strategy will be included in the game as a Lingo script so all
Lingo handlers and functions
are at your disposal.
NOTE: The variables and handlers for the blue and yellow teams should begin with b or y respectivly global i may used as a counter but it's value should not be altered.
Comments
are in blue.
An explanation for each section
of the template strategy code is located at the end and is described and explained
in detail.
--Blue----
--Strategy
Line
1:
Global B1,B2,B3,B4,B5,Ball
Line
2: Global FTop,FBot,FRightX
Line
3: Global FLeftX,GTopY,GBotY
Line
4: on strategyY
Line
5: Goalie(B1)
Line
6: Attack1(B2)
Line
7: Attack2(B3)
Line
8: Defend1(B4)
Line
9: Defend2(B5)
--------------------------
Line
10: end strategyY
Line
11: on Goalie(whichBot)
Line
12: vl=0
Line
13: vr=0
Line
14: Velocity(whichBot,vl,vr)
Line
15: end Goalie
Line
16: on Attack1(whichBot)
Line
17: vl=0
Line
18: vr=0
Line
19: Velocity(whichBot,vl,vr)
-------------------------
Line
20: end Attack1
Line
21: on Attack2(whichBot)
Line
22: vl=0
Line
23: vr=0
Line
24: Velocity(whichBot,vl,vr)
-------------------------
Line
25: end Attack2
Line
26: on Defend1(whichBot)
Line
27: vl=0
Line
28: vr=0
Line
29: Velocity(whichBot,vl,vr)
-------------------------
Line
30: end Defend1
Line
31: on Defend2(whichBot)
Line
32: vl=0
Line
33: vr=0
Line
34: Velocity(whichBot,vl,vr)
-------------------------
Line
35: end Defend2
---------------------------------------------------------
This analysis is done line
by line for the code above
Global
B1,B2,B3,B4,B5,Ball
These global
variables can be considered to be your vision system. B1 B5 contain the
positional and rotational coordinates for each of the blue teams robots in
terms of their x and y coordinates and their z rotation. Y1 Y5 contain the
positional and rotational coordinates for each of the yellow teams robots
in terms of their x and y coordinates and their z rotation. The global variable
Ball contains only the positional coordinates of the ball in terms of its
x and y coordinates. These global variables are declared at the very top of
the strategy script in accordance with Lingo procedure.
Global
FTop,FBot,FRightX
Global
FLeftX,GTopY,GbotY
These global
variables only contain the values (i.e. a number) for these constants (positions
on the field). No dot syntax is required. That is you can reference GtopY
simply using its name unlike the robots whose position would be referenced
using b1.pos.x or b1.pos.y.
Ftop
is
the y coordinate for the top of the field that is the wall closest to the
top of your screen.
Fbot
is
the y coordinate for the bottom of the field that is the wall closest to the
bottom of your screen.
FrightX
is
the x coordinate for the right wall of the field that is the wall closest
to the right side of your screen
FLeftX
is
the x coordinate for the Left wall of the field that is the wall closest to
the Left side of your screen
GtopY
is
the y coordinate for the opening of the goal closest to the top of the screen
for either goal
Gbotx
is
the x coordinate for the opening of the goal closest to the bottom of the
screen for either goal.
These global
variables are declared at the very top of the strategy script in accordance
with Lingo procedure.
on
strategyY
This handler
must be part of your strategy as it is automatically called from within
the robot soccer simulator sixty times a second. This handler will control
the entire
strategy
for your team by calling your custom handlers. We have provided some example
names below.
Goalie(B1)
Attack1(B2)
Attack2(B3)
Defend1(B4)
Defend2(B5)
The five custom
handlers above will each control the behaviour of a robot team member. You
do not have to name your custom handlers exactly the same as the five above
this is just an example. These handlers would be called within on strategyY
or on strategyB, the bracketed alphanumeric digits (B1, B2, B3, B4, B5)
ascribe the handler controls to a specific robot. This digit would be passed
to the velocity handler in the form of an element for the variable whichbot.
on
strategyY
This handler
must be called in your strategy. This is the hook that The Robot Soccer Simulator
uses to read and understand your strategy. It can be in the form of on strategyY
for the yellow team, as above, or on strategyB for the blue team.
NOTE:If
you do not include this handler then your strategy will not work.
on
Goalie(whichBot)
vl=0
vr=0
This is a template
for your custom goalie handler. You may control the goalie robot by entering
values between 0 and 125 for the vl and vr variables.
In the case
above if vl = 125 and vr = 125 then the goalie robot would move at maximum
speed in whichever direction he is pointing at the time.
If you wish
the goalie to move in a particular fashion when certain conditions are met
then you would create further custom handlers within this on Goalie handler
to perform the required actions. This subject is dealt with in the example
strategy below.
Velocity(whichBot,vl,vr)
This handler
must be included in every custom handler. It is a black box into which the
robots delimiter - Y1, and the values for vl and vr are fed, from here the
custom handler on Goalie controls the specific robot movements depending
on the satisfaction of determinant conditions.
end
Goalie
This ends your
on Goalie custom handler within the strategy.
on
Attack1(whichBot)
vl=0
vr=0
This is a template
for your custom attacker handler. The firstl ine defines the custom handler
and an argument (whichbot) for its operations. The second and third lines
are values for the speed of the robot wheels. You may control one of
your attack robots by entering values between 0 and 125 for the vl and vr
variables.
In the case
above if vl = 50 and vr = 30 then the attack robot would do a circle at medium
speed in the direction of the highest amount i.e. vl = 50. If you wish the
speed and the direction of the robot to be conditional then further custom
handlers defining these conditions would be included in the on Attack custom
handler
Velocity(whichBot,vl,vr)
This handler
must be included in every custom handler. It is a black box into which the
robots delimiter B2, (or any robot you choose) and the values for vl and
vr are fed. From here the custom handler on Attack1 controls the specific
robot movements depending on the satisfaction of determinant conditions that
will be defined by further custom handlers within this custom handler.
Now that we have described
the general characteristics of a strategy script we will delve into the creation
of custom handlers that would be included within on Goalie on Attack1
and on Attack2, and on Defend1 and on Defend2. These will allow the
movement of the robots to be controlled within handlers that are called.
Comments are in blue.
An explanation for each section of
the example strategy code is located at the end and is described and explained
in detail.
--StrategyB---------------------
---Blue team global
variables--
Line
1: global
b1,b2,b3,b4,b5,ball
--------------------
Line
2: on
strategyB
---(robots can be
controled directly)
Line3:
velocity(B1, 125, 125)
Line4:
velocity(B2, -125, -125)
--- (or controled
using handlers)
Line5:
goReallyFast(B3)-
Calls the goReallyFast handler below and passes B3 as its argument -------------------------
Line6:
goBackFast(B4) -
Calls the goBackFast handler below and passes B4 as its argument -------------------------
Line7:
circle(B5) -
Calls the circle handler below and passes B5 as its argument -------------------------
Line8:
end strategyB
---Handlers(similar
to functions)
Line9:
on goReallyFast(whichBot)
Line10:
vl = 125
Line11:
vr = 125
Line12:
velocity(whichBot, vl,
vr)
Line13:
end goReallyFast
------------------
Line14:
on goBackFast(whichBot)
Line15:
vl = -125
Line16:
vr = -125
Line17:
velocity(whichBot, vl,
vr)
Line18:
end goBackFast
---------------------
Line19:
on circle(whichBot)
Line20:
vl = 60
Line21:
vr = 30
Line22:
velocity(whichBot, vl,
vr)
Line23:
end circle
The required global variables
of robot names and ball are first instantiated. These must be in place or
your strategy will not work. These should be at the beginning or your strategy
script.
This handler must be included
in your strategy or the script will not work.
Line3:
velocity(B1, 125, 125)
These two lines of code call
the velocity handler. The speed of B1 and B2 are being directly controlled.
Commas must separate the alphanumeric digits within the brackets. The first
pair of digits nominate which robot is to be controlled by the handler, B1
B5 : the global variables which were instantiated at the very top of your
strategy script.
Line5:goReallyFast(B3)
This line of code shows the
handler goReallyFast being passed the name of one of the robots, B3. goReallyFast
is an imaginary handler which we have used here to indicate how a robot can
be controlled by a handler rather than simply directly with velocity on its
own in on strategyB. For example in this handler the condition may be if
the ball is directly in front of me and I am facing the goal of the opposing
team then vl = 125 & vr = 125. (This is not how you would write the code
merely an explanation of the logic).
Line6:goBackFast(B4)
This line of
code shows the handler goBackFast being passed the name of one of the robots,
B2. goBackFast is an imaginary handler which we have used here to indicate
how a robot can be controlled by a handler
rather than simply directly with
velocity on its own in on strategyB. For example in this handler the condition
may be if the ball is directly behind me and I am facing away from the opponents
goal then vl = -125 & vr = -125. (This is not how you would write the
code merely an explanation of the logic)
Line7:
circle(B5)
This line of code shows the
handler circle being passed the name of one of the robots, B5. circle
is an imaginary handler which we have used here to indicate how a robot can
be controlled by a handler rather than simply directly with velocity on its
own in on strategyB. For example in this handler the condition may be if
the ball
is at point a and I want to collide with it from this direction then vl =
20 & vr = 40.
NOTE:
In reality the vl and vr values would be a result of a conditional formula
in this handler or another handler called from this handler. These examples
merely present the idea of how you could control the robots directly if you
so wish.
This line of code concludes
the on strategyB handler.
This handler contains the
mechanics for moving the robots really fast It is passed whichBot from
the call on line 5.
Line10:
vl = 125
Line12:
velocity(whichBot, vl, vr)
The velocity handler is called
and the arguments whichBot (which is obtained from the code on line 5) vl
and vr ( which are passed from lines 10 and 11 within the on goReallyFast
handler.
Line13:
end
goReallyFast
This line of code concludes
the on goReallyFast handler.
NOTE:
The on goBackFast and on circle handlers operate in a similar fashion.
The next two imaginary handlers
in the code would be formatted similarly so we shall move onto examining a
working strategy at this time.
All comments
are in blue. A line by line analysis of the code is available for your perusal
at the end of the code.
--StrategyY--------------------
------------------------------
---Team 2--------------------
--Players and ball-----
Line
1. global Y1,Y2,Y3,Y4,Y5,ball
---Field coords--------------
Line
2. global ftop,
fbot, gRight, gLeft
--Required handler--------------
Line
3. on strategyY
--Optional handler
calls----------
Line
4. goaliel(Y1)
Line
5. attackball(Y2)
Line
6. attackball(Y3)
Line
7. attackball(Y4)
Line
8. attackball(Y5)
Line
9. end
--Optional handlers-------------------------
--You may add any
"Handlers"(funtions) you like.--
--You can call handlers
from handlers-----
Line
10. on Goalie1(whichBot)
--if nothing happens
do nothing
Line
11. vl = 0
Line
12. vr = 0
--Assign variables
Line
13. Tx =
ball.x
Line
14. Ty =
ball.y
Line
15. A = whichBot.pos
Line
16. R = whichBot.rot.z
--Convert from Director's
0 to 180
-- 0 to -180 rotation
to 0.001 to 360
Line
17. if
R < .001 then R = R + 360
Line
18. if R >360.001
then R = R - 360
--------
--if the Goalie's
y coord is larger than the balls
-- +.9 and he's
still in the goal area, go back fast!
Line
19. if A.y >
Ty + .9 and A.y > 27 then
Line
20. vl = -100
Line
21. vr =-100
Line
22. end if
---------
--if the Goalie's
y coord is Less than the balls
-- -.9 and he's
still in the goal area, go fwd fast!
Line
23. if A.y <
Ty -.9 and A.y < 43 then
Line
24. vl = 100
Line
25. vr =100
Line
26. end if
---------
--if some bully
pushed you past your limit,
--don't just sit
there, go fwd fast!
Line
27. if A.y <
27 then
Line
28. vl = 100
Line
29. vr =100
Line
30. end if
------
--if some bully
pushed you past your limit,
--don't just sit
there, go back fast!
Line
31. if A.y >
43 then
Line
32. vl = -100
Line
33. vr =-100
Line
34. end if
------------
--if your facing
the wrong way, straighten up------
Line
35. if R >
90.5 then
Line
36. vr = vr
+ abs(R - 90)
Line
37. else if
R < 89.5 then
Line
38. vl = vl
+ abs(R - 90)
Line
39. end if
--send off the instructions------------------
Line
40. velocity(whichBot
, vl, vr)
Line
41. end
---------------------------
---------------------------
Line
42. on attackball(whichbot)
--assign variables
Line
43. T = ball
Line
44. A = whichBot.pos
Line
45. R = whichBot.rot
.z
-------------------
Line
46. vl = 0
Line
47. vr = 0
-------get angleToPoint-----
Line
48. dX = A.x
-T.x
Line
49. dY = A.y
- T.y
Line
50. angleToPoint
= atan(abs(dY/dX)) * 180.0/pi()
--Adjust result
for quadrants-----------------------
--eg above left,
above right, below left, below right-------
Line
51. if(dX
> 0) then
Line
52.
if(dY > 0) then
Line
53.
angleToPoint = angleToPoint - 180
Line
54.
else if(dY < 0) then
Line
55. angleToPoint
= 180.0 - angleToPoint
Line
56.
end if
Line
57. end if
Line
58. if(dX
< 0) then
Line
59.
if(dY > 0) then
Line
60.
angleToPoint = 180 -angleToPoint -180
Line
61.
else if(dY < 0) then
Line
62. angleToPoint
= 270 - angleToPoint -180
Line
63.
end if
Line
64.
end if
-------------------------
--if it right in
front of you, go fast!-----------------
Line
65. if
abs(R - (angleToPoint )) < 4 then
Line
66. vl = 100
Line
67. vr= 100
--if
its not, go backward slowly(reduces the radius of turn)
Line
68. else if
abs(R - (angleToPoint )) > 4 then
Line
69. vl = -10
Line
70. vr = -10
Line
71. end if
---------
--set the right
wheel speed proportionate to the difference
--between the actual
angle and the target angle---------
Line
72. if
R > (angleToPoint ) then
Line
73. vr = vr
+ abs(R - angleToPoint)
Line
74. end if
----------
--set the left wheel
speed proportionate to the difference
--between the actual
angle and the target angle---------
Line
75. if
R < (angleToPoint ) then
Line
76. vl = vl
+ abs(R - angleToPoint)
Line
77. end if
-----------
--Because this happens
last and it sets an absolute vl,vr,
--when this "if"
is true the previous "ifs" are ignored---
--if you're more
or less facing the right way, go fast and
--correct as you
go!-----------------------------------
Line
78. if
abs(R - (angleToPoint )) < 30 then
Line
79. vl = 100
Line
80. vr= 100
Line
81. if R <
angletopoint then
Line
82. vr = vr-
10
Line
83. end if
Line
84.
if R > angleToPoint then
Line
85. vl = vl
- 10
Line
86. end if
Line
87. end if
----------------
--send off the instructions-----------------------
Line
88. velocity(whichBot
, vl, vr)
----------
Line
89. end attackBall
Note: All
strategies must be written into a text file.
The required global variables
of robot names and ball are first instantiated. These must be in place or
your strategy will not work. These should be at the beginning or your strategy
script.
Line
2: global
ftop, fbot, gRight, gLeft
These global
variables only contain the values (i.e. a number) for these constants (positions
on the field). No dot syntax is required. That is you can reference GtopY
simply using its name unlike the robots whose position would be referenced
using b1.pos.x or b1.pos.y.
Ftop
is
the y coordinate for the top of the field that is the wall closest to the
top of your screen.
Fbot
is
the y coordinate for the bottom of the field that is the wall closest to the
bottom of your screen.
gRight
is
the x coordinate for the middle of the back wall of the right goal, that is
the back wall of the goal closest to the right side of your screen
gLeft
is
the x coordinate for the middle of the back wall of the left goal, that is
the back wall of the goal closest to the Left side of your screen
Line
3: on
strategyY
This
handler must be called in your strategy. This is the hook that The Robot Soccer
Simulator uses to read and understand your strategy. It can be in the form
of on strategyY for the yellow team, as above, or on strategyB for the
blue team.
Line
4: goaliel(Y1)
This
handler
is called to control
the movements of the left goalie for the blue team. This handler is passed
the argument Y1. Y1 is the name of the robot required to perform the function
of the goalie.
Line
5: attackball(Y2)
This handler is called to
control the movements of a robot performing as an attacker for the blue team.
This handler is passed the argument Y2. Y2 is the name of the robot required
to perform attacking behaviours.
Line
6: attackball(Y3)
This handler is called to
control the movements of a robot performing as an attacker for the blue team.
This handler is passed the argument Y3. Y3 is the name of the robot required
to perform attacking behaviours.
Line
7: attackball(Y4)
This
handler is called to control the movements of a robot performing as an attacker
for the blue team. This handler is passed the argument Y4. Y4 is the name
of the robot required to perform attacking behaviours.
Line
8: attackball(Y5)
This handler is called to
control the movements of a robot performing as an attacker for the blue team.
This handler is passed the argument Y5. Y5 is the name of the robot required
to perform attacking behaviours.
Line
9: end
The end of the
on strategyY handler
Line
10: on
Goalie1(whichBot)
The on goalie1 handler begins
here. The argument whichBot is passed Y1 from the call of this handler on
line 4 of the on strategyY handler.
Line
11: vl =0
The
speed of the left wheel for the goalie robot (Y1) is initially set to zero
in the on goalie1 handler
Line
12: vr =0
The speed of the right wheel for
the goalie robot (Y1) is initially set to zero in the on goalie1 handler
Line
13: Tx
= ball.x
In the on Goalie1 handler
the variable Tx is created and is filled with the x coordinate of the ball.
T stands for target. There is no hardwiring of the coordinates. This convention
means the variable contents can at any time be changed to coordinates of any
entity in the game.
Line
14: Ty
= ball.y
In the on Goalie1handler
the variable Ty is created and is filled with the y coordinate of the ball.
T stands for target. There is no hardwiring of the coordinates. This convention
means the variable contents can at any time be changed to coordinates of any
entity in the game.
Line
15: A
= whichBot.pos
In the on Goalie1
handler the variable A is created and is filled with the positional coordinates
of whichBot. WhichBot is passed a robot name from the on strategyY handler.
Line
16: R
= whichBot.rot.z
In
the on Goalie1 handler the variable R is created and is filled with the
rotational coordinates of whichBot on the z axis (the only rotation available
to the robots in
the
game. WhichBot is passed a robot name from the on strategyY handler.
We have now
reached a point in the code where it is necessary to explain Directors and
therefore Lingos perception of angles. The angles of a full circle in Macromedias
Director are described in terms of zero to 180 degrees and zero to minus 180
degrees. This can easily be converted to 0 360 but both ways have their
advantages and disadvantages.
Line
17: if
R < .001 then R = R + 360
Line
18: if R >360.001
then R = R 360
In the on Goalie1 handler
lines 17 and 18 convert Directors rotational coordinates for whichBot to
units of 360 for the angle degrees of a full rotation. .001 and and 360.001
are necessary to prevent any division by zero in the handlers operator functions.
Line
19: if
A.y > Ty + .9 and A.y > 27 then
Line
20: vl
= -100
Line
21: vr
=-100
Line
22: end
if
if the y coordinate of the
goalie robot (Y1) is larger than the y coordinate of the ball +.9, and Y1
is still in the goal area then reverse quickly. End if concludes the function.
Line
23: if
A.y < Ty -.9 and A.y < 43 then
Line
24: vl
= 100
Line
25: vr
= 100
Line
26: end
if
The gist of lines 23 26 is, if
the y coordinate of the goalie robot (Y1) is less than the y coordinate of
the ball -.9, and Y1 is no longer in the goal area then reverse quickly. End
if concludes the function.
Line
27: if
A.y < 27 then
Line
28: vl
= 100
Line
29:
vr = 100
Line
30: end
if
The gist of lines
27 30 is that if the the y coordinate of the goalie robot (Y1) is less than
a point in line with the front of the goal then accelerate forwards.
Line
31: if
A.y > 43 then
Line
32: vl
= -100
Line
33: vr
=-100
Line
34: end
if
The gist of lines 31 34 is
that if the goalie robot (Y1) is outside the goal area then reverse back to
defend the goal
Line
35: if
R > 90.5 then
Line
36: vr
= vr + abs(R - 90)
Line
37: else if R
< 89.5 then
Line
38: vl = vl + abs(R
- 90)
Line
39: end if
The gist of lines 35 39
is that the goalie (Y1) is facing in a certain direction and if he is bumped
or for some reason faces a different direction then he should realign himself
to the original orientation.
Line
40: velocity(whichBot
, vl, vr)
The velocity handler is called,
this handler functions as a black box within the game to control the robots
and the only way to control the robots is by calling this handler at the end
of your custom handler.
Line
41: end
The
end of the on goalie1 handler
Line
42: on
attackball(whichbot)
This is the beginning of
the first attack ball handler for robot Y2. This handler commands Y2 to got
to the position of the ball.
Line
43:
T = ball
The
variable T (Target) is filled with the coordinates
of the ball.
Line
44: A = whichBot.pos
The variable A is filled
with the coordinates of the position of whichBot, which has been passed Y2.
Line
45: R = whichBot.rot
.z
The variable R is filled
with the coordinates of the position of whichBot, which has been passed Y2.
Line
46: vl = 0
At the beginning of the game
the speed of the left wheel of whichBot, which has been passed Y2 is set to
zero.
Line
47:vr = 0
At the beginning of the game
the speed of the right wheel of whichBot, which has been passed Y2 is set
to zero.
Line
48: dX = A.x -T.x
Explaining the code from this
point on involves the description of some complex mathematics and it will
only unnecessarily complicate the process of learning how to write a basic
strategy. You are welcome to examine and analyse the code however we
do not recommend this as a good example.
These rules
have been taken from the Mirosot rules for Robot Soccer. They have been re-printed
under the acceptable usage for educational purposes clause.
|
FIRA Middle League MiroSot
Game Rules |
|
Law 1 : The Field and the Ball
(a) Playground dimensions A black (non-reflective)
wooden rectangular playground 220cm X 180cm in size with 5cm
high and 2.5cm thick white side-walls will be used. The topsides of
the side-walls shall be black in color with the walls painted in white
(side view). Solid 7cm X 7cm isosceles triangles shall be fixed
at the four corners of the playground to avoid the ball getting cornered.
The surface texture of the board will be that of a ping pong table. (b) Markings on
the playground (Appendix 1) The field of play shall
be marked as shown in Appendix 1. The center circle will have a radius
of 25cm. The arc, which is part of
the penalty area, will be 25cm along the goal line and 5cm perpendicular
to it. The major lines/arcs (centerline,
goal area borderlines and the center circle) will be white in color
and 3mm in thick. The free ball (Law
13) robot positions (circles) shall be marked in gray color. (c) The goal The goal shall be 40cm wide.
Posts and nets shall not be provided at the goal. (d) The goal line
and goal area The goal line is the line
just in front of the goal, which is 40cm long. The goal areas (The
region A of Appendix 1) shall comprise of the area
contained by the rectangle (sized 50cm X 15cm in front of the goal).
(e) The penalty
area The penalty areas (The
region B of Appendix 1) shall comprise of areas contained by the
rectangle (sized 80cm X 35cm in front of the goal) and the attached
arc (25cm in parallel to the goal line and 5cm perpendicular to it). (f) The ball An orange golf ball shall
be used as the ball, with 42.7mm diameter and 46g weight. (g) The filed location The field shall be indoors. (h) The lighting
condition The lighting condition in
the competition site shall be fixed around 1,000 Lux. Law 2 : The Players
(a) The overall
system A match shall be played
by two teams, each consisting of five robots. One of the robots can
be the goalkeeper (Law
2.(b).2). Three human team members, a "manager", a "coach"
and a "trainer" shall only be allowed on stage. (b) The robots 1.
The size of each robot shall be limited to 7.5cm X 7.5cm X 7.5cm.
The height of the RF communication antenna will not be considered in
deciding a robot's size.
I.
The topside of a robot must not be colored in orange. A color
patch either blue or yellow, as assigned by the organizers, will identify
the robots in a team. All the robots must have (at least) a 3.5cm X
3.5cm solid region of their team color patch, blue
or yellow, visible on their top. A team's identification color will
change from game to game, and the team color patch used should be detachable.
When assigned with one of the 2-team colors (blue or yellow), the robots
must not have any visible patches of those colors used by an opponent
team.
II.
To enable infrared sensing a robot's sides should be colored
light, except at regions necessarily used for robot functionality, such
as those for sensors, wheels and the ball catching mechanism. The robots
should wear uniforms and the size of which shall be limited to 8cm X
8cm X 8cm. 2.
A robot within its own goal area (Law
1.(d).) shall be considered as the "goalkeeper". The goalkeeper
robot shall be allowed to catch or hold the ball only when it is inside
its own goal area or penalty area. 3.
Each robot must be fully independent, with powering and motoring
mechanisms self-contained. Only wireless communication shall be allowed
for all kinds of interactions between the host computer and a robot. 4.
The robots are allowed to equip with arms, legs, etc., but they
must comply with the size restrictions (Law
2.(b).1) even after the appendages fully expanded. None of the robots,
except the single designated goalkeeper, shall be allowed to catch or
hold the ball such that more than 30% of the ball is out of view either
from the top or from the sides (Appendix 2). 5.
While a match is in progress, at any time the referee whistles
the human operator should stop all robots using the communication between
the robots and the host computer. (c) Substitutions Two substitutes shall be
permitted while a game is in progress. At half time, unlimited substitutions
can be made. When a substitution is desired while the game is in progress,
the concerned team manager should call 'time-out' to notify the referee,
and the referee will stop the game at an appropriate moment. The game
will restart, with all the robots and the ball placed at the same positions
as they were occupying at the time of interrupting the game. (d) Time-out The human operator can call
for 'time-out' to notify the referee. Each team will be entitled for
two time-outs in a game and each shall be of 2 minutes duration. ท
Laws
4 & 5 have been omitted due to their covering of the computer system
information that can control the physical robots and the vision system
that is used for the physical robots. Law 5 : Game Duration
1.
The duration of a game shall be two equal periods of 5 minutes
each, with a half time interval for 10 minutes. An official timekeeper
will pause the clock during substitutions, while transporting an injured
robot from the field, during time-out and during such situations that
deem to be right as per the discretion of the timekeeper. 2.
If a team is not ready to resume the game after the half time,
additional 5 minutes shall be allowed. Even after the allowed additional
time if such a team is not ready to continue the game, that team will
be disqualified from the game. Law 6 : Game Commencement
1.
Before the commencement of a game, either the team color (blue/yellow)
or the ball shall be decided by the toss of a coin. The team that wins
the toss shall be allowed to choose either their robot's identification
color (blue/yellow) or the ball. The team who receives the ball shall
be allowed to opt for their carrier frequency band as well. 2.
At the commencement of the game, the attacking team will be allowed
to position their robots freely in their own area and within the center
circle. Then the defending team can place their robots freely in their
own area except within the center circle. 3.
At the beginning of the game or after a goal has been scored,
the game shall be commenced/continued, with the positions of the robots
as described in Law
6.2. 4.
After the half time, the teams have to change their sides. Law 7 : Method of Scoring
(a) The winner A goal shall be scored when
the whole of the ball passes over the goal line. The winner of a game
shall be decided on the basis of the number of goals scored. (b) The tiebreaker In the event of a tie after
the second half, the winner will be decided by the sudden death scheme.
The game will be continued after a 5 minutes break, for a maximum period
of three minutes. The team managing to score the first goal will be
declared as the winner. If the tie persists even after the extra 3 minutes
game, the winner shall be decided through penalty-kicks. Each team shall
take three penalty-kicks, which differs from Law
11 as only a kicker and a goalkeeper shall be allowed on the playground.
The goalkeeper should be kept within its goal area and the positions
of the kicker and of the ball shall be the same as per the Law
11. After the referee's whistle, the goalkeeper may come out
of the goal area. In case of a tie even after the three-time penalty-kicks,
additional penalty-kicks shall be allowed one-by-one, until the winner
can be decided. All penalty-kicks shall be taken by a single robot and
shall commence with the referee's whistle. A penalty-kick will be completed,
when any one of the following happens: 1.
The goalkeeper catches the ball with its appendages (if any)
in the goal area. 2.
The ball comes out of goal area. 3.
Thirty (30) seconds pass after the referee's whistle. Law 8 : Fouls
A foul will be called for
in the following cases. 1.
Colliding with a robot of the opposite team, either intentionally
or otherwise: the referee will call such fouls that directly affect
the play of the game or that appear to have potential to harm the opponent
robot. When a defender robot intentionally pushes an opponent robot,
a free kick will be given to the opposite team. It
is permitted to push the ball and an opponent player backwards provided
the pushing player is always in contact with the ball. 2.
It is permitted to push the goalkeeper robot in the goal area,
if the ball is between the pushing robot and the goalkeeper. However,
pushing the goalkeeper into the goal along with the ball is not allowed.
If an attacking robot pushes the goalkeeper along with the ball into
the goal or when the opponent robot pushes the goalkeeper directly then
the referee shall call goal kick as goalkeeper
charging. 3.
Attacking with more than one robot in the goal area of the opposite
team shall be penalized by a goal kick to be taken
by the team of the goalkeeper. A robot is considered to be in the goal
area if it is more than 50% inside, as judged by the referee. 4.
Defending with more than one robot in the goal area shall be
penalized by a penalty-kick. (A robot is considered
to be in the goal area if it is more than 50% inside, as judged by the
referee.) An exception to this is the situation when the additional
robot in the goal area in not there for defense or if it does not directly
affect the play of the game. The referee shall judge the penalty-kick
situation when the additional robot in the goal area is not there for
defense or if it does not directly affect the play of the game. The
referee shall judge the penalty-kick situation. 5.
It is referred to as handling, as judged by the referee,
when a robot other than the goalkeeper catches the ball. It is also
considered as handling, if a robot firmly attaches itself to
the ball such a way that no other robot is allowed to manipulate the
ball. 6.
The goalkeeper robot should kick out the ball from its goal area
(Law 1.(d).)
within 10 seconds. The failure to do so will be penalized by giving
a penalty kick to the opposite team. 7.
Giving a goal kick to the team of the goalkeeper
will penalize the intentional blocking of a goalkeeper in its goal area. 8.
Only the referee and one of the human members of a team (manager,
coach or trainer) shall be allowed to touch the robots. The award of
a penalty-kick shall penalize touching the robots without
the referee's permission. 9.
Defending
with more than three robots in the penalty area shall be penalized by
a penalty-kick. (A robot is considered to be in the
goal area if it is more than 50% inside, as judged by the referee.) Law 9 : Play Interruptions
The play shall be interrupted
and relocation of robots shall be done by a human operator, only when: 1.
A robot has to be changed. 2.
A robot has fallen in such a way as to block the goal. 3.
A goal is scored or a foul occurs. 4.
Referee calls goal kick (Law
12) or free-ball (Law
13). Law 10 : Free Kick (Appendix 3)
When a defender robot intentionally
pushes an opponent robot, a free kick will be given
to the opposite team (Law
8.1.). The ball will be placed at the relevant free kick position
(FK) on the playground (Appendix 1). The robot taking the kick shall
be placed behind the ball.
The attacking team can position its robots freely on the playground.
The two defending robots are allowed to be placed at the leftmost and
rightmost sides in touch with the front line of goal area and the other
defending two robots should be placed in touch with the side line of
the penalty area. With the referee's whistle all robots can start moving
freely. Law 11 : Penalty-Kick (Appendix 4)
A penalty-kick will be called
under the following situations. 1.
Defending with more than one robot in a goal area (Law
8.4.). 2.
Failure on the part of a goalkeeper to kick out the ball from
its goal area within 10 seconds (Law
8.6.). 3.
When any one of the human members touches the robots without
the referee's permission, while the game is in progress (Law
8.8.). 4.
Defending
with more than three robots in a penalty area (Law
8.9.). When the referee calls a
penalty-kick, the ball will be placed at the relevant penalty kick position
(PK) on the playground (Appendix 1). The robot taking the kick shall
be placed behind the ball. While facing a penalty kick one of the sides
of the goalkeeper must be in touch with the goal line. The goalkeeper
may be oriented in any direction. Other robots shall be placed freely
within the other side of the half-line, but the attacking team will
get preference in positioning their robots. The game shall restart normally
(all robots shall start moving freely) after the referee's whistle.
The robot taking the penalty-kick may kick or dribble the ball. Law 12 : Goal Kick (Appendix 5)
A goal kick
will be called under the following situations. 1.
When an attacking robot pushes the goalkeeper in its goal area,
the referee shall call goal kick as goalkeeper
charging (Law
8.2.). 2.
Attacking with more than one robot in the goal area of the opposite
team shall be penalized by a goal kick to be taken
by the opposite team (Law
8.3.). 3.
When an opponent robot intentionally blocks the goalkeeper in
its goal area (Law
8.7.). 4.
When the goalkeeper catches the ball with its appendages (if
any) in its own goal area. 5.
When a stalemate occurs in the goal area for 10 seconds. During goal kick only the
goalkeeper will be allowed within the penalty area and the ball can
be placed anywhere within the penalty area. Other robots of the team
shall be placed outside the penalty area during goal kick. The attacking
team will get preference in positioning their robots anywhere on the
playground, but it must be as per Law
8.3. The defending team can then place its robots within their own
side of the playground. The game shall restart with the referee's whistle. Law 13 : Free-Ball (Appendix 6)
Referee will call a free-ball
when a stalemate occurs for 10 seconds outside the goal area. When a free-ball is called
within any quarter of the playground, the ball will be placed at the
relevant free ball position (FB) (Appendix 1). One robot per team will
be placed at locations 25cm apart from the ball position in the longitudinal
direction of the playground. Other robots (of both teams) can be placed
freely outside the quarter where the free-ball is being called, but
with the rule that, the defending team will get their preference in
positioning their robots. The game shall resume when the referee gives
the signal and all robots may then move freely. |
Appendix 2 Back
These resources
have been included for the users interest. Should the user wish to develop
the engine further, learn more about strategies or simply learn more about
robot soccer in general, these resources are a great place to start.
1.
http://www.cs.hku.hk/~tlchung/collision_library.html
2.
http://www.cosy.sbg.ac.at/~held/projects/collision/collision.html
3.
http://www.cs.brown.edu/courses/gs007/lect/sim/web/murat.html
4.
http://www.gamasutra.com/features/20000330/bobic_01.htm
5.
http://aleph0.clark.edu/~djoyce/java/trig
6.
http://catcode.com/trig/index.html
7.
http://www.encyclopedia.com/articles/13050.html
8.
http://archives.math.utk.edu/topics/trigonometry
9.
http://www.math.uakron.edu?tprice/trig/TrigEquations.pdf
10.
http://www.gamasutra.com/features/20000913/lander_01.htm
11. http://www.havok.com
13.
http://almond.srv.cs.cmu.edu/afs/cs/project/robosoccer/www/index.html
15.
http://lrb.cs.uni-dortmund.de/fira99/
16.
http://www.machinebrain.com/Robot_Competition/
17.
http://www.csl.sony.co.jp/person/Kitano/RoboCup/RoboCup.html
18.
http://www.news.cornell.edu/Chronicles/8.12.99/robot_soccer.html
19.
http://sky.fit.qut.edu.au/~maire/RobSoc/robsoc.hhtml
20.
http://www.robotsoccer.at/
21.
http://united.rmit.edu.au/home2.html
22.
http://www/cc/gatecj/edi/classes/cs4324_98_spring?robot-soccer.html
23.
http://sciencedaily.com/print/1999/08/990806080010.htm
24.
http://www.robots.net/rcfaq.html
25.http://www.aem.org/crossroads/xrds4-3/robocup.html
1.
Macromedia Director 8.5 Shockwave Studio
for 3D: Training from the source.
By Phil Gross
and Mike Gross. Macromedia Press, Berkely 2002.
2.
Director 7 Demystified
By Jason Roberts
and Phil Gross. Macromedia Press, Berkely 1999.
3.
Flash Magic with ActionScript.
By J. Scott
Hamlin and David J. Emberton. New Riders Publishing, Indiana 2001.
4.
Software Quality Management A pro-active
approach
By John W.O.
Brinkworth. Prentice Hall, Hertfordshire 1992.
5.
Inside 3D Studio Max 4
by Kim Lee. New Riders Publishing, Indiana 2001
6.
3DS Max 4 Bible
by Kelly L.
Murdock. Hungry Minds Inc. 2001.
7.
Game Design: The Art and Business of Creating
Games
By Bob Bates
and Andre Lomothe. Premier Press Inc. 2001.
8.
Handbook of Software Quality Assurance,
Second Edition
Ed. G. Gordon
Schulmeyer and James I. McManus. Von Nostrand Reinhold
New York 1992.
9.
ISO 9000 for software Developers
By Charles
H. Schmauch. ASQC Quality Press. Milwaukee 1994
10.
Software Quality Assurance
By Tom Manns
and Michael Coleman, Second Edition
Macmillan Press
Ltd. London, 1996.