Code center > Darwinbots Program Source Code
No fix for ghost collisions with planet eaters necissary
Botsareus:
Just ran sleepy again with your method:
That eyestrength thing is indeed eating up a lot. Numsgil, here is the code for eyestrength, any idea how to make it faster? It is supposed to trow a Boolean and revert to 1.
--- Code: ---0.25s Private Function eyestrength(n1 As Integer) As Single 'Botsareus 2/3/2013 eye strength mod
Const EyeEffectiveness As Byte = 3 'Botsareus 3/26/2013 For eye strength formula
If SimOpts.Pondmode And rob(n1).pos.y > 1 Then 'Botsareus 3/26/2013 Bug fix if robot Y pos is almost zero
eyestrength = (EyeEffectiveness / (rob(n1).pos.y / 2000) ^ SimOpts.Gradient) ^ (6828 / SimOpts.FieldHeight) 'Botsareus 3/26/2013 Robots only effected by density, not light intensity
Else
0.02s eyestrength = 1
End If
0.02s If Not SimOpts.Daytime Then eyestrength = eyestrength * 0.8
0.03s If eyestrength > 1 Then eyestrength = 1
End Function
--- End code ---
This is called from all over the place in the buckets module such as:
--- Code: ---'Returns the distance an eye of absolute width w can see.
'Eye sight distance S varies as a function of eye width according to: S = 1 - ln(w)/4
'where w is the absolute eyewidth as a multiple of the standard Pi/18 eyewidths
Public Function EyeSightDistance(w As Integer, n1 As Integer) As Single 'Botsareus 2/3/2013 modified to except robot id
If w = 35 Then
EyeSightDistance = 1440 * eyestrength(n1)
Else
EyeSightDistance = 1440 * (1 - (Log(w / 35) / 4)) * eyestrength(n1)
End If
End Function
--- End code ---
Good find btw.
Numsgil:
It looks like most of the expense is the overhead of calling a function. What does the callstack look like?
Basically, you should probably only ever need to call this once per bot per cycle. If it's getting called more than that, that would be the issue. You want to cache the values you get for each bot instead of recalculating them.
This is one of those cases where there's not much you can do to speed up the function itself, so you have to figure out ways to call it less frequently.
Botsareus:
Ok, I'll play with it, see what I can come up with. It does not look too promising though. If I get a reasonable speed improvement expect a revision drop soon.
Botsareus:
Nah, did not help a bit, My speed is exactly the same if I declare eyestrength in robot structure (and stuff) or I do not.
Numsgil:
That must not have been the bottleneck then :/
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version