|
@@ -4,6 +4,8 @@
|
4
|
4
|
![main2.png](images/main2.png)
|
5
|
5
|
![main3.png](images/main3.png)
|
6
|
6
|
|
|
7
|
+[Verano 2016 - Rafa - Ive]
|
|
8
|
+
|
7
|
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*.
|
8
|
10
|
|
9
|
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.
|
|
@@ -24,6 +26,7 @@ Before arriving to the laboratory you should have:
|
24
|
26
|
1. Reviewed the basic decision and repetition structures for C++.
|
25
|
27
|
2. Reviewed the creation of objects and how to invoke their methods.
|
26
|
28
|
3. Studied the concepts and instructions for the laboratory session.
|
|
29
|
+4. Taken the Pre-Lab quiz, available in Moodle.
|
27
|
30
|
|
28
|
31
|
|
29
|
32
|
---
|
|
@@ -152,19 +155,20 @@ Suppose that the robot is currently in the upper left room (northwest) of a **sq
|
152
|
155
|
|
153
|
156
|
**Instructions**
|
154
|
157
|
|
155
|
|
-1. Download the folder `Repetitions-CountingSquares` from `Bitbucket` by using the terminal, moving to the directory `Documents/eip`, and writing the command `git clone http://bitbucket.org/eip-uprrp/repetitions-countingsquares`.
|
|
158
|
+1. Load the project `CountingSquares` into `QtCreator`. There are two ways to do this:
|
156
|
159
|
|
157
|
|
-2. Load the `CountingSquares` project to Qt creator by double clicking on the `CountingSquares.pro` file that can be found in the `Documents/eip/Repetitions-CountingSquares` folder of your computer.
|
|
160
|
+ * Using the virtual machine: Double click the file `CountingSquares.pro` located in the folder `/home/eip/labs/repetitions-countingsquares` of your virtual machine.
|
|
161
|
+ * Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/repetitions-countingsquares` to download the folder `repetitions-countingsquares` from `Bitbucket`. Double click the file `CountingSquares.pro` located in the folder that you downloaded to your computer.
|
158
|
162
|
|
159
|
|
-3. Configure the project. The project consists of various files. **You will only write code in the file** `main.cpp`. The rest of the files contain functions that implement the functionality of the instructions the robot can understand.
|
|
163
|
+2. Configure the project. The project consists of various files. **You will only write code in the file** `main.cpp`. The rest of the files contain functions that implement the functionality of the instructions the robot can understand.
|
160
|
164
|
|
161
|
|
-4. When writing your algorithm, you should make sure that the `MainGameWindow` object is created using the argument `Mode::SQUARE_TOP_LEFT`. Remember, the robot does not know beforehand how many rooms there are. Test your algorithm with some examples.
|
|
165
|
+3. When writing your algorithm, you should make sure that the `MainGameWindow` object is created using the argument `Mode::SQUARE_TOP_LEFT`. Remember, the robot does not know beforehand how many rooms there are. Test your algorithm with some examples.
|
162
|
166
|
|
163
|
|
-5. If the size of the grid is 3x3, how many rooms should the robot visit to complete your algorithm? How about 4x4? How about $$n \times n$$ rooms?
|
|
167
|
+4. If the size of the grid is 3x3, how many rooms should the robot visit to complete your algorithm? How about 4x4? How about $$n \times n$$ rooms?
|
164
|
168
|
|
165
|
|
-6. 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?
|
|
169
|
+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?
|
166
|
170
|
|
167
|
|
-7. 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").
|
|
171
|
+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").
|
168
|
172
|
|
169
|
173
|
|
170
|
174
|
### Exercise 2 - Rectangular grid
|