generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: What's wrong with my A* algorithm?

Previous Thread :: Next Thread 
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
21 Mar 2014 11:14 PM
function distance(cframe, target)
xdist, ydist = math.abs(cframe.X-target.X), math.abs(cframe.Z-target.Z)
if xdist > ydist then
h = 14*ydist+10*(xdist-ydist)
else
h = 14*xdist+10*(ydist-xdist)
end
return h
end

function shortest(cframe, model)
current = model:GetModelCFrame()
open, closed = {current}, {}
options = {}
found = false
while wait() do
if not found then
for i, v in next, open do
if v ~= cframe then

cf = v + Vector3.new(1, 0, 0)
cf2 = v - Vector3.new(1, 0, 0)
cf3 = v + Vector3.new(0, 0, 1)
cf4 = v - Vector3.new(0, 0, 1)
shortest, check = 900, 0
lisp = {
["cf"] = distance(cf, cframe),
["cf2"] = distance(cf2, cframe),
["cf3"] = distance(cf3, cframe),
["cf4"] = distance(cf4, cframe)}

for x,b in next, lisp do
if shortest > b then
shortest, check = b, x
print(shortest)
end
end

if check == "cf" then
open[v] = cf
elseif check == "cf2" then
open[v] = cf2
elseif check == "cf3" then
open[v] = cf3
elseif check == "cf4" then
open[v] = cf4
end
closed[i] = v
open[i] = nil
else
found = true
break
end
end
else
break
end
end
end

shortest(CFrame.new(29.8, -351.83, -284.6), workspace.ai2)

Issue:

It gets stuck on: 6.8759727478027 for the distance.. It doesn't go farther
Report Abuse
LeadStormTest is not online. LeadStormTest
Joined: 14 Mar 2014
Total Posts: 25
21 Mar 2014 11:22 PM
You would probably receive more help on the scripters thread, this thread is often filled with inexpierenced programmers, or lazy programmers. Scripters usualy has more people willing to work on a larger, interesting projects. (Such as this)
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
21 Mar 2014 11:31 PM
Nevermind I retested it and it is fine.
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
21 Mar 2014 11:37 PM
@LeadStormTest, no. Just, no.
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
22 Mar 2014 12:54 AM
You would probably receive more help on the scripters thread, this thread is often filled with inexpierenced programmers, or lazy programmers. Scripters usualy has more people willing to work on a larger, interesting projects. (Such as this)
--------------------------
Sure... If I wanted to get flamed out of that sub-forum then I would've brought this issue there.
Report Abuse
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
22 Mar 2014 01:24 AM
@LeadStormTest
Nope. das for trullls bruh.
Report Abuse
LeadStormTest is not online. LeadStormTest
Joined: 14 Mar 2014
Total Posts: 25
22 Mar 2014 12:48 PM
Meh, i'm always lazy with my replies on this sub-forum, but on the scripters sub-thread, there are actually a few smart people(The percent is slowly decreasing, to more noobish topics sadly)

Alt. of Jetta765214
Report Abuse
glosgreen2 is not online. glosgreen2
Joined: 06 Jul 2009
Total Posts: 1303
22 Mar 2014 01:02 PM
It's not A* if it doesn't work. :p
Good job it did. :)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image