Author Topic: Making bots see better in post 2.4  (Read 5583 times)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Making bots see better in post 2.4
« 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:
 
Code: [Select]
  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:
 
 
Code: [Select]
  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.
« Last Edit: April 16, 2006, 03:14:08 AM by Numsgil »

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Making bots see better in post 2.4
« Reply #1 on: April 16, 2006, 08:48:23 AM »
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.  
« Last Edit: April 16, 2006, 08:49:06 AM by Testlund »
The internet is corrupt and controlled by criminally minded people.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Making bots see better in post 2.4
« Reply #2 on: April 16, 2006, 10:40:18 AM »
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.

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Making bots see better in post 2.4
« Reply #3 on: April 16, 2006, 01:30:35 PM »
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.
The internet is corrupt and controlled by criminally minded people.

Offline Elite

  • Bot Overlord
  • ****
  • Posts: 532
    • View Profile
Making bots see better in post 2.4
« Reply #4 on: April 16, 2006, 01:56:41 PM »
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'
« Last Edit: April 16, 2006, 01:56:58 PM by Elite »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Making bots see better in post 2.4
« Reply #5 on: April 16, 2006, 02:51:09 PM »
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.