You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: artificialintelligence/assignments/flocking/README.md
+13-14Lines changed: 13 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,12 @@ Flocking is a behavior that is observed in birds, fish and other animals that mo
8
8
9
9
!!! note "Formal Notation Review"
10
10
11
-
- $\overrightarrow{F}$ means a vector $F$ that has components. In a 2 dimensional vector it will hold $F_x$ and $F_y$. For example, if $F_x = 1$ and $F_y = 1$, then $\overrightarrow{F} = (1,1)$
11
+
- $\overrightarrow{F}$ means a vector $F$ that has components. In a 2 dimensional vector it will hold $F_x$ and $F_y$. For example, if $F_x = 1$ and $F_y = 3$, then $\overrightarrow{F} = (1,3)$
12
12
- Simple math operations between vectors are done component-wise. For example, if $\overrightarrow{F} = (1,1)$ and $\overrightarrow{G} = (2,2)$, then $\overrightarrow{F} + \overrightarrow{G} = (3,3)$
13
13
- $\overrightarrow{P_1P_2}$ means the vector that goes from $P_1$ to $P_2$. It is the same as $P_2-P_1$
14
14
- The modulus notation means the length (magnitude) of the vector. $|\overrightarrow{F}| = \sqrt{F_x^2+F_y^2}$ For example, if $\overrightarrow{F} = (1,1)$, then $|\overrightarrow{F}| = \sqrt{2}$
15
-
- The hat ^ notation means the unitary vector of the vector. $\hat{F} = \frac{\overrightarrow{F}}{|\overrightarrow{F}|}$ For example, if $\overrightarrow{F} = (1,1)$, then $\hat{F} = (\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}})$
16
-
- The hat notation over 2 points means the unit vector that goes from the first point to the second point. $\widehat{P_1P_2} = \frac{\overrightarrow{P_1P_2}}{|\overrightarrow{P_1P_2}|}$ For example, if $P_1 = (0,0)$ and $P_2 = (1,1)$, then $\widehat{P_1P_2} = (\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}})$
15
+
- The hat ^ notation means the normalized vector(magnitude is 1) of the vector. $\hat{F} = \frac{\overrightarrow{F}}{|\overrightarrow{F}|}$ For example, if $\overrightarrow{F} = (1,1)$, then $\hat{F} = (\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}})$
16
+
- The hat notation over 2 points means the normalized vector that goes from the first point to the second point. $\widehat{P_1P_2} = \frac{\overrightarrow{P_1P_2}}{|\overrightarrow{P_1P_2}|}$ For example, if $P_1 = (0,0)$ and $P_2 = (1,1)$, then $\widehat{P_1P_2} = (\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}})$
17
17
- The sum $\sum$ notation means the sum of all elements in the list going from `0` to `n-1`. Ex. $\sum_{i=0}^{n-1} \overrightarrow{V_i} = \overrightarrow{V_0} + \overrightarrow{V_1} + \overrightarrow{V_2} + ... + \overrightarrow{V_{n-1}}$
18
18
19
19
It is your job to implement those 3 behaviors following the ruleset below:
@@ -22,7 +22,7 @@ It is your job to implement those 3 behaviors following the ruleset below:
22
22
23
23
Apply a force towards the center of mass of the group.
24
24
25
-
1. The $n$ neighbors of an agent are all the other agents that are within a certain radius of the agent;
25
+
1. The $n$ neighbors of an agent are all the other agents that are within a certain radius of the agent. It doesnt include the agent itself;
26
26
2. Compute the location of the center of mass of the group ($P_{CM}$);
27
27
3. Compute the force that will move the agent towards the center of mass($\overrightarrow{F_{c}}$); The farther the agent is from the center of mass, the force increases linearly up to the limit of the cohesion radius $r_c$.
28
28
@@ -48,12 +48,11 @@ It will move the agent away from other agents when they get too close.
48
48
1. The $n$ neighbors of an agent are all the other agents that are within the separation radius of the agent;
49
49
2. If the distance to a neighbor is less than the separation radius, then the agent will move away from it inversely proportionally to the distance between them.
50
50
3. Accumulate the forces that will move the agent away from each neighbor ($\overrightarrow{F_{s}}$). And then, clamp the force to a maximum value of $F_{Smax}$.
The force composition is made by a weighted sum of the influences of those 3 behaviors. This is the way we are going to work, this is not the only way to do it, nor the more correct. It is just a way to do it.
93
92
94
-
-$ \overrightarrow{F} = K_c \cdot \overrightarrow{F_c} + K_s \cdot \overrightarrow{F_s} + K_a \cdot \overrightarrow{F_a} $`This is a weighted sum!`
95
-
-$ \overrightarrow{V_{new}} = \overrightarrow{V_{cur}} + \overrightarrow{F} \cdot \Delta t $`This is a simplification!`
96
-
-$ P_{new} = P_{cur}+\overrightarrow{V_{new}} \cdot \Delta t $`This is an approximation!`
93
+
-\( \overrightarrow{F} = K_c \cdot \overrightarrow{F_c} + K_s \cdot \overrightarrow{F_s} + K_a \cdot \overrightarrow{F_a} \)`This is a weighted sum!`
94
+
-\( \overrightarrow{V_{new}} = \overrightarrow{V_{cur}} + \overrightarrow{F} \cdot \Delta t \)`This is a simplification!`
95
+
-\( P_{new} = P_{cur}+\overrightarrow{V_{new}} \cdot \Delta t \)`This is an approximation!`
97
96
98
97
!!! warning
99
98
100
99
A more precise way for representing the new position would be to use full equations of motion. But given timestep is usually very small and it even squared, it is acceptable to ignore it. But here they are anyway, just dont use them in this assignment:
101
100
102
-
- $ \overrightarrow{V_{new}} = \overrightarrow{V_{cur}}+\frac{\overrightarrow{F}}{m} \cdot \Delta t $
0 commit comments