Robot tasks. Performer Robot

Home / Breakdowns

Idol program

Performer Robot


Who is the Robot performer?

  • Imagine a checkered field (like a sheet from a notebook with a checkered pattern) on which there is a certain object, which we will call a Robot. Using special commands, we can control this Robot - move it around the cells, paint over the cells. And in most cases, our task will be to write a program for the Robot, in which it will paint certain cells.

Setting up the environment Idol for the performer Robot

  • The launched Idol program looks like this.

Robot starting environment

  • Before starting the program execution, it is necessary to set the starting environment for the Robot executor. This means placing the Robot in the desired position, placing walls, painting the required cells, etc. This step is very important. If you ignore it, the program may not work correctly or even crash.

Click on Edit environment



Performer Robot. Simple commands.

  • up
  • down
  • left
  • right
  • paint over

The result of executing these commands is clear from their names:

  • up - move the Robot up one cell
  • down - move the Robot one cell down
  • left - move the Robot one cell to the left
  • right - move the Robot one cell to the right
  • paint over - paint over the current cell (the cell in which the Robot is located).

Algorithm example

  • First you need to write the phrase:
  • use Robot

If you know how many cells need to be painted, then the solution algorithm will be as follows!


Task No. 1

  • Write a program to solve the following problem if you know how many cells need to be shaded

Cycles

  • 1. Loop with counter used when it is known in advance how many repetitions need to be done.

nc time

kts

Here we must specify the number of repetitions (number) and the commands that will be repeated. Commands that are repeated in a loop are called body of the cycle.



Task No. 2

  • Write a program to solve the following problem using a loop with a counter

  • 2. Loop with condition - while the condition is true, the loop is satisfied, if false, it is not satisfied
  • The Robot performer has several conditions

free on top

free from below

left free

free on the right

wall above

wall below

left wall

wall on the right

  • Particles you can use: NOT, AND, OR

Conditional loop structure

nts for now free on the right

right

paint over

kts



Task No. 3

  • Write a program to solve the following problem using a conditional loop:

Task No. 4

  • Write a program to solve the following problem using conditional loops:



Problem solving:

  • 2. The robot must be moved from the starting position to the final position, painting the walls


Task No. 5

  • There is a horizontal wall on an endless field. The length of the wall is unknown. The robot is located on top of the wall at its left end. The figure shows the location of the robot relative to the wall (the robot is designated by the letter “P”):

Answer to task No. 5

  • nc not yet (bottom free)

paint over

The beginning of the cycle (nc) and the condition (not yet (free from below)) are written on one line.



Design If

  • top free bottom free left free right free
  • These commands can be used in conjunction with a condition "If", having the following form:
  • If condition That
  • sequence of commands
  • For example, to move one cell to the right, if there is no wall on the right, and paint the cell, you can use the following algorithm:
  • if the right is free then
  • right
  • paint over

Task No. 7

The lengths of the walls are unknown.


Answer to task No. 7

until the top is free

paint over

right

while the top is free

right

while it's free on the right

paint over

right

not yet free on the right

paint over

down

while it's free on the right

down

not yet free on the right

paint over

down


Task No. 8

The lengths of the walls are unknown.

Each wall has exactly one passage, the exact location of the passage and its width are unknown.


Answer to task No. 8

while the top is free

until the top is free

paint over

while the top is free

until the top is free

paint over

until the bottom is free

paint over

while the bottom is free

until the bottom is free

paint over


Task No. 9

The lengths of the walls are unknown.

Each wall has exactly one passage, the exact location of the passage and its width are unknown.


Answer to task No. 9

while the bottom is free

until the bottom is free

paint over

while the bottom is free

until the bottom is free

paint over

until the top is free

paint over

while the top is free

until the top is free

paint over


Task No. 10

The lengths of the walls are unknown.

Each wall has exactly one passage, the exact location of the passage and its width are unknown.


Answer to task No. 10

while the left is free

while the left is free

paint over

while the left is free

until the left is free

paint over

not yet free on the right

paint over

while it's free on the right

not yet free on the right

paint over


Task No. 11

The lengths of the walls are unknown.

Each wall has exactly one passage, the exact location of the passage and its width are unknown.


Answer to task No. 11

until the top is free

until the top is free

paint over

while the bottom is free

until the top is free

paint over


Task No. 12

There is a staircase on the endless field. The staircase first goes down from right to left, then down from left to right. The height of each step is one square, the width is two squares. The robot is to the right of the top step of the stairs. The number of steps leading to the left and the number of steps leading to the right are unknown. The figure shows one of the possible ways to position the ladder and the Robot (the Robot is designated by the letter “P”).


Answer to task No. 12

We move down under the stairs from right to left until we reach the junction of the stairs:

nts the bottom is free for now

down

left

left

We move down to the end of the descending staircase, painting the necessary cells along the way:

nts not free on the left yet

paint over

right

paint over

right

down



Answer to task No. 13

nts the left is free for now

paint over

left

up

nts not free on the left yet

paint over

up


Task No. 14

On an infinite field there is a rectangle bounded by walls. The lengths of the sides of the rectangle are unknown. The robot is inside a rectangle. The figure shows one of the possible ways to position the walls and the Robot (the Robot is designated by the letter “P”).


Answer to task No. 14

while it's free on the right

right

while the top is free

up

paint over

nts the left is free for now

left

paint over



Answer to task No. 15

while it's free on the right

paint over

right

while the bottom is free

paint over

down

paint over

not yet (bottom free)

left

down

not yet (free on the right)

paint over

down

paint over

right

not yet (free on top)

paint over

right



Answer to task No. 16

not yet free on the right

paint over

down

paint over

right

until the top is free

paint over

right

while the top is free

up

while it's free on the right

paint over

right

not yet free on the right

paint over

down



The teacher’s task is to walk this path with the student, not insuring against failure, but preventing disappointment due to possible difficulties. It is very important to organize classes so that children themselves discover new things through activities that are meaningful to them.
How does a robot help study computer science? I will indicate only a few computer science topics on which robotics is based.
Topic "Files and file system".
The student had a LEGO®NXT microcomputer from the educational set at his disposal. LEGO Mindstorms NXT Education. Control it file system occurs using standard commands, but since the memory volume is not large, control of what is needed and what is not required must be carried out constantly. In order to voice the robot’s actions, display a picture, or add to the library of working programs, you need to operate with basic computer science concepts: file, file type, file path, menu, folder.
Topic: “Information processes”, “Information coding”.
The robotic kit is equipped with sensors that record audio, tactile and video information. Once digitized, the information can be displayed on a display screen. A special function of the microcomputer makes it possible to experiment with sensors and motors using ready-to-run programs. After conducting a series of experiments with sensors, an understanding emerges: why an ultrasonic distance sensor works slower than an infrared light sensor, how sound turns into a digital code, and so on. The study of information processes and principles of information coding provides a deeper understanding of the essence of information technology.

Theme: Communication Technologies.
The LEGO®NXT microcomputer supports technology wireless communication. Using the Bluetooth function, you can set wireless connection between the NXT microcomputer and other devices that have Bluetooth device, for example, with other NXT, with mobile phones or with computers. By establishing a Bluetooth connection, it is possible to: download programs from a computer remotely; send programs from other devices (not from a computer), including from NXT; send programs to both individual NXTs and their groups. This technology makes it possible to control the robot using a mobile phone.

Topics “Algorithms. Algorithm Executor”, “Programming Environment”.
For initial acquaintance with the robot, you can directly program the NXT unit without accessing a computer. Directly on the display screen, using a template of five commands, you can create a simple program and loop it. However, it is impossible to do without knowledge of basic algorithmic structures and mastering the programming environment. It is the ability to program the robot that makes it a universal performer, capable of solving a variety of problems. You should start mastering programming technology with visual programming environments, then moving on to more powerful and modern event-oriented environments.
Thus, robotics will require basic knowledge of computer science, and the student’s inexhaustible desire to make his robot “the best” pushes him to master new knowledge.
Why can a robot be called an ideal teaching tool? Because this tool makes it possible to create a learning environment that will make use of the child’s natural desires to play, create, and communicate with peers. So, we can highlight the advantages of robotics as a teaching tool:
. Knowledge acquisition occurs during the game.
. Building a robot offers creative freedom.
. Most students have a desire to improve their work.

As an example, I would like to cite the model of a “Robot delivering free treats”, created by a 6th grade student as part of the “Robot Programming” course during extracurricular activities. The robot is assembled from the LEGO MINDSTORMS NXT Education 9797 set according to the standard Alpharex 1.0 model, and is complemented by a color sensor to indicate the robot's status and a tray for treats.
The goal of the work is to implement a human gait model as far as possible with the available resources. The movement of each leg is controlled by a motor and a mechanical assembly of gears and levers. One lever moves the leg up and down, the other moves it forward. In this case, the body deflects towards the supporting leg, due to which the robot maintains balance. This gait is called "shuffling"
A separate motor controls the distance sensor and the lever arms that hold the touch sensor and color sensor. The treat tray is fixed.
The robot is programmed to act as a deliverer, for example, free treats, according to the following behavior algorithm. The robot accompanies its movement with a direct phrase: “I am the Alpharex robot, I offer a free treat!” A person who wants to make contact with the robot can stop it with a gesture. After stopping, the robot says the phrase: “Help yourself and press the button!” Having taken the candy, the person must press the button once as a sign of gratitude. Three seconds after stopping, the robot will continue moving. When the treats run out (the robot is programmed to have a specific number of candies on the tray), the robot will say goodbye, the red indicator will light up, and the robot will stop.

The program for controlling the robot is written in the NXT Programming 2.0 environment.

Performer The robot exists in a rectangular field, divided into cells, between which there can be walls and fits entirely in one cell. The robot can move around the field, paint cells, measure temperature and radiation. The robot cannot walk through walls, but it can check to see if there is a wall next to it.

The “Robot” performer’s command system includes:

  • 5 commands that trigger the Robot's actions (left, right, up, down, paint)
  • 10 condition checking commands:
  • 8 commands of the form [left/right/bottom/top] [wall/free]
  • 2 commands of the cell type [filled/blank]
  • 2 measurement commands (temperature, radiation)

Action commands

Check commands

Team Description
log on the left is free Returns yes if the robot can move to the left, otherwise no.
log on the right is free Returns yes if the robot can move to the right, otherwise no.
log from above free Returns yes if the robot can move up, otherwise no.
log below free Returns yes if the robot can move down, otherwise no.
log left wall Returns yes if there is a wall to the left of the robot, otherwise no.
log right wall Returns yes if there is a wall to the right of the robot, otherwise no.
log on top wall Returns yes if there is a wall above the robot, otherwise no.
log below wall Returns yes if there is a wall below the robot, otherwise no.
log cell is filled in Returns yes if the cell is filled, and no if the cell is not filled.
log cell clean Returns no if the cell is filled, and yes if the cell is not filled.

Measurement commands

Let it be necessary to transfer from the cell to the left of the wall to the cell to the right of the wall:

The algorithm might look like this:

use Robot
alg example 1
beginning
. down
. right
. up
con

If you try to guide the Robot through the wall, a failure will occur. The robot will crash into the wall and will no longer be able to follow commands.


Let's write an algorithm for a robot passing a maze from point A to B:

use Robot
Alg from A to B
beginning
. right

. up ; up ; right ; down ; down ; right
. up ; up ; right ; down ; down ; right
con

The commands for passing each section can be grouped into one line - this shortens the recording of the algorithm and makes it more understandable. In order to write commands on one line, they must be separated by a semicolon.

Solution 20.1 of the OGE 2017 task in computer science from the demo version. This is a task of the second part with a detailed answer, of a high level of difficulty. Estimated task completion time is 45 minutes. For this task you can score a maximum of 2 points. The task is performed on the computer.

Checked content elements:
- ability to write a short algorithm in the environment formal executor.

Description of content elements tested during the exam:
— algorithm,
properties of algorithms,
— ways of writing algorithms,
- block diagrams,
- an idea of ​​programming,
- algorithmic constructions,
boolean values,
- operations,
- expressions,
— dividing the task into subtasks,
- auxiliary algorithm,
— processed objects (chains of characters, numbers, lists, trees).

20.1 task OGE 2017 in computer science

Performer Robot can navigate through a labyrinth drawn on a plane divided into cells. Between adjacent (on the sides) cells there may be a wall through which the Robot cannot pass.
Robot has nine commands. Four commands are order commands:
up
down
left
right
When executing any of these commands, the Robot moves one cell, respectively: up, down ↓, left ←, right →. If the Robot receives a command to move through a wall, it will collapse.
Robot also has a team paint over, in which the cell in which the Robot is currently located is painted over.
Four more commands are condition checking commands. These commands check if the path is clear for the Robot in each of four possible directions:
free at the top
free from below
left free
free on the right
These commands can be used in conjunction with the condition " if", having the following form:
If condition That
sequence of commands
All
Here the condition is one of the condition checking commands.
Command Sequence– this is one or more any command-orders.
For example, to move one cell to the right, if there is no wall on the right, and paint the cell, you can use the following algorithm:
if the right is free then
right
paint over
All
In one condition, you can use several condition checking commands using logical connectives And, or, Not, For example:
if (right is free) and (not below is free) then
right
All
To repeat a sequence of commands, you can use a loop " Bye", having the following form:
nts for now condition
sequence of commands
kts
For example, to move to the right while it is possible, you can use the following algorithm:
nts the right is free for now
right
kts

Complete the task.
The endless field has horizontal and vertical walls. The left end of the horizontal wall is connected to the bottom end of the vertical wall. Wall lengths unknown. There is exactly one passage in the vertical wall; the exact location of the passage and its width are unknown. The robot is in a cage located directly above the horizontal wall at its right end.
The figure shows one of possible ways the location of the walls and the Robot (the Robot is designated by the letter “P”).

Write an algorithm for the Robot that paints all the cells located directly to the left and right of a vertical wall. The passage must remain unpainted. The robot must paint only cells that satisfy this condition. For example, for the picture above, the Robot must color in the following cells (see picture).

When executing the algorithm, the Robot must not be destroyed; the execution of the algorithm must be completed. The final location of the Robot can be arbitrary.
The algorithm must solve the problem for any permissible arrangement of walls and any location and size of the passage inside the wall.
The algorithm can be executed in a formal executor environment or written in a text editor.
Save the algorithm in text file. The name of the file and the directory for saving will be provided to you by the exam organizers.

Solution 20.1 of the OGE 2017 assignment in computer science

We will record the performer's commands bold font, and comments - italics. The beginning of a comment will be denoted by the symbol “|” ( It is not necessary to write down comments while working).

|We move to the left until we reach a vertical wall.
nts the left is free for now
left
kts

|We move up until we reach the passage in the wall, and paint over the cells.
nts not free on the left yet
paint over
up
kts

|We move up to the end of the wall and paint over the cells.
nts not free on the left yet
paint over
up
kts

|We go around the wall.
left
down

|We move down until we reach the passage in the wall and paint over the cells.
nts not free on the right yet
paint over
down
kts

|We move down to the end of the wall and paint over the cells.
nts not free on the right yet
paint over
down
kts

Other solutions are also possible.
It is allowed to use a different syntax for the performer’s instructions, which is more familiar to students.
The presence of individual syntactic errors is allowed, but does not distort the intent of the author of the solution.

2 points for the task are given if
The algorithm works correctly for all valid input data.
1 point for the task is given if
For all valid input data, the following is true:
1) execution of the algorithm is completed, and the Robot does not crash;
2) no more than 10 extra cells are painted over;
3) no more than 10 cells from those that should have been painted remained unpainted.
0 points for a task are given if
The task was completed incorrectly, i.e., the conditions for giving 1 or 2 points were not met.

© 2024 ermake.ru -- About PC repair - Information portal