Advertisement
eea

targetnn

eea
Jan 28th, 2022 (edited)
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. local link = "https://pastebin.c"
  2. local link3 = "om/raw/UZVVh1Un"
  3. local httpservice = game:GetService("HttpService")
  4. local module, b, c = loadstring(httpservice:GetAsync(link..link3))()
  5.  
  6.  
  7. function random(min, max)
  8.     min = min or 0
  9.     max = max or 1
  10.     return min + math.random() * (max-min)
  11. end
  12.  
  13. local NNL = module
  14. local nn = NNL:CreateNN(7,15,2,3, .7, "Sigmoid")
  15.  
  16. local range = 20
  17.  
  18. local target = Instance.new("Part", script)
  19. target.Size = Vector3.new(1,1,1)
  20. target.Position = Vector3.new(math.random(1, range), math.random(1, range), math.random(1, range))
  21. target.Color = Color3.new(1,0,0)
  22. target.Anchored = true
  23. target.Name = "target"
  24.  
  25. local learn = Instance.new("Part", script)
  26. learn.Position = Vector3.new(math.random(1, range), math.random(1, range), math.random(1, range))
  27. learn.Size = Vector3.new(1,1,1)
  28. learn.Color = Color3.new(0,1,0)
  29. learn.Anchored = true
  30. learn.Name = "learn"
  31.  
  32. local a0 = Instance.new("Attachment", learn)
  33. a0.Name = "a0"
  34. a0.Position = Vector3.new(0,1/4,0)
  35.  
  36. local a1 = Instance.new("Attachment", learn)
  37. a1.Name = "a1"
  38. a1.Position = Vector3.new(0,-1/4,0)
  39.  
  40. local trail = Instance.new("Trail", learn)
  41. trail.Name = "trail"
  42. trail.Attachment0 = a0
  43. trail.Attachment1 = a1
  44. trail.MaxLength = 2000
  45. trail.Lifetime = 25
  46. trail.Color = ColorSequence.new(Color3.new(0,1,0))
  47.  
  48. local ts = 250000
  49.  
  50.  
  51. for j = 1,ts do
  52.     local distance = (target.Position - learn.Position).Magnitude/range
  53.     local d_vector = target.Position - learn.Position
  54.     local inputs = {
  55.         learn.Position.X/range,
  56.         learn.Position.Y/range,
  57.         learn.Position.Z/range,
  58.         distance,
  59.         d_vector.X/range,
  60.         d_vector.Y/range,
  61.         d_vector.Z/range
  62.     }
  63.    
  64.     local targets = {
  65.         target.Position.X/range,
  66.         target.Position.Y/range,
  67.         target.Position.Z/range
  68.     }
  69.    
  70.     --nn:BackProp(inputs, targets)
  71.     nn:BackProp(inputs,targets)
  72.     local pos =nn:Forward(inputs)
  73.     --print(pos)
  74.     learn.Position = Vector3.new(math.clamp(pos[1]*range, 0, range), math.clamp(pos[2]*range, 0, range), math.clamp(pos[3]*range, 0, range))
  75.     if distance < 1/range then
  76.        target.Position = Vector3.new(random(1, range), random(1, range), random(1, range))
  77.     end
  78.     task.wait()
  79. end
  80. print("done")
  81. print(nn.__Weights)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement