eea

2d nnout

eea
Apr 17th, 2022 (edited)
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.03 KB | None | 0 0
  1. local world_model = Instance.new("WorldModel", script)
  2. local Frame_Part = Instance.new("Part", world_model) -- Get the Part that displays the Gui
  3. Frame_Part.Size = Vector3.new(16, 10, 1)
  4. Frame_Part.Position = Vector3.new(0, 8, 13.5)
  5. Frame_Part.Anchored = true
  6. Frame_Part.Material = "SmoothPlastic"
  7. Frame_Part.Transparency = 1
  8. local SurfaceGui_Display = Instance.new("SurfaceGui", Frame_Part) -- Get the Part's SurfaceGui
  9. local SurfaceGui_Frame = Instance.new("Frame", SurfaceGui_Display) -- Get the Frame Display
  10. SurfaceGui_Frame.BackgroundColor3 = Color3.new()
  11. SurfaceGui_Frame.BorderColor3 = Color3.new(1,1,1)
  12. SurfaceGui_Frame.Size = UDim2.fromScale(1, 1)
  13. local y = owner.Character.HumanoidRootPart.Position.Y
  14. local frame = 0
  15.  
  16. local corners = Instance.new("UICorner", SurfaceGui_Frame)
  17. corners.CornerRadius = UDim.new(.125, 8)
  18.  
  19. local InfoText = Instance.new("TextBox", SurfaceGui_Frame)
  20. InfoText.BackgroundTransparency = 1
  21. InfoText.TextColor3 = Color3.new(1,1,1)
  22. InfoText.RichText = true
  23. InfoText.Position = UDim2.fromOffset(25, 20)
  24. InfoText.Size = UDim2.fromScale(.5, 1/10)
  25. InfoText.Text = "Server FPS: "..(2/wait())
  26. InfoText.TextXAlignment = "Left"
  27. InfoText.TextYAlignment = "Top"
  28.  
  29. local FPSText = Instance.new("TextBox", SurfaceGui_Frame)
  30. FPSText.BackgroundTransparency = 1
  31. FPSText.TextColor3 = Color3.new(1,1,1)
  32. FPSText.RichText = true
  33. FPSText.Position = UDim2.fromOffset(25, InfoText.TextSize + 24)
  34. FPSText.Size = UDim2.fromScale(.5, 1/10)
  35. FPSText.Text = "Simulation FPS: "
  36. FPSText.TextXAlignment = "Left"
  37. FPSText.TextYAlignment = "Top"
  38.  
  39. local TickCounter = Instance.new("TextBox", SurfaceGui_Frame)
  40. TickCounter.BackgroundTransparency = 1
  41. TickCounter.TextColor3 = Color3.new(1,1,1)
  42. TickCounter.RichText = true
  43. TickCounter.Position = UDim2.fromOffset(25, InfoText.TextSize + FPSText.TextSize + 28)
  44. TickCounter.Size = UDim2.fromScale(.5, 1/10)
  45. TickCounter.Text = "Tick Counter: "
  46. TickCounter.TextXAlignment = "Left"
  47. TickCounter.TextYAlignment = "Top"
  48.  
  49. local link1 = [[ht]]
  50. local link2 = [[tps]]
  51. local link3 = [[://past]]
  52. local link4 = [[ebin.com/raw/]]
  53. local link5 = [[UZV]]
  54. local link6 = [[Vh1Un]]
  55. local httpservice = game:GetService("HttpService")
  56. local NN_Creator = loadstring(httpservice:GetAsync(link1..link2..link3..link4..link5..link6))()
  57.  
  58. local New_NN = NN_Creator:CreateNN(2, 5, 1, 2, .2, "Sigmoid")
  59.  
  60. local Targets = {
  61.     {{.5, .5}, {.5, .5}};
  62.     {{.25, .75}, {.25, .75}};
  63.     {{0.1, .5}, {0.1, .5}};
  64.     {{0.25, .4}, {0.25, .4}};
  65. }
  66.  
  67. local NN_Frames = {}
  68.  
  69. function RelativePosToWorldPos(X, Y)
  70.     local New_X = (Frame_Part.Size.X * 100 * X)/2
  71.     local New_Y = (Frame_Part.Size.Y * 100 * Y)/2
  72.     return New_X, New_Y
  73. end
  74.  
  75. function Round(X, Decimal_Point)
  76.     local String_X = tostring(X)
  77.     local Rounded_X = string.sub(String_X, 1, 2 + Decimal_Point)
  78.     return tonumber(Rounded_X)
  79. end
  80.  
  81. function LoadFrames()
  82.     for I = 1,#Targets do
  83.         local New_Frame = Instance.new("Frame", SurfaceGui_Frame)
  84.         New_Frame.Size = UDim2.new(0, 50, 0, 50)
  85.         New_Frame.ZIndex = 2
  86.        
  87.         local Position_Text = Instance.new("TextBox", New_Frame)
  88.         Position_Text.ZIndex = 2
  89.         Position_Text.Position = UDim2.new(.1, 0, .1, 0)
  90.         Position_Text.Size = UDim2.fromScale(.75,.75)
  91.         Position_Text.BackgroundTransparency = 1
  92.         Position_Text.TextColor3 = Color3.fromRGB(0, 0, 150)
  93.         Position_Text.TextScaled = true
  94.         Position_Text.RichText = true
  95.         Position_Text.Text = "(0, 0)"
  96.         Position_Text.Font = Enum.Font.Arcade
  97.        
  98.         local Frame_Corner = Instance.new("UICorner", New_Frame)
  99.         Frame_Corner.CornerRadius = UDim.new(1, 1)
  100.        
  101.         NN_Frames[I] = New_Frame
  102.     end
  103. end
  104.  
  105. function LoadTargetFrames()
  106.     for i = 1,#Targets do
  107.         local New_Frame = Instance.new("Frame", SurfaceGui_Frame)
  108.         New_Frame.Size = UDim2.new(0, 50, 0, 50)
  109.         New_Frame.Position = UDim2.fromScale(Targets[i][2][1], Targets[i][2][2])
  110.         New_Frame.BackgroundTransparency = .55
  111.         New_Frame.ZIndex = 1
  112.  
  113.         local Position_Text = Instance.new("TextBox", New_Frame)
  114.         Position_Text.Position = UDim2.new(.1, 0, .1, 0)
  115.         Position_Text.Size = UDim2.fromScale(.75,.75)
  116.         Position_Text.BackgroundTransparency = 1
  117.         Position_Text.TextColor3 = Color3.fromRGB(0, 0, 150)
  118.         Position_Text.ZIndex = 1
  119.         Position_Text.TextTransparency = .55
  120.         Position_Text.TextScaled = true
  121.        
  122.         local roundedX = Round(Targets[i][2][1], 2)
  123.         local roundedY = Round(Targets[i][2][2], 2)
  124.        
  125.         local x, y = RelativePosToWorldPos(roundedX, roundedY)
  126.        
  127.         Position_Text.Text = "("..x..", "..y..")"
  128.         Position_Text.Font = Enum.Font.Arcade
  129.  
  130.         local Frame_Corner = Instance.new("UICorner", New_Frame)
  131.         Frame_Corner.CornerRadius = UDim.new(1, 1)
  132.     end
  133. end
  134.  
  135. LoadFrames()
  136. LoadTargetFrames()
  137.  
  138. function UpdateFrames(Output, Index)
  139.     local Current_Frame = NN_Frames[Index]
  140.     local rounded_X, rounded_Y = Round(Output[1], 2), Round(Output[2], 2)
  141.     local X, Y = RelativePosToWorldPos(rounded_X, rounded_Y)
  142.     Current_Frame.Position = UDim2.new(Output[1], 0, Output[2], 0)
  143.     Current_Frame.TextBox.Text = "("..X..", "..Y..")"
  144. end
  145.  
  146. function UpdateVisPosAndRotation()
  147.     local pos = owner.Character.HumanoidRootPart.Position
  148.     local angle = math.rad(owner.Character.HumanoidRootPart.Orientation.Y)
  149.     local r = 8
  150.     local x = -math.sin(angle)*r
  151.     local z = -math.cos(angle)*r
  152.     Frame_Part.Position = Vector3.new(x, 3, z) + pos
  153.     Frame_Part.Orientation = Vector3.new(0, math.deg(angle)-180, 0)
  154. end
  155.  
  156. function UpdateInfo()
  157.     InfoText.Text = "Server FPS: "..(2/wait())
  158. end
  159.  
  160. function UpdateSimFPS(SimFPS)
  161.     FPSText.Text = "Simulation FPS: "..SimFPS
  162. end
  163.  
  164. local start = tick()
  165. while task.wait() do
  166.     frame += 1
  167.     _G.kainn = New_NN
  168.     Frame_Part.Locked = true
  169.     local Training_Data_Index = math.random(1, #Targets)
  170.     local Inputs = Targets[Training_Data_Index][1]
  171.     local Target_Index = Targets[Training_Data_Index][2]
  172.     New_NN:BackProp(Inputs, Target_Index)
  173.     local Output = New_NN:Forward(Inputs)
  174.     UpdateFrames(Output, Training_Data_Index)
  175.     UpdateVisPosAndRotation()
  176.     UpdateInfo()
  177.     UpdateSimFPS(frame/(tick()-start))
  178.     TickCounter.Text = "Frame Counter: "..frame
  179. end
Add Comment
Please, Sign In to add comment