RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Editor AI TestsEditor AI VisualizationEditor – Assembly Spline ToolAsset BrowserAsset DeduplicatorAsset Management ToolSFX Previewer (Audio Events List)Audio Ribbon EditorAutoSaveBarriers EditorBiome ToolBuilding EditorBulk RenameCamera BookmarksCamera TransformCamera Path EditorCEF HelperCo-Simulation Signal EditorCrawl Data EditorCreate Object ToolDataBlock EditorDecal EditorDecal Spline EditorDocumentation HelperDrag Race EditorDrift Data EditorDrive Path EditorDynamic Decals Tool (Vehicle Livery Creator)Engine Audio DebugExtensions DebugExtensions EditorFFI Pointer Leak TestFile DialogFlowgraph EditorForest EditorForest ViewEditor Gizmo HelperEditor Ground Model Debug HelperEditor Headless Editor TestEditor Icon OverviewEditor ImGui C DemoEditor InspectorEditor Layout ManagerEditor Level SettingsEditor Level ValidatorEditor LoggerEditor Log HelperEditor MainEditor Main MenuEditor Main ToolbarEditor Main UpdateMap Sensor EditorMaster Spline EditorMaterial EditorMeasures Inspector HeaderMesh Editor (Base)Mesh Road EditorMesh Spline EditorMission EditorMission PlaybookMission Start Position EditorMulti Spawn Manager (Vehicle Groups)Navigation Mesh EditorEditor News MessageObject Tool (Object Select Edit Mode)Object To Spline EditorParticle EditorPerformance Profiler / Camera RecorderPhysics ReloaderPrefab Instance EditorEditor PreferencesRace / Path EditorRally EditorRaycast Test Editor ToolRenderer Components Editor ToolRender Test Editor ToolResource Checker Editor ToolRiver EditorRoad Architect EditorRoad DecorationsRoad Editor (Decal Road)Road Network ExporterRoad River Cache HandlerRoad River GUIRoad Spline EditorRoad Template EditorRoad UtilitiesScene TreeScene ViewScreenshot Creator BootstrapScript AI EditorScript AI ManagerSensor Configuration EditorSensor DebuggerShape EditorShortcut LegendSidewalk Spline EditorSites EditorSlot Traffic EditorSuspension Audio DebugTech Server ManagerTerraform ToolTerrain And Road ImporterTerrain EditorTerrain Materials EditorText EditorTool ManagerTool ShortcutsTraffic DebugTraffic ManagerTraffic Signals EditorUndo History ViewerVehicle Bridge TestVehicle Detail ViewerVehicle Editor MainEditor - VisualizationEditor Viz HelperEditor Water Object HelperEditor Windows Manager
Gen Decal EditorGen Experimental Frame EditorGen Mesh ExplorerGen Experimental SolidFlexGen Mesh ModuleGen Network ModuleGen Region ModuleGen Render ModuleGen Terrain ModuleEditor Gen TestEditor Gen Top (Roof Geometry)Editor Gen UI (Building Architect UI)Editor Gen UtilsEditor Gen World
Gen AI LibraryGen JBeam LibraryGen UI Library

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionseditorgenlib

Gen AI Library

Gradient descent optimization library for the gen editor's experimental tools.

Gradient descent optimization library for the gen editor's experimental tools.


Overview

The ai library module provides numerical optimization via gradient descent. It offers two variants: a basic gradient descent (go) with ratio-based convergence, and an advanced version (go2) with configurable step functions and epoch limits. Used by experimental gen editor tools for inverse kinematics, body simulation, and parameter fitting.


Functions

FunctionSignatureDescription
M.go2(ac, loss, step, epo, s)(table, function, function, number?, number?) → number, number, tableAdvanced gradient descent with custom step function. step(ac, k, s) returns perturbed copy. Returns (finalLoss, initialLoss, coefficients)
M.line(set, ac)(table, table?) → number, table, tableFits a line to a point set using gradient descent. Returns (ratio, finalCoeffs, initialCoeffs) where coefficients are {ax,ay,az,bx,by,bz}

Parameters

M.go2(ac, loss, step, epo, s)

ParameterTypeDefaultDescription
actable-Coefficient array (modified in-place)
lossfunction-Loss function
stepfunction-Step function: step(ac, k, s) → perturbed_ac
eponumber1000Maximum epochs
snumber0.02Perturbation step size

Algorithm

Both functions use finite-difference gradient estimation:

  1. For each coefficient k, perturb ac[k] by step size
  2. Evaluate loss() to estimate gradient direction
  3. Update all coefficients proportionally to gradient
  4. Repeat until convergence or max iterations

Usage Example

local AI = require('/lua/ge/extensions/editor/gen/lib/ai')

-- Simple optimization
local coeffs = {0.5, 0.3, 0.7}
local function myLoss(ac)
  return (ac[1] - 1)^2 + (ac[2] - 2)^2 + (ac[3] - 3)^2
end
local finalLoss, initialLoss = AI.go(coeffs, myLoss, 0.1)

-- Advanced with custom step
local final, initial = AI.go2(coeffs, myLoss, function(ac, k, s)
  local copy = deepcopy(ac)
  copy[k] = copy[k] + s
  return copy
end, 500, 0.01)

Note on Local Functions

  • go(ac, loss, rat) - Local (not exported). Basic gradient descent without custom step function. Used internally.

See Also

  • Gen Frame Editor - Uses AI for IK solving
  • Gen SolidFlex - Uses AI for physics optimization

Editor Gen World

Central world/scene management module for the Building Architect Tool (BAT). Manages the full lifecycle of procedural buildings: creation, editing, material assignment, forest item placement, DAE expo

Gen JBeam Library

JBeam file parsing library for the gen editor's mesh and vehicle inspection tools.

On this page

OverviewFunctionsParametersM.go2(ac, loss, step, epo, s)AlgorithmUsage ExampleNote on Local FunctionsSee Also