Browse Source

rust raids update

pull/1086/head
miguel 2 years ago
parent
commit
332e922aae
  1. 58
      subjects/drawing/README.md
  2. 13
      subjects/drawing/audit/README.md
  3. BIN
      subjects/drawing/image.png
  4. 37
      subjects/road_intersection/README.md
  5. 80
      subjects/road_intersection/audit/README.md

58
subjects/drawing/README.md

@ -2,44 +2,50 @@
### Instructions
- Copy the code in [usage](#usage) to your main.rs
The purpose of this exercise is to create an image in the example bellow:
- Create a module called geometrical_shapes in another file.
![example](image.png)
- This module will keeps all the logic for creating and operating with the different geometrical shapes and define two traits `Displayable` and `Drawable`.
For this exercise you will need to do the following:
- `Drawable` contains the methods `draw` and `color`
- Copy the code in [usage](#usage) to your `main.rs`.
- `Displayable` contains the method `display`.
- Create a module called `geometrical_shapes` in another file.
- Define them in correspondence with the way they're called in the main function
This module will keep all the logic for creating and operating with the different geometrical shapes. You need to define two traits, `Displayable` and `Drawable`.
- You have to define the structures for Point, Circle, Line, Rectangle and Triangle and make the code in `main.rs` compile and run.
- `Drawable` which contains the methods `draw` and `color`.
- You are free to implement all the shapes with the internal structure that you find more adequate, but you have to provide for all the shapes an associated function `new` which will be described next:
- `Displayable` which contains the method `display`.
- Point: a new point should be created from two i32 values
- Line: a new line should be created from references to two points also define an associated function called `random` that receives two argument the first is the maximum x value a point can have and the
second the maximum y value that a point can have
- Triangle: a new triangle should be created from references to three points
- Rectangle: a new rectangle should be created from two references to points
- Circle: a new circle should be created from a point representing the center and an i32 value representing the radius
Define them according to the way they are called in the `main.rs` function.
- The main function also requires a definition of an associated function called `random` for the types Line, Point and Circle. You should derive their signature from the usage.
In order to make the code in the `main.rs` compile and run, you have to define the following structures:
Don't forget to add the dependencies in your Cargo.toml.
- `Point`
- `Circle`
- `Line`
- `Rectangle`
- `Triangle`
#### Bonus
You are free to implement all the shapes with whatever internal structure you see fit, but you must provide an associated function `new` for all the shapes, which will be described below:
- Implement drawing a pentagon (implement the structure Pentagon, and the trait needed to draw in the image)
- `Point`: a new point should be created from two `i32` values.
- `Line`: a new line should be created from references to two different points. Also it will define an associated function called `random`:
- `random`: receives two arguments, the first is the `maximum x` value a point can have and the second is the `maximum y` value that a point can have.
- `Triangle`: a new triangle should be created from references to three different points.
- `Rectangle`: a new rectangle should be created from two references to different points. ??????????????????????????????
- `Circle`: a new circle should be created from a point representing the center and an `i32` value representing the radius for the circle.
- Implement drawing a cube (implement the structure Cube, and the trait needed to draw in the image)
- The main function also requires a definition of an associated function called `random` for the types `Line`, `Point` and `Circle`. You should derive their signature from the usage.
### Notions
**Note**: Don't forget to add the dependencies in your Cargo.toml.
- [Image processing library](https://docs.rs/raster/0.2.0/raster/)
#### Bonus
- Implement the possibility of drawing a pentagon (implement the structure Pentagon, and the trait needed to draw in the image)
- [Traits](https://doc.rust-lang.org/stable/book/ch10-02-traits.html)
- Implement the possibility of drawing a cube (implement the structure Cube, and the trait needed to draw in the image)
### Usage
@ -83,4 +89,10 @@ impl Displayable for Image {
}
```
### And the expected output is a png file: `image.png`
**Note**: The expected output is a png file: `image.png`
### Notions
- [Image processing library](https://docs.rs/raster/0.2.0/raster/)
- [Traits](https://doc.rust-lang.org/stable/book/ch10-02-traits.html)

13
subjects/drawing/audit/README.md

@ -1,10 +1,18 @@
#### Functional
##### Run the command `cargo run`
###### Can you confirm that the module `geometrical_shapes` was created?
##### Try to run the command `cargo run`.
###### Does the program compile and run without any error or warning?
###### Does the program produces a png file called image.png?
###### Does the program produce a `png` file called `image.png`?
##### Open the module `geometrical_shapes`.
###### Can you confirm that the traits `Displayable` and `Drawable` where created?
##### Try to open the `image.png`.
###### Does the image contain lines, circles, rectangles and triangles?
@ -15,4 +23,3 @@
###### +Can you draw a pentagon?
###### +Can you draw a cube?

BIN
subjects/drawing/image.png

diff.bin_not_shown

After

Width:  |  Height:  |  Size: 146 KiB

37
subjects/road_intersection/README.md

@ -3,7 +3,7 @@
### Objectives
The objective for this raid is to create a traffic control strategy and represent it with an interface/UI.
Its up to you to decide which library and file system you want do use to create this simulation, but we recommend to use the library [sdl2](https://docs.rs/sdl2/0.34.3/sdl2/)
It's up to you to decide which library and file system you want to use in order to create this simulation, but we recommend you to use the library [sdl2](https://docs.rs/sdl2/0.34.3/sdl2/)
### Instructions
@ -13,7 +13,7 @@ You must create an environment which contains all the objects described in this
1. Roads
There exists various shapes of intersections, we will focus on the widely seen four-lane intersection. For simplicity each lane will have two directions.
There are various forms of intersections, let's focus on the widely seen four-lane intersection. For simplicity, each lane will have two directions.
```console
| ↓ | ↑ |
@ -32,7 +32,7 @@ _________________________|_______________________
r ↓ |
_______________ | _____________
| | ← ↑ → |
| ↓ | r s l |
| ↓ | l s r |
| ↓ | ↑ |
| ↓ | ↑ |
| ↓ | ↑ |
@ -40,7 +40,7 @@ _______________ | _____________
| ↓ | ↑ |
```
For clarification reasons we will assume that a lane can have three different routes (consider you are in the vehicle position):
For clarification reasons we will assume that a lane can have three different routes (consider that you are in the vehicle position):
- `r`, turning right
- `s`, straight ahead
@ -49,11 +49,11 @@ For clarification reasons we will assume that a lane can have three different ro
2. Traffic lights
Traffic lights are signalize devices positioned at road intersections that follows an universal color code,
normally its green, red and amber, but for this project you will just use the colors **red** and **green**.
it's usually green, red and amber, but for this project you will just use the colors **red** and **green**.
You will then have to create some kind of representation for the traffic lights and distribute them for each lane in the intersection.
You are free to decide what algorithm you want to implement for the traffic light system, but keep in mind that traffic congestion should not be to high.
You are free to decide what algorithm you want to implement to represent traffic light system, but keep in mind that traffic congestion should not be to high (8 or more vehicles).
3. Vehicles
@ -65,15 +65,17 @@ You are free to decide what algorithm you want to implement for the traffic ligh
Vehicles must obey this rules:
- Vehicles must have a color depending on their route the colors are up to you to decide(ex:`r`- purple, `s`- Blue and `l`- Yellow). This must then be given during the audit
- Vehicles must have a color depending on their route the colors are up to you to decide
- Autonomous, vehicles driving on a lane with a **given route** must follow the direction of
that route, its not possible for the driver to change lanes or route.
- Vehicles must have a color so that it's possible to identify which route it will follow (ex:`r`- purple, `s`- Blue and `l`- Yellow). This information about the colors must be given to the auditor of the raid.
- Autonomous vehicles driving on a lane with a **given route** must follow the direction of
that route, it's not possible for the driver to change lanes or routes.
- Each vehicle must have a fixed velocity.
- It must be kept a safety distance from other vehicles, if one vehicle stops the other vehicle that
behind him must stop and keep its distance.
- A safety distance from other vehicles must be kept, if one vehicle stop the other vehicle that's
behind him must stop and keep it's distance.
- Vehicles must stop if the traffic light is red and proceed otherwise.
@ -85,7 +87,7 @@ Vehicles must obey this rules:
#### **Commands**
The generating of vehicle must be done using the keyboard event. You must be able to generate
The generating of vehicles must be done using the keyboard event. You must be able to generate
vehicles in different lanes and with different routes.
For this it must be possible to do the following:
@ -101,17 +103,20 @@ For this it must be possible to do the following:
- The `Esc` key must finish the simulation.
> Arrow keys must not let the user spam the creation of vehicles, vehicles must be created with a safe distance between them.
> Arrow keys must not let the user spam the creation of vehicles, they must be created with a safe distance between them.
> A safe distance is any distance that allows the vehicles not to crash into each other.
### Example
You can see an example [here](https://www.youtube.com/watch?v=6B0-ZBET6mo).
You can see an example for the road_intersection [here](https://www.youtube.com/watch?v=6B0-ZBET6mo).
### Bonus
You can implement the following optional features :
You can implement the following optional features:
- Vehicle and traffic lights animation and image rendering. You can find some cool assets:
- Vehicle and traffic lights animation and image rendering. You can find some cool assets :
- [limezu](https://limezu.itch.io/)
- [finalbossblue](http://finalbossblues.com/timefantasy/free-graphics/).
- [mobilegamegraphics](https://mobilegamegraphics.com/product-category/all_products/freestuff/).

80
subjects/road_intersection/audit/README.md

@ -1,86 +1,98 @@
#### Functionals
#### Functional
##### Try and run the application, then generate a vehicle by pressing the `"Arrow Up"` key.
##### Try to run the application.
###### Is the application running?
##### Try to generate a vehicle by pressing the `"Arrow Up"` key.
###### Was a vehicle generated from the cardinal south?
##### Try pressing the `"Arrow Down"` key.
##### Try to generate a vehicle by pressing the `"Arrow Down"` key.
###### Was a vehicle generated from the cardinal North?
##### Try pressing the `"Arrow Right"` key.
##### Try to generate a vehicle by pressing the `"Arrow Right"` key.
###### Was a vehicle generated from the cardinal west?
##### Try pressing the `"Arrow left"` key.
##### Try to generate a vehicle by pressing the `"Arrow left"` key.
###### Was a vehicle generated from the cardinal east?
##### Try pressing the `"R"` key.
###### Are vehicles generated randomly(random lane and route)?
###### Was the vehicle generated randomly (random lane and route)?
##### Try pressing the `"R"` key more than 5 times to generate multiple vehicles in different lines.
###### Can you confirm that the vehicles were created and maintain a safe distance one from another?
##### Try to generate tree vehicles in the same lane (do this to all lanes).
##### Try to generate tree vehicles in the same lane (do this on all lanes one at a time).
###### Did all vehicles passed the intersection without any collision?
###### Can you confirm that the vehicles were created with a safe distance one from another?
##### Try to generate two vehicles at the same time, one using the `"Up"` key and the other using the `"Down"` key (to this at least 3 times).
##### Try to generate two vehicles at the same time, one using the `"Up"` key and the other using the `"Down"` key (do this at least 3 times).
###### Did all vehicles passed the intersection without any collision?
###### Did all the vehicles passed the intersection without any collision?
##### Try to generate two vehicles at the same time, one using the `"Right"` key and the other using the `"Left"` key (to this at least 3 times).
##### Try to generate two vehicles at the same time, one using the `"Right"` key and the other using the `"Left"` key (do this at least 3 times).
###### Did all vehicles passed the intersection without any collision?
###### Did all the vehicles passed the intersection without any collision?
##### Try to generate two vehicles at the same time, one using the `"Up"` key and the other using the `"Left"` key (to this at least 3 times).
##### Try to generate two vehicles at the same time, one using the `"Up"` key and the other using the `"Left"` key (do this at least 3 times).
###### Did all vehicles passed the intersection without any collision?
###### Did all the vehicles passed the intersection without any collision?
##### Try to generate two vehicles at the same time, one using the `"Up"` key and the other using the `"Right"` key (to this at least 3 times).
##### Try to generate two vehicles at the same time, one using the `"Up"` key and the other using the `"Right"` key (do this at least 3 times).
###### Did all vehicles passed the intersection without any collision?
###### Did all the vehicles passed the intersection without any collision?
##### Try to generate two vehicles at the same time, one using the `"Down"` key and the other using the `"Left"` key (to this at least 3 times).
##### Try to generate two vehicles at the same time, one using the `"Down"` key and the other using the `"Left"` key (do this at least 3 times).
###### Did all vehicles passed the intersection without any collision?
###### Did all the vehicles passed the intersection without any collision?
##### Try to generate two vehicles at the same time, one using the `"Down"` key and the other using the `"Right"` key (to this at least 3 times).
##### Try to generate two vehicles at the same time, one using the `"Down"` key and the other using the `"Right"` key (do this at least 3 times).
###### Did all vehicles passed the intersection without any collision?
###### Did all the vehicles passed the intersection without any collision?
##### Try to generate five vehicles using the `"Up"` key, at the same time generate two vehicles using the key `"Right"`.
##### Try to generate five vehicles using the `"Up"` key, at the same time generate two vehicles using the `"Right"` key.
###### Did all vehicles passed the intersection without any collision?
###### Did all the vehicles passed the intersection without any collision?
##### Try to generate one vehicle for all the lanes (to this at least 3 times).
##### Try to generate one vehicle for all the lanes (do this at least 3 times).
###### Did all vehicles passed the intersection without any collision?
###### Did all the vehicles passed the intersection without any collision?
##### Try to generate vehicles randomly using the `"R"` key. Then wait for at least 1 min.
###### Did all vehicles passed the intersection without any collision?
###### Did all the vehicles passed the intersection without any collision?
###### Was there a low traffic congestion while running the application? (ex: high traffic congestion can be 8 or more vehicles in the same lane without proceeding)?
##### Try to generate multiple vehicles with lanes at your choice.
###### Did all the vehicles passed the intersection without any collision?
##### Try to generate vehicles with lanes at your choice.
##### Try pressing the `"Esc"` key.
###### Did all vehicles passed the intersection without any collision?
###### Was the simulation finished?
###### Was there a low traffic congestion while running the application? (ex: high traffic congestion can be 8 or more vehicles in the same lane without proceeding)?
#### General
###### Is it not possible to spam the creation of vehicles(by pressing the arrow keys to many times)?
###### Can you confirm that it is impossible to spam the creation of vehicles (by pressing the arrow keys to many times or leave it pressed)?
###### Are vehicles assigned to their own route, and if so do they obey that route? (you can use the colors for each route to see this)
###### Are vehicles assigned to their own route, and if so, do they obey that route? (you can use the colors for each route to see this, ask the owner of the raid for instructions)
###### Are vehicles kept in a safe distance(do not collide when ever one stops)?
###### Do the vehicles kept a safe distance (do not collide whenever one stops)?
###### Do vehicles stop when ever there is a red light?
###### Do vehicles stop whenever there is a red light?
###### Do vehicles proceed when ever there is a green light?
###### Do vehicles proceed whenever there is a green light?
#### Bonus
###### +Is there any type of image sprite for traffic light?
###### +Is there any type of image sprite for traffic light? (An image sprite is a collection of images put into a single image.)
###### +Did the student implement some kind of animation and image sprite for the vehicle?

Loading…
Cancel
Save