Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bfc17ed

Browse files
committedSep 6, 2024·
First commit
1 parent f9b6630 commit bfc17ed

29 files changed

+1298
-0
lines changed
 

‎.clang-format

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
BasedOnStyle: Google
3+
IndentWidth: 4

‎.github/statics/illustration-01.png

31.6 KB
Loading

‎.github/statics/illustration-02.png

20.9 KB
Loading

‎.github/statics/preview.png

18.7 KB
Loading
+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Code Documentation
2+
3+
This document provides a series of templates and examples to document the [structures](#structures), [functions](#functions), and [macros](#macros) of the application.
4+
5+
The documentation must follow these rules:
6+
7+
- It must be written in English.
8+
- It should be done in files with a `.h` extension.
9+
10+
> If you use [Visual Studio Code](https://code.visualstudio.com/), you can use the pre-made Snippets.
11+
12+
## Structures
13+
14+
### Template
15+
16+
```c
17+
/**
18+
* @struct <STRUCTURE NAME>.
19+
* @brief <BRIEF DESCRIPTION OF WHAT THE STRUCTURE REPRESENTS>.
20+
*
21+
* <DETAILED DESCRIPTION OF THE STRUCTURE (PURPOSE, AND LISTS OF FIELDS)>.
22+
*/
23+
typedef struct {
24+
/**
25+
* @brief <BRIEF DESCRIPTION OF THE MEMBER>.
26+
*/
27+
DataType01 member01;
28+
29+
// ...
30+
} MyStruct;
31+
```
32+
33+
_For example..._
34+
35+
```c
36+
/**
37+
* @struct Point2D
38+
* @brief Represents a point in 2D space.
39+
*
40+
* The Point struct is used to represent a coordinate in a
41+
* two-dimensional Cartesian plane. It contains two members
42+
* representing the x and y coordinates.
43+
*/
44+
typedef struct {
45+
/**
46+
* @brief The x-coordinate of the point.
47+
*/
48+
int x;
49+
50+
/**
51+
* @brief The y-coordinate of the point.
52+
*/
53+
int y;
54+
} Point2D;
55+
```
56+
57+
## Functions
58+
59+
### Template
60+
61+
```c
62+
/**
63+
* @brief <BRIEF DESCRIPTION OF THE FUNCTION>.
64+
*
65+
* <DETAILED DESCRIPTION OF THE FUNCTION (WHAT IT DOES, HOW IT WORKS, AND ANY IMPORTANT INFORMATION)>.
66+
*
67+
* @param param01 <BRIEF DESCRIPTION OF `param01` PARAMETER>.
68+
*
69+
* @return <BRIEF DESCRIPTION OF THE FUNCTION'S RETURN VALUE>.
70+
*
71+
* @warning <RELEVANT INFORMATION ABOUT SIDE EFFECTS OR IMPORTANT CONSIDERATIONS (OPTIONAL)>.
72+
*/
73+
ReturnDataType myFn(DataType01 param01);
74+
```
75+
76+
> `@return` can be omitted if the function returns `void`.
77+
78+
_For example..._
79+
80+
```c
81+
/**
82+
* @brief Calculates the factorial of a number.
83+
*
84+
* This function computes the factorial of a non-negative integer
85+
* using an iterative approach. It handles the base case of 0! as 1.
86+
*
87+
* @param n The integer whose factorial is to be calculated.
88+
* Must be non-negative.
89+
*
90+
* @return The factorial of the given number. If the input is
91+
* negative, returns -1 as an error code.
92+
*
93+
* @warning The function does not handle large values of n well due to
94+
* potential integer overflow.
95+
*/
96+
int factorial(int n) {
97+
int i = 1;
98+
int result = 1;
99+
100+
if (n < 0) return -1;
101+
102+
for (i = 2; i <= n; i++) {
103+
result *= i;
104+
};
105+
106+
return result;
107+
}
108+
```
109+
110+
## Macros
111+
112+
### Template
113+
114+
```c
115+
/**
116+
* @def <MACRO NAME>
117+
* @brief <BRIEF DESCRIPTION OF WHAT THE MACRO DOES>.
118+
*
119+
* @warning <WARNINGS ABOUT THE USE OF THE MACRO (OPTIONAL)>.
120+
*/
121+
#define MY_MACRO value
122+
```
123+
124+
_For example..._
125+
126+
```c
127+
/**
128+
* @def PI
129+
* @brief The value of Pi to 5 decimal places.
130+
*
131+
* @warning This value may not be precise enough for some applications
132+
* requiring high accuracy in mathematical computations.
133+
*/
134+
#define PI 3.14159
135+
```
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Practical Work - Programming Topics
2+
3+
> [!CAUTION]
4+
> 2 grades are required in the subject, the practical work (PW) must be submitted and defended individually in parts 1 and 2 before the midterm exam. The defense will be individual, and you must demonstrate mastery of the tools in general and the practical work in particular. For the PW to be archived, it must be submitted by the deadline indicated by the teachers in the following format: `ID_LASTNAME_FIRSTNAME_PW.zip`, e.g., `41127133_PEREZ_MARIA_PIA_PW.zip`. Note that it is a `.zip`, not `.rar` or `.7z`, respect the submission format. The PW as a suffix indicates it is practical work. Attach the statement and remove the `bin` and `obj` folders, as you are sharing programs, and for obvious reasons, the servers will delete compressed files containing binaries or executables.
5+
6+
## Necessary Knowledge
7+
8+
- **Part 1**: Structured programming and arrays.
9+
- **Part 2**: Dynamic memory.
10+
- **Part 3**: Files.
11+
12+
## General Guidelines and Statement
13+
14+
Develop the following work in groups of 3 to 5 people. Submission and defense are mandatory. Parts 1 and 2 will be required to take the midterm exam. Keep in mind that the solution must be executable in the laboratories of the [UNLaM](https://www.unlam.edu.ar/), so it must be compatible with the **MinGW 64-bit** compiler. For richer and lag-free visualization, it is recommended to use the [SDL (Simple DirectMedia Layer)](https://www.libsdl.org/) library, the teachers will provide a project with the library included. You will only need to know the functions that allow drawing the elements of the work (_Illustration 1_).
15+
16+
![Illustration 1](../../statics/illustration-01.png)
17+
18+
> Illustration 1
19+
20+
Conway's Game of Life is a one-player game designed by British mathematician [John Horton Conway](https://en.wikipedia.org/wiki/John_Horton_Conway) in 1970. It is a one-player game where the evolution is determined by the initial state. A series of very simple rules will determine the overall evolution of the system.
21+
22+
The playing field will be an **NxM** board where each position represents a cell. Each cell has 8 neighboring positions. Cells can be alive/dead, and the following rules determine the cellular behavior in each turn:
23+
24+
- Born: If a dead cell has exactly 3 living neighboring cells, it is "born" (i.e., it will be alive in the next turn).
25+
- Dies: A living cell can die from overpopulation or isolation.
26+
- Overpopulation: If it has more than three neighbors.
27+
- Isolation: If it has only one neighbor or none.
28+
- Lives: A cell remains alive if it has 2 or 3 neighbors.
29+
30+
### For more information:
31+
32+
- [https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life)
33+
- [https://www.youtube.com/watch?v=2ssnMkJFqbA](https://www.youtube.com/watch?v=2ssnMkJFqbA)
34+
35+
## Part 1
36+
37+
### Part A
38+
39+
Design and test in library-type files `matrices.h` and `matrices.c` the necessary functions to initialize matrices with a known pattern (see _Illustration 2 - Glider Gun_), for example:
40+
41+
- Glider
42+
- Toad
43+
- Pulsar
44+
- Glider Gun
45+
46+
You can explore known patterns from online sources.
47+
Design and implement functions that allow determining the next state of a cell based on its current state and its neighbors.
48+
Use the patterns to verify correct functionality. Develop the solution to work with different matrix sizes, even if the size is defined at compile time.
49+
50+
### Part B
51+
52+
Draw the game on screen using **SDL** (the teachers will provide the template). You don’t have to follow the order of parts **A** and **B**; do it however feels most comfortable. Do you prefer to start with **SDL** to get a better visualization of what is happening? Great, do it that way. Do you prefer to test the cell logic via the console and then incorporate the visualization? Excellent, do it that way. Part of the learning process is understanding that these are different problems and how to tackle them. Choose the alternative that feels most comfortable.
53+
54+
![Glider Gun](../../statics/illustration-02.png)
55+
56+
> Illustration 2 - Glider Gun
57+
58+
## Part 2
59+
60+
Did you observe the largest matrix you can work with? Why does this happen?
61+
62+
Add new functions that allow working with matrices in dynamic memory, receive the matrix size via command line, and never use **VLA (Variable Length Array)**. In part 2, the matrix size will be dynamic and known at runtime.
63+
64+
## Part 3
65+
66+
Add the ability to read the system’s general state from text files before starting.
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.