Vamos a comenzar el tema de robótica empleando el programa
RobotProg 1.1 que se encuentra instalado en los ordenadores del aula. El
programa, junto con el
tutorial original en inglés y los
archivos de ejemplo se pueden descargar de su web pinchando en los enlaces. También he preparado una traducción al castellano del tutorial, podéis descargarlo en el siguiente enlace:
Tutorial de RobotProg 1.1 en español.
Se puede obtener un listado completo del lenguaje del robot, visitando la siguiente página:
https://sites.google.com/site/robotprogbr/robot-language-summary, por si desapareciese, la reproduzco a continuación:
|
Robot Language Summary
|
|
| Keyword |
comment |
| Begin |
First executed block in a program |
| End |
Ends the execution of the current program or subroutine |
| Input |
Input instruction to enter a variable value with keyboard
Example: Input myVariable |
| Display |
Output instruction to show texts and variables values
Example: Display "The value of A is ", A |
| While |
Used in the header of a loop
This key word must be followed by a logical condition.
Example: While Not WallAhead |
| Wend |
End of a while loop |
| For |
Used in the header of a loop. Examples:
For i = 1 To 10
For k = 5 To 25 step 5 |
| To |
Used in the header of a loop |
| Step |
Used in the header of a loop |
| Next |
End of a for loop |
|
|
| MoveForward |
Robot command; the robot move to the tile ahead |
| TurnRight |
Robot command; the robot turns on the right but stays on the same tile |
| TurnLeft |
Robot command; the robot turns on the left but stays on the same tile |
| Mark |
Robot command; the robot paints a mark on the tile |
| Erase |
Robot command; the robot erases the mark on the tile |
| Reload |
Robot command; if the robot is over a socket, its energy is set to the maximum |
| GetBall |
Robot command; the robot takes the ball if it is on the same tile. |
| DropBall |
Robot command; the robot puts the ball on the tile. |
| ThrowBall |
Robot command; the robot throws the ball 3 tiles ahead |
|
|
| WallAhead |
Logical function returning true if the robot is facing a wall |
| WallOnRight |
Logical function returning true if the robot has a wall on its right side |
| WallOnLeft |
Logical function returning true if the robot has a wall on its left side |
| Out |
Logical function returning true if the robot is on an outer tile (darker tile), returning false otherwise |
| RobotOnSocket |
Logical function returning true when the robot occupies a tile containing an energy socket |
| MarkedSquare |
Logical function returning true if there is a mark on the tile occupied by the robot. |
| SquareAheadOccupied |
Logical function returning true if the tile ahead is occupied by an other robot |
| BallOnGround |
Logical function returning true if the ball is on the ground |
|
|
| DistanceFromWall |
Function returning a number equal to the number of tiles between the robbot and the nearest wall ahead |
| Energy |
Function returning a number representing the remaining energy of the robot |
| xRobot |
Function returning the x coordinate of the robot on the ground. |
| yRobot |
Function returning the y coordinate of the robot on the ground. |
| dxRobot |
Function returning the direction of the robot along the x axis (-1, 0 or 1) |
| dyRobot |
Function returning the direction of the robot along the y axis (-1, 0 or 1) |
| xBall |
Function returning the x coordinate of the ball on the ground. |
| yBall |
Function returning the y coordinate of the ball on the ground. |
|
|
| And |
Logical operator |
| Or |
Logical operator |
| Not |
Logical operator |
| True |
Logical constant |
| False |
Logical constant |
|
|
| = |
Assignment operator |
| () |
Parenthesis to be used in logical and numerical expressions |
| + - * / |
Numerical operators producing a numerical result with numerical operands |
| = > >= < <= |
Comparison operators producing a logical result with numerical operands |
|
|
A petición vuestra, aquí os dejo la tabla traducida:
Sumario del Lenguaje del Robot
Palabra
reservada
|
Comentario
|
Begin
|
Primer
bloque ejecutado en un programa
|
End
|
Finaliza
la ejecución del programa o subrutina actual
|
Input
|
Instrucción
de entrada de datos para introducir el valor de una variable desde el teclado
Ejemplo: Input myVariable
|
Display
|
Instrucción
de salida para mostrar valores de variables y textos
Ejemplo: Display "El valor de A es ", A
|
While
|
Usado
en la cabecera de un bucle while
Esta palabra reservada debe ir seguida de una condición lógica
Ejemplo: While Not WallAhead
|
Wend
|
Fin de un bucle while
(While end)
|
For variable = valor inicial
|
Usado
en la cabecera de un bucle for. Ejemplos:
For i = 1 To 10 (Step es opcional, no siempre aparece)
For k = 5 To 25 step 5.
|
To valor final
|
Usado
en la cabecera de un bucle for
|
Step
n
|
Usado en
la cabecera de un bucle for. Step es opcional.
|
Next
|
Fin de un bucle for
|
|
|
MoveForward
|
Comando
del robot; el robot se mueve hasta la baldosa delante de él
|
TurnRight
|
Comando
del robot; el robot gira a la derecha, pero permanece en la misma baldosa
|
TurnLeft
|
Comando
del robot; el robot gira a la izquierda, pero permanece en la misma baldosa
|
Mark
|
Comando
del robot; el robot pinta una marca en la baldosa
|
Erase
|
Comando
del robot; el robot borra una marca de la baldosa
|
Reload
|
Comando
del robot; si el robot está sobre un enchufe, su energía se carga al máximo
|
GetBall
|
Comando
del robot; el robot agarra el balón si éste está en la misma baldosa
|
DropBall
|
Comando
del robot; el robot deja el balón sobre la baldosa
|
ThrowBall
|
Comando
del robot; el robot lanza el balón 3 a baldosas delante de él
|
|
|
WallAhead
|
Función
lógica; devuelve verdadero (true) si
el robot está cara a una pared
|
WallOnRight
|
Función
lógica; devuelve verdadero (true) si
el robot tiene una pared a su derecha
|
WallOnLeft
|
Función
lógica; devuelve verdadero (true) si
el robot tiene una pared a su izquierda
|
Out
|
Función
lógica; devuelve verdadero (true) si
el robot está sobre una baldosa externa (baldosa más oscura), devuelve falso
(false) en cualquier otro caso
|
RobotOnSocket
|
Función
lógica; devuelve verdadero (true) cuando
el robot ocupa una baldosa que contiene un enchufe de energía
|
MarkedSquare
|
Función
lógica; devuelve verdadero (true) si
hay una marca sobre la baldosa ocupada por el robot
|
SquareAheadOccupied
|
Función
lógica; devuelve verdadero (true) si
la baldosa de delante está ocupada por otro robot
|
BallOnGround
|
Función
lógica; devuelve verdadero (true) si el balón está en el suelo
|
|
|
DistanceFromWall
|
Función
que devuelve un número igual al número de baldosas entre el robot y la pared
más próxima delante de él
|
Energy
|
Función
que devuelve un número que representa la energía que le queda al robot
|
xRobot
|
Función
que devuelve la coordenada x del robot sobre el terreno
|
yRobot
|
Función
que devuelve la coordenada y del robot sobre el terreno
|
dxRobot
|
Función
que devuelve la dirección del robot a lo largo del eje x (-1, 0 or 1)
|
dyRobot
|
Función
que devuelve la dirección del robot a lo largo del eje y (-1, 0 or 1)
|
xBall
|
Función
que devuelve la coordenada x del balón sobre el terreno
|
yBall
|
Función
que devuelve la coordenada y del balón sobre el terreno
|
|
|
And
|
Operador
lógico
|
Or
|
Operador
lógico
|
Not
|
Operador
lógico
|
True
|
Constante
lógica
|
False
|
Constante
lógica
|
|
|
=
|
Operador
de asignación
|
()
|
Paréntesis;
para ser usados en expresiones lógicas y numéricas
|
+ -
* /
|
Operadores
numéricos; producen un resultado numérico con operandos numéricos
|
=
> >= < <=
|
Operadores
de comparación; producen un resultado lógico con operandos numéricos
|
|