Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local link1 = "ht"
- local link2 = "tps"
- local link3 = "://past"
- local link4 = "ebin.com/raw/"
- local link5 = "UZV"
- local link6 = "Vh1Un"
- local httpservice = game:GetService("HttpService")
- local module = loadstring(httpservice:GetAsync(link1..link2..link3..link4..link5..link6))()
- function normalize(array)
- local normalized = {}
- local copyarray = {}
- for i = 1,#array do
- copyarray[i] = array[i]
- end
- table.sort(copyarray, function(i, j) return math.abs(i) < math.abs(j) end)
- for i = 1,#array do
- normalized[i] = array[i] / math.abs(copyarray[#copyarray])
- end
- return normalized
- end
- function adjust(v, omi, oma, nmi, nma)
- local new_v = ((v - omi) / (oma - omi)) * (nma - nmi) + nmi
- return new_v
- end
- function bool2int(b)
- if b then
- return 1
- end
- return 0
- end
- local NNL = module
- local out = 0
- local otherout = 0
- local xi = 100
- local zi = 100
- local targetgrid1d = {}
- local weights = {}
- local wblocks = {}
- local blocks = {}
- local size = Vector3.new(1,1,1)
- local wsize = Vector3.new(1,1,1)
- local nn = NNL:CreateNN(2, 2, 1, 1, 0.4, "Sigmoid")
- local training = 100000
- local pos = owner.Character.HumanoidRootPart.Position
- function creatblock(x,z,c)
- c = c or Color3.new(0,0,0)
- local block = Instance.new("SpawnLocation", script)
- block.Enabled = false
- block.Shape = "Block"
- block.Size = size
- block.Position = Vector3.new(x, 1, z)*size + pos
- block.Anchored = true
- block.Color = c
- block.Material = "Neon"
- blocks[x][z] = block
- end
- for l = 1,#nn.__Weights do
- wblocks[l] = {}
- for h = 1, nn.__Weights[l].rows do
- wblocks[l][h] = {}
- for i = 1, nn.__Weights[l].cols do
- local s, e = pcall(function()
- local b = Instance.new("SpawnLocation", script)
- b.Position = Vector3.new(h, l*3, i)*wsize + pos
- b.Enabled = false
- b.Size = wsize
- b.Anchored = true
- b.Color = Color3.new()
- b.Material = "SmoothPlastic"
- wblocks[l][h][i] = b
- end)
- if e then
- wait(.8)
- local s, e = pcall(function()
- local b = Instance.new("SpawnLocation", script)
- b.Enabled = false
- b.Position = Vector3.new(h, l*3, i)*wsize + pos
- b.Size = wsize
- b.Anchored = true
- b.Color = Color3.new()
- b.Material = "SmoothPlastic"
- wblocks[l][h][i] = b
- end)
- end
- end
- end
- end
- for x = 1,xi do
- blocks[x] = {}
- for z = 1,zi do
- local s, e = pcall(function() creatblock(x, z) end)
- if e then
- wait(1)
- creatblock(x, z)
- end
- end
- end
- for x = 1,#blocks do
- for z = 1,#blocks[x] do
- out+=1
- targetgrid1d[out] = bool2int((x^2 + z^2)/(xi^2 + zi^2) % 0.01 == 0)
- --targetgrid1d[out] = bool2int(x == 5 and z == 10)
- --targetgrid1d[out] = bool2int(math.sqrt(x^2 + z^2)/math.sqrt(xi^2 + zi^2) > 0.5)
- --targetgrid1d[out] = .5
- --targetgrid1d[out] = math.noise((x+.1)/6, (z+.1)/6) + .5
- --targetgrid1d[out] = math.abs(x - z)/math.sqrt(xi*zi)
- --targetgrid1d[out] = (500 - (blocks[1][1].Position - blocks[x][z].Position).Magnitude)/500
- end
- end
- local lowesterror = Instance.new("SpawnLocation", script)
- lowesterror.Size = Vector3.new(1, 1, 1)
- lowesterror.Color = Color3.new(0, 0, 1)
- lowesterror.Anchored = true
- lowesterror.Enabled = false
- lowesterror.Position = Vector3.new(1, 2*size.Y, -1) + pos
- for t = 1,training do
- otherout = 0
- local totalerror = 0
- for blockx = 1,#blocks do
- for blockz = 1,#blocks[blockx] do
- otherout+=1
- local block = blocks[blockx][blockz]
- local inputs = {
- block.Color.R;
- targetgrid1d[otherout];
- }
- nn:BackProp(inputs, {targetgrid1d[otherout]})
- local color = nn:Forward(inputs)[1]
- local clamped = math.clamp(color, 0, 1)
- blocks[blockx][blockz].Color = Color3.new(clamped, clamped, clamped)
- block.Position = Vector3.new(block.Position.X, 2*size.Y*clamped+pos.Y, block.Position.Z)
- totalerror += targetgrid1d[otherout] - color
- end
- wait()
- end
- lowesterror.Position = Vector3.new(t, 2*size.Y, -1) + pos
- local erro = Instance.new("SpawnLocation",script)
- erro.Size = Vector3.new(1,1,1)
- erro.Position = Vector3.new(t, (math.abs(totalerror)+1)*size.Y*2, -1) + pos
- erro.Color = Color3.fromRGB(math.clamp(math.abs(totalerror) * (255 / (xi*zi)), 0, 255), 0, 0)
- erro.Anchored = true
- erro.Enabled = false
- for l = 1,#nn.__Weights do
- for h = 1, nn.__Weights[l].rows do
- local normalizedweights = normalize(nn.__Weights[l].Matrix[h])
- for i = 1, nn.__Weights[l].cols do
- local color = (normalizedweights[i]+1)/2
- wblocks[l][h][i].Color = Color3.new(color, color, color)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment