Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
boids
boids4
Commits
556f1535
Commit
556f1535
authored
Oct 30, 2015
by
Cassio Kirch
Browse files
Little optimization.
parent
6ecd465d
Changes
1
Hide whitespace changes
Inline
Side-by-side
nextstep.c
View file @
556f1535
#include <stdio.h>
]
#
include
<
stdio
.
h
>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
...
...
@@ -67,10 +67,13 @@ makeSum (struct Boid* const boid, const struct Boid* conductor, \
//if (conductor -> type == ECTODERM) /* And boid->type==ENDO */
//boid -> ectoNeighbors++;
}
#if defined(ENDO_GAMMA) || defined(ECTO_GAMMA) || defined(COUNT_NEIGHBORS)
if
(
conductor
->
type
==
ECTODERM
)
boid
->
ectoNeighbors
++
;
else
/* Assume endo. */
boid
->
endoNeighbors
++
;
#endif
}
}
conductor
=
conductor
->
next
;
...
...
@@ -138,7 +141,8 @@ setNextVelocity (struct Boid* const boid, const struct Box box[])
boid
->
newVelocity
[
Y
]
=
V0
*
sumY
/
sum
;
if
(
boid
->
ectoNeighbors
!=
0u
||
boid
->
endoNeighbors
!=
0u
)
boid
->
gamma
=
(
double
)
boid
->
ectoNeighbors
/
boid
->
neighbors
;
boid
->
gamma
=
(
double
)
boid
->
ectoNeighbors
/
\
(
boid
->
endoNeighbors
+
boid
->
ectoNeighbors
);
}
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment