Nuke Code (lua)

Come in here to talk about your sky-net style world-destroying super bots!

Moderator: Defcon moderators

User avatar
trickser
level5
level5
Posts: 1826
Joined: Thu Mar 06, 2008 2:15 pm
Location: The Senate ; GMT+1
Contact:

Nuke Code (lua)

Postby trickser » Fri Aug 27, 2010 7:09 pm

I tired to find the algorithm which determines nuke movement, but I did not find time and/or interest to finish the research.
Anyway, here is the function I use for the basic nuke path curves.

Code: Select all

function GetNextNukePos (startX,startY,targetX,targetY,curPosX,curPosY)
   local relDist = (distance(curPosX,curPosY,targetX,targetY)/distance(startX,startY,targetX,targetY))
   local angle = math.pi/3*relDist+(math.atan2(targetY-curPosY,targetX-curPosX))
   local speed = ((0.01+0.01*(1-relDist)^2)*GetGameSpeed())
   local nextX = curPosX + math.cos(angle)*speed
   local nextY = curPosY + math.sin(angle)*speed
   return nextX, nextY
end

where distance is a simple function to calculate the distance of 2 points.

Return to “AI Bots”

Who is online

Users browsing this forum: No registered users and 3 guests