Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local link = "https://pastebin.c"
- local link3 = "om/raw/UZVVh1Un"
- local httpservice = game:GetService("HttpService")
- local module, b, c = loadstring(httpservice:GetAsync(link..link3))()
- function random(min, max)
- min = min or 0
- max = max or 1
- return min + math.random() * (max-min)
- end
- local NNL = module
- local nn = NNL:CreateNN(7,15,2,3, .7, "Sigmoid")
- local range = 20
- local target = Instance.new("Part", script)
- target.Size = Vector3.new(1,1,1)
- target.Position = Vector3.new(math.random(1, range), math.random(1, range), math.random(1, range))
- target.Color = Color3.new(1,0,0)
- target.Anchored = true
- target.Name = "target"
- local learn = Instance.new("Part", script)
- learn.Position = Vector3.new(math.random(1, range), math.random(1, range), math.random(1, range))
- learn.Size = Vector3.new(1,1,1)
- learn.Color = Color3.new(0,1,0)
- learn.Anchored = true
- learn.Name = "learn"
- local a0 = Instance.new("Attachment", learn)
- a0.Name = "a0"
- a0.Position = Vector3.new(0,1/4,0)
- local a1 = Instance.new("Attachment", learn)
- a1.Name = "a1"
- a1.Position = Vector3.new(0,-1/4,0)
- local trail = Instance.new("Trail", learn)
- trail.Name = "trail"
- trail.Attachment0 = a0
- trail.Attachment1 = a1
- trail.MaxLength = 2000
- trail.Lifetime = 25
- trail.Color = ColorSequence.new(Color3.new(0,1,0))
- local ts = 250000
- for j = 1,ts do
- local distance = (target.Position - learn.Position).Magnitude/range
- local d_vector = target.Position - learn.Position
- local inputs = {
- learn.Position.X/range,
- learn.Position.Y/range,
- learn.Position.Z/range,
- distance,
- d_vector.X/range,
- d_vector.Y/range,
- d_vector.Z/range
- }
- local targets = {
- target.Position.X/range,
- target.Position.Y/range,
- target.Position.Z/range
- }
- --nn:BackProp(inputs, targets)
- nn:BackProp(inputs,targets)
- local pos =nn:Forward(inputs)
- --print(pos)
- 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))
- if distance < 1/range then
- target.Position = Vector3.new(random(1, range), random(1, range), random(1, range))
- end
- task.wait()
- end
- print("done")
- print(nn.__Weights)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement