Author Topic: Version 2.42.5 Released  (Read 10073 times)

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Version 2.42.5 Released
« Reply #15 on: May 27, 2006, 06:10:23 PM »
Quote from: Numsgil
I thought poffs were strictly ornamental.

Perhaps they should be, but today makepoff() calls createshot() (20 times) passing RobSize * 2 which gets assigned to the shot energy.  Magic energy from death... reminds me of Larry Niven's Magic Goes Away novels...

If poffs were strictly ornimental, I could exclude them entirely from collision detection.  That would be nice.
« Last Edit: May 27, 2006, 06:10:56 PM by EricL »
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Version 2.42.5 Released
« Reply #16 on: May 27, 2006, 07:58:39 PM »
I am 95% certain that poffs are strictly decoration.
 
 Corpses fire off shots periodically, which is the way I think the simulation is meant to deliver energy from dead things.
 
 Plus the disable poff button wouldn't make much sense if they effected the simulation.
 
 If poffs aren't just decoration, I think it's a "bug" (more unintended feature than bug really, but still).

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Version 2.42.5 Released
« Reply #17 on: May 28, 2006, 05:34:27 PM »
Corpses were a feature that I added around V3.1. prior to that there was no way that I was aware of that energy could be redeamed from a dead bot.

If as you say, the POFFs contain energy then it is a bug/feature that has been entirely overlooked for a long long time.
I say time to break out the bug squisher.  
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Version 2.42.5 Released
« Reply #18 on: June 18, 2006, 02:20:38 PM »
Quote from: Numsgil
Hehe, okay, this is taking less time than I thought
 
 
Code: [Select]
deltapos = botpos - shotpos
 deltavel = botvel - shotvel
 L2vel = squaredlength(deltavel)
 
 t0 = -(deltapos) dot deltavel + bot radius * sqrt(L2vel)
        -----------------------------------------------
                  L2vel
 
 t1 = -(deltapos) dot deltavel - bot radius * sqrt(L2vel)
        ------------------------------------------------
                      L2vel
 
 bool uset0 = true, uset1 = true
 time t <-- collision time
 
 if(t0 < 0 || t0 > 1)
     uset0 = false
 
 if(t1 < 0 || t1 > 1)
     uset1 = false
 
 if(uset0 = false and uset1 = false)
     the shot and bot don't collide
 
 if(uset0 = true and uset1 = true)
     t = min(t0, t1)
 
 else if(uset0 = true)
     t = t0
 
 else
     t = t1
 
 Now that we have t, we can find the pos of the bot and shot when they collided:
 
 posbot = oldbotpos + t * botvel
 
 posshot = oldshotpos + t * shotvel

 That's all from the top of my head, so someone feel free to double check the figures.  The basic algorithm is sound though (construct a quadratic and solve it)


I've been looking at this and I don't get the same factors.    Hey Nums, can you elaborate on your derivation for factoring the quadratic equation?
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Version 2.42.5 Released
« Reply #19 on: June 18, 2006, 09:00:52 PM »
The vector math makes some things a little funny.
 
 Solving the quadratic equation you get:
 
 t = -2 * deltapos dot deltavel +/- sqrt( (2 * deltapos dot deltavel) ^ 2 - 4 * deltavel dot deltavel * (deltapos dot deltapos - radius ^ 2)) / (2 * deltavel dot deltavel)
 
 I believe.  The vector math makes things tricky.  I don't remember exactly how I got whatever answer I got.  If I had the resources I'd just let something like matlab do the factoring.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Version 2.42.5 Released
« Reply #20 on: June 28, 2006, 08:10:27 PM »
Got matlab today, here's the answer I get:
 
 Collision occurs if c * t^2 + 2*b*t+(a-rad^2) <= 0
 
 The actual collision (both the entrance and exit "wouds") occur at c * t^2 + 2*b*t+(a-rad^2) = 0
 
 where:
 a = deltapos dot deltapos
 b = deltapos dot deltavel
 c = deltavel dot deltavel
 
 roots are at:
 
 t = -(b +/- sqrt(b^2 - a*c + c*rad^2)) / c
« Last Edit: June 28, 2006, 08:11:01 PM by Numsgil »

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Version 2.42.5 Released
« Reply #21 on: June 28, 2006, 10:14:47 PM »
Yup, that's what I came up with.  

Here's the heart of the current code...


        B0 = rob(robnum).pos
        d = VectorSub(vs, vb)         ' Vector of velocity change from both both and shot over time t
        p = VectorSub(S0, B0)
        P2 = VectorMagnitudeSquare(p) ' |P|^2
         
        D2 = VectorMagnitudeSquare(d) ' |D|^2
        If D2 = 0 Then GoTo CheckRestOfBots
        DdotP = Dot(d, p)
        x = -DdotP
        y = DdotP ^ 2 - D2 * (P2 - r ^ 2)
       
        If y < 0 Then GoTo CheckRestOfBots ' No collision
     
        y=Sqr(y)
               
        time0 = (x - y) / D2
        time1 = (x + y) / D2
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Version 2.42.5 Released
« Reply #22 on: June 28, 2006, 10:29:04 PM »
I like this double checking of answers