Movement Calculation

09/27/2011 20:11 general_lolichdissdich#1
I don't want any thanks or whatsoever for this. Just throwing it out to the devs who will maybe get interested in developing another bot!
This should really only be encouraging for beginners to write new software!
You can use this without permission (no licencing).
Also it's kind of a nice and easy task if you want to do some maths again ;)
If you have questions or spotted a mistake, please tell me!

Have fun!

PHP Code:
from math import powsqrt

def calcposattime
(currentdestinationspeedtime):
    
# extract
    
currentxcurrenty current
    destinationx
destinationy destination
    
# errorpreventing
    
if (currentx == destinationx) and (currenty == destinationy):
        return (
00)
    
# calc delta
    
deltaxdeltay currentx destinationxcurrenty destinationy
    
# calc distance from current to destination
    
distance sqrt(pow(deltax,2)+pow(deltay,2))
    
# distance: dis travelled in time: t with speed: v => dis = v * t
    
distance_travelled speed time
    
# now see how much of the final distance we made and multiply with our delta coordinates:
    
delta_travelled_x deltax * (distance_travelled/distance)
    
delta_travelled_y deltay * (distance_travelled/distance)
    
# and now add it to our current location
    
newxnewy currentx delta_travelled_xcurrenty delta_travelled_y
    
return (newxnewy)


if 
__name__ == "__main__":
    
STEPSIZE 4
    
for x1 in range(010STEPSIZE):
        for 
y1 in range(010STEPSIZE):
            for 
x2 in range(010STEPSIZE):
                for 
y2 in range(010STEPSIZE):
                    print 
"from"x1y1"to"x2y2"="calcposattime((x1y1), (x2y2), 11
(That lower part is for testing purposes)
Python