|
@@ -4,11 +4,11 @@
|
4
|
4
|
![main2.png](images/main2.png)
|
5
|
5
|
![main3.png](images/main3.png)
|
6
|
6
|
|
7
|
|
-[Verano 2016 - Rafa - Ive]
|
|
7
|
+[Verano 2016 - Rafa - Ive- Tatiana]
|
8
|
8
|
|
9
|
|
-One of the advantages of using computer programs is that we can easily implement repetitive tasks. Structures such as the `for`, `while`, and `do-while` allow us to repeat a block of instructions as many times as needed. These structures are also referred to as *repetition structures*.
|
|
9
|
+One of the advantages of using computer programs is that we can easily implement repetitive tasks. Structures such as `for`, `while`, and `do-while` allow us to repeat a block of instructions as many times as needed. These structures are also referred to as *repetition structures*.
|
10
|
10
|
|
11
|
|
-Algorithms are one of the fundamental concepts in Computer Science. Given a small set of instructions and the basic programming structures, we can solve many problems. In this laboratory experience you will practice the creation of algorithms simulating a robot that must explore a space using a set of very limited instructions.
|
|
11
|
+Algorithms are one of the fundamental concepts in Computer Science. Given a small set of instructions and the basic programming structures, we can solve many problems. In this laboratory experience, you will practice the creation of algorithms simulating a robot that must explore a space using a set of very limited instructions.
|
12
|
12
|
|
13
|
13
|
##Objectives:
|
14
|
14
|
|
|
@@ -36,7 +36,7 @@ Before arriving to the laboratory you should have:
|
36
|
36
|
|
37
|
37
|
## Counting Squares
|
38
|
38
|
|
39
|
|
-In this laboratory experience we will be programming a robot that has been placed in a grid of square rooms. Each one of the four walls in each room can have a door. Only the walls of adjoining rooms have doors. The walls that make up the grid's exterior do not have doors.
|
|
39
|
+In this laboratory experience, we will be programming a robot that has been placed in a grid of square rooms. Each one of the four walls in each room can have a door. Only the walls of adjoining rooms have doors. The walls that make up the grid's exterior do not have doors.
|
40
|
40
|
|
41
|
41
|
---
|
42
|
42
|
|
|
@@ -130,9 +130,11 @@ In the example, the code is trying to move the robot as many times as it can tow
|
130
|
130
|
---
|
131
|
131
|
|
132
|
132
|
|
133
|
|
-!INCLUDE "../../eip-diagnostic/repetitions-countingsquares/en/diag02.html" <br>
|
|
133
|
+!INCLUDE "../../eip-diagnostic/repetitions-countingsquares/en/diag02.html"
|
|
134
|
+<br>
|
134
|
135
|
|
135
|
|
-!INCLUDE "../../eip-diagnostic/repetitions-countingsquares/en/diag01.html" <br>
|
|
136
|
+!INCLUDE "../../eip-diagnostic/repetitions-countingsquares/en/diag01.html"
|
|
137
|
+<br>
|
136
|
138
|
|
137
|
139
|
|
138
|
140
|
---
|
|
@@ -162,7 +164,7 @@ Suppose that the robot is currently in the upper left room (northwest) of a **sq
|
162
|
164
|
|
163
|
165
|
5. Suppose we want to minimize the amount of energy used by the robot. Can you create an algorithm that uses less steps for the same grid size?
|
164
|
166
|
|
165
|
|
-6. Once you have finished your algorithm, and made it correct and efficient, hand it in using Delivererable 1 in Moodle. On the algorithm's header, write and explain the expression you found about the number of rooms the robot should visit to complete its task for a grid of size $$n \times n$$ (For example, "The robot takes 2x+5 steps, 5 to arrive at the middle and 2n to count the rest").
|
|
167
|
+6. Once you have finished your algorithm, and made it correct and efficient, hand it in using Deliverable 1 in Moodle. On the algorithm's header, write and explain the expression you found about the number of rooms the robot should visit to complete its task for a grid of size $$n \times n$$ (For example, "The robot takes 2x+5 steps, 5 to arrive at the middle and 2n to count the rest").
|
166
|
168
|
|
167
|
169
|
|
168
|
170
|
### Exercise 2 - Rectangular grid
|
|
@@ -179,13 +181,13 @@ Suppose that the robot is currently in the upper left room (northwest) of a **sq
|
179
|
181
|
|
180
|
182
|
### Exercise 3 - Rectangular grid, random position
|
181
|
183
|
|
182
|
|
-**Instrucciones**
|
|
184
|
+**Instructions**
|
183
|
185
|
|
184
|
186
|
1. Suppose that now the robot starts its task in any of the rooms in a **rectangular** grid (not necessarily square). Design an algorithm so the robot can compute the number of rooms there are in the grid.
|
185
|
187
|
|
186
|
188
|
2. To test this part of the program you should make sure the `MainGameWindow` object is created using the argument `Mode::RECT_RANDOM`.
|
187
|
189
|
|
188
|
|
-3. Once you have finished your algorithm, and made it correct and efficient, implement it in the `main` function. In the header of the program, write and explain the expression you found about the number of rooms the robot should visit to complete its task for a grid of size $$m \times n$$. In this case, the number of rooms to visit will depend on the robot's initial position, so express the worst case, i.e. according to your algorithm, how many rooms should the robot visit if it starts in the *worst* room.
|
|
190
|
+3. Once you have finished your algorithm, and made it correctly and efficiently, implement it in the `main` function. In the header of the program, write and explain the expression you found about the number of rooms the robot should visit to complete its task for a grid of size $$m \times n$$. In this case, the number of rooms to visit will depend on the robot's initial position, so express the worst case, i.e. according to your algorithm, how many rooms should the robot visit if it starts in the *worst* room.
|
189
|
191
|
|
190
|
192
|
4. Hand in the `main.cpp` file with the code to calculate the number of rooms in a rectangular grid with the robot in a random position using Deliverable 3 in Moodle.
|
191
|
193
|
|
|
@@ -221,4 +223,6 @@ Use the "Deliverable" links in Moodle to hand in the algorithm for Exercise 1 an
|
221
|
223
|
|
222
|
224
|
## References
|
223
|
225
|
|
224
|
|
-[1] Luther A. Tychonievich, Mark S. Sherriff, and Ryan M. Layer, http://nifty.stanford.edu/2015/tychonievich-sherriff-layer-counting-squares/
|
|
226
|
+[1] Luther A. Tychonievich, Mark S. Sherriff, and Ryan M. Layer, http://nifty.stanford.edu/2015/tychonievich-sherriff-layer-counting-squares/
|
|
227
|
+
|
|
228
|
+
|