Darwinbots Forum
Code center => Bugs and fixes => Topic started by: Numsgil on April 16, 2006, 03:12:22 AM
-
I've done this on the C++ version to great effect.
In the buckets Module, you see this code:
Public Sub CompareRobots(n1 As Integer, N2 As Integer, field As Integer)
Dim ab As vector, ac As vector, ad As vector 'vector from n1 to n2
Dim invdist As Single, discheck As Single
Dim eyecellC As Integer, eyecellD As Integer
Dim a As Integer
ab = VectorSub(rob(N2).pos, rob(n1).pos)
invdist = VectorMagnitudeSquare(ab)
discheck = field * RobSize + rob(N2).radius
discheck = discheck * discheck
'check distance
If discheck < invdist Then Exit Sub
invdist = VectorInvMagnitude(ab)
'ac and ad are to either end of the bots, while ab is to the center
ac = VectorScalar(ab, invdist)
'ac is now unit vector
ad = VectorSet(ac.y, -ac.x)
ad = VectorScalar(ad, rob(N2).radius)
ad = VectorAdd(ab, ad)
ac = VectorSet(-ac.y, ac.x)
ac = VectorScalar(ac, rob(N2).radius)
ac = VectorAdd(ab, ac)
eyecellD = EyeCells(n1, ad)
eyecellC = EyeCells(n1, ac)
If eyecellC = 0 And eyecellD = 0 Then Exit Sub
If eyecellC = 0 Then eyecellC = EyeStart + 9
If eyecellD = 0 Then eyecellD = EyeStart + 1
For a = eyecellD To eyecellC
If rob(n1).mem(a) < (RobSize * 100 * invdist) Then
Dim eyevalue As Long
If a = EyeStart + 5 Then
rob(n1).lastopp = N2
End If
eyevalue = (RobSize * 100 * invdist)
If eyevalue > 32000 Then eyevalue = 32000
rob(n1).mem(a) = eyevalue
End If
Next a
End Sub
Here's the changes I made:
Public Sub CompareRobots(n1 As Integer, N2 As Integer, field As Integer)
Dim ab As vector, ac As vector, ad As vector 'vector from n1 to n2
Dim invdist As Single, discheck As Single
Dim eyecellC As Integer, eyecellD As Integer
Dim a As Integer
ab = VectorSub(rob(N2).pos, rob(n1).pos)
invdist = VectorMagnitudeSquare(ab)
discheck = field * RobSize + rob(N2).radius
discheck = discheck * discheck
'check distance
If discheck < invdist Then Exit Sub
invdist = VectorInvMagnitude(ab)
'ac and ad are to either end of the bots, while ab is to the center
ac = VectorScalar(ab, invdist)
'ac is now unit vector
ad = VectorSet(ac.y, -ac.x)
ad = VectorScalar(ad, rob(N2).radius)
ad = VectorAdd(ab, ad)
ac = VectorSet(-ac.y, ac.x)
ac = VectorScalar(ac, rob(N2).radius)
ac = VectorAdd(ab, ac)
eyecellD = EyeCells(n1, ad)
eyecellC = EyeCells(n1, ac)
If eyecellC = 0 And eyecellD = 0 Then Exit Sub
If eyecellC = 0 Then eyecellC = EyeStart + 9
If eyecellD = 0 Then eyecellD = EyeStart + 1
eyevalue = RobSize * 100 / (RobSize - rob(n1).radius - rob(N2).radius + 1 / invdist)
If eyevalue > 32000 Then eyevalue = 32000
For a = eyecellD To eyecellC
If rob(n1).mem(a) < eyevalue Then
Dim eyevalue As Long
If a = EyeStart + 5 Then
rob(n1).lastopp = N2
End If
rob(n1).mem(a) = eyevalue
End If
Next a
End Sub
It should help bots that don't react well at size greater than or less than 1000 body. It's obviously not optimized, since you're finding the inverse distance at the top of the function and then finding the inverse of that later on, but I think you get the idea.
-
I don't know if anyone agrees with me, bot seeing bots seem unrealistic. How about adding a function in the GUI where you can set the vision distance for bots, so you can set it like they allmost have to bump into something to see it. Then it whould be more like they are sensing that they are near something, like living single cellular organisms behave. That whould be neat I think.
-
The max range needs to be kept at 1440 because there are all sorts of optimizations that require bot vision to be constant.
But we can probably add a "fog" element to lower the distance bots can see.
If you take away a bot's vision, it really isn't left with a whole lot of other senses. Most senses are tied into vision.
-
Yeah, I guess it whould be more trouble than it's worth to change to some other sensing organ, but making it more short-sighted might be a nice solution.
-
You could have a bot that constantly travels forward, and when it hits something uses .hitang and .aimshot (or is it .aimshoot?) to fire at what it has hit. If it is hit itself it could return fire using .shang to determine the location of the attacker.
(The shot and hit sysvars are rather buggy though)
Just a thought
Blind bots would probably only be useful in thick 'fog'
-
I might be able to rig up the Pond Mode gradient to viewing distance. It would involve alot of math, though, so it's not an immediate priority.