Closed richelbilderbeek closed 5 years ago
@robkruger: I assign you this Issue. Feel free to delegate it to others, as long as you take the responsibility to ensure the code is actually sped up!
The program sped up significantly👍
I see here the new speed is 2m12.
Well done!
Is your feature request related to a problem? Please describe.
In recent Travis CI build logs we can observe that 44% of all run-time is spent in
can_eat
.Now we can rationally speed up the program, let's reduce the number of times it is called!
What we can see, is that when
can_eat
is called for anyagent
,can_eat
will always return the samestd::vector
. We can store thatstd::vector
internally in anagent
.Describe the solution you'd like
agent
add to theprivate
section:m_prey
at the constructor ofagent
, by callingcan_eat
can_eat
by usingm_prey
insteadDo not make a getter for
m_prey
! It's an implementation detail that should not be exposed.Describe alternatives you've considered
None.
Additional context
None,