How to make better spring-based neurons

About advanced scenes, and the Thyme scripting language used in Algodoo.

How to make better spring-based neurons

Postby UnityDogGaming04 » Sat Oct 09, 2021 6:17 pm

I'm trying to make a spring-based neural network system, it's a successor to laser-based neural nets, because spring-based systems have plenty advantages over lasers. However, while the spring-based neurons work, they don't work exactly as I want them to. To get what I really want I need the neuron's output value to be set to 0 first, and then all the inputs attached to the neuron are added to it. Currently, it seems like these steps are happening out of order, because the second neuron receives nothing and stays neutral. Copy this into your scene to see what I'm talking about. Controls are WS.
Code: Select all
// FileVersion 21
// Phunlet created by Algodoo v2.1.0

FileInfo -> {};
Scene.addCircle {
    inertiaMultiplier := 1.0000000;
    resources := [];
    timeToLive := +inf;
    textureClamped := [false, false];
    adhesion := 0.00000000;
    attractionType := 2;
    attraction := 0.00000000;
    texture := "";
    update := (e)=>{};
    controllerInvertX := false;
    controllerInvertY := false;
    showMomentum := false;
    vel := [0.00000000, 0.00000000];
    restitution := 0.50000000;
    onCollide := (e)=>{};
    killer := false;
    materialVelocity := 0.00000000;
    showForceArrows := false;
    controllerReverseXY := false;
    refractiveIndex := 1.5000000;
    textureMatrix := [1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000];
    protractor := false;
    immortal := false;
    area := 0.049087387;
    collideSet := 1;
    drawBorder := true;
    reflectiveness := 1.0000000;
    friction := 0.50000000;
    entityID := 728;
    velocityDamping := [0.00000000, 0.00000000, 0.00000000];
    _acc := 0;
    onClick := (e)=>{};
    color := [0.10213728, 0.16502188, 0.23271626, 1.0000000];
    collideWater := true;
    onSpawn := (e)=>{};
    materialName := "";
    onHitByLaser := (e)=>{};
    drawCake := false;
    pos := [0.12500000, 0.37500000];
    onDie := (e)=>{};
    density := 2.0000000;
    airFrictionMult := 1.0000000;
    controllerAcc := 11.000000;
    colorHSVA := [211.10503, 0.56110811, 0.23271626, 1.0000000];
    radius := 0.12500000;
    angvel := 0.00000000;
    heteroCollide := false;
    glued := false;
    onKey := (e)=>{};
    showVelocity := false;
    postStep := (e)=>{
        color = [0.30000001, _acc,  - _acc, 1];
        _acc = 0
    };
    opaqueBorders := true;
    geomID := 6676637;
    body := 6676831;
    edgeBlur := 0.00000000;
    angle := 0.00000000;
    zDepth := 4.0000000;
    layer := 0
};
Scene.addCircle {
    inertiaMultiplier := 1.0000000;
    resources := [];
    timeToLive := +inf;
    textureClamped := [false, false];
    adhesion := 0.00000000;
    attractionType := 2;
    attraction := 0.00000000;
    texture := "";
    update := (e)=>{};
    controllerInvertX := false;
    controllerInvertY := false;
    showMomentum := false;
    vel := [0.00000000, 0.00000000];
    restitution := 0.50000000;
    onCollide := (e)=>{};
    killer := false;
    materialVelocity := 0.00000000;
    showForceArrows := false;
    controllerReverseXY := false;
    refractiveIndex := 1.5000000;
    textureMatrix := [1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000];
    protractor := false;
    immortal := false;
    area := 0.049087387;
    collideSet := 1;
    drawBorder := true;
    reflectiveness := 1.0000000;
    friction := 0.50000000;
    entityID := 588;
    velocityDamping := [0.00000000, 0.00000000, 0.00000000];
    _acc := 0;
    onClick := (e)=>{};
    color := [0.10213728, 0.16502188, 0.23271626, 1.0000000];
    collideWater := true;
    onSpawn := (e)=>{};
    materialName := "";
    onHitByLaser := (e)=>{};
    drawCake := false;
    pos := [-0.12500000, 0.37500000];
    onDie := (e)=>{};
    density := 2.0000000;
    airFrictionMult := 1.0000000;
    controllerAcc := 11.000000;
    colorHSVA := [211.10503, 0.56110811, 0.23271626, 1.0000000];
    radius := 0.12500000;
    angvel := 0.00000000;
    heteroCollide := false;
    glued := false;
    onKey := (e)=>{};
    showVelocity := false;
    postStep := (e)=>{
        color = [0.30000001, _acc,  - _acc, 1];
        _acc = 0
    };
    opaqueBorders := true;
    geomID := 6149479;
    body := 6149892;
    edgeBlur := 0.00000000;
    angle := 0.00000000;
    zDepth := 3.0000000;
    layer := 0
};
Scene.addLaserPen {
    geom := 0;
    relPoint := [-0.37500000, 0.43750000];
    collideWater := true;
    _acc := 1;
    color := [0.00000000, 1.0000000, 0.81476569, 1.0000000];
    showLaserBodyAttrib := true;
    opaqueBorders := true;
    timeToLive := +inf;
    update := (e)=>{};
    followGeometry := true;
    entityID := 532;
    onSpawn := (e)=>{};
    cutter := false;
    zDepth := 1.0000000;
    resources := [];
    fadeDist := 300.00000;
    size := 0.13000000;
    maxRays := 1;
    maxCuts := 0;
    _weight := 1;
    rotation := 0.00000000;
    legacyMode := 1;
    velocity := +inf;
    onDie := (e)=>{};
    onClick := (e)=>{};
    postStep := (e)=>{
        _acc = _weight * math.atan((scene.entityByGeomID((readable(entity)).geom))._acc) / math.pi / 0.50000000;
        color = [1, _acc,  - _acc, 1]
    };
    onLaserHit := (e)=>{
        e.geom._acc = e.geom._acc + _acc
    };
    collideSet := 1023;
    onKey := (e)=>{};
    colorHSVA := [168.88594, 1.0000000, 1.0000000, 1.0000000];
    layer := 0;
    activationButton := "w"
};
Scene.addLaserPen {
    geom := 0;
    relPoint := [-0.37500000, 0.31250000];
    collideWater := true;
    _acc := -1;
    color := [0.00000000, 1.0000000, 0.81476569, 1.0000000];
    showLaserBodyAttrib := true;
    opaqueBorders := true;
    timeToLive := +inf;
    update := (e)=>{};
    followGeometry := true;
    entityID := 533;
    onSpawn := (e)=>{};
    cutter := false;
    zDepth := 2.0000000;
    resources := [];
    fadeDist := 300.00000;
    size := 0.13000000;
    maxRays := 1;
    maxCuts := 0;
    _weight := 1;
    rotation := 0.00000000;
    legacyMode := 1;
    velocity := +inf;
    onDie := (e)=>{};
    onClick := (e)=>{};
    postStep := (e)=>{
        _acc = _weight * math.atan((scene.entityByGeomID((readable(entity)).geom))._acc) / math.pi / 0.50000000;
        color = [1, _acc,  - _acc, 1]
    };
    onLaserHit := (e)=>{
        e.geom._acc = e.geom._acc + _acc
    };
    collideSet := 1023;
    onKey := (e)=>{};
    colorHSVA := [168.88594, 1.0000000, 1.0000000, 1.0000000];
    layer := 0;
    activationButton := "s"
};
Scene.addLineEndPoint {
    geom := 6149479;
    relPoint := [0.00000000, 0.00000000];
    followGeometry := true;
    opaqueBorders := true;
    rotation := 0.00000000;
    size := 0.055911731;
    colorHSVA := [273.13718, 0.81999999, 0.13320202, 1.0000000];
    _weight := 1;
    onKey := (e)=>{};
    update := (e)=>{};
    postStep := (e)=>{};
    timeToLive := +inf;
    entityID := 726;
    resources := [];
    color := [0.084300190, 0.023976363, 0.13320202, 1.0000000];
    onSpawn := (e)=>{};
    zDepth := 6.0000000;
    onDie := (e)=>{};
    onClick := (e)=>{};
    layer := 0
};
Scene.addLineEndPoint {
    geom := 6676637;
    relPoint := [0.00000000, 0.00000000];
    followGeometry := true;
    opaqueBorders := true;
    rotation := 0.00000000;
    size := 0.027955865;
    colorHSVA := [164.67188, 0.37813368, 0.80820179, 1.0000000];
    _weight := 1;
    onKey := (e)=>{};
    update := (e)=>{};
    postStep := (e)=>{};
    timeToLive := +inf;
    entityID := 725;
    resources := [];
    color := [0.50259346, 0.80820179, 0.73012841, 1.0000000];
    onSpawn := (e)=>{};
    zDepth := 7.0000000;
    onDie := (e)=>{};
    onClick := (e)=>{};
    layer := 0
};
Scene.addSpring {
    lineEndPoint0 := 726;
    lineEndPoint1 := 725;
    legacyMode := 3;
    opaqueBorders := true;
    dampingFactor := 0.00000000;
    size := 0.069889665;
    constant := 0.00000000;
    texture := "";
    colorHSVA := [0.00000000, 1.0000000, 1.0000000, 1.0000000];
    length := 0.50000000;
    onKey := (e)=>{};
    update := (e)=>{};
    postStep := (e)=>{
        endPoint0 = (entityByID((readable(owner)).lineEndPoint0));
        endPoint1 = (entityByID((readable(owner)).lineEndPoint1));
        box0 = (entityByGeomID((readable(endPoint0)).geom));
        box1 = (entityByGeomID((readable(endPoint1)).geom));
        box1._acc = box1._acc + box0._acc * _weight
    };
    allowDirectSolve := true;
    _weight := 1;
    timeToLive := +inf;
    entityID := 727;
    resources := [];
    color := [1.0000000, 0.00000000, 0.00000000, 1.0000000];
    forceDirectSolve := false;
    onSpawn := (e)=>{};
    disableCollisions := false;
    zDepth := 5.0000000;
    onDie := (e)=>{};
    onClick := (e)=>{};
    layer := 0;
    totImp := 1.0000000
}

I'm aware of a way to fade the neuron's value over time, but this leads to fuzzier computation and past values effecting present ones. So while it works, it's just ugly. Hope my idea has gotten across correctly, if not ask questions. Anyone who helps may use the neural system without needing to credit me (or credit yourself and I both! :lol: )
ALL HAIL THYME!
UnityDogGaming04
 
Posts: 17
Joined: Tue Oct 05, 2021 8:35 pm
Location: Buckeye, AZ

Re: How to make better spring-based neurons

Postby UnityDogGaming04 » Sat Oct 09, 2021 6:28 pm

This variation uses fading, but it is much better than no fading at all. I might just use this if this topic remains quiet.
Code: Select all
// FileVersion 21
// Phunlet created by Algodoo v2.1.0

FileInfo -> {};
Scene.addCircle {
    inertiaMultiplier := 1.0000000;
    resources := [];
    timeToLive := +inf;
    textureClamped := [false, false];
    adhesion := 0.00000000;
    attractionType := 2;
    attraction := 0.00000000;
    texture := "";
    update := (e)=>{};
    controllerInvertX := false;
    controllerInvertY := false;
    showMomentum := false;
    vel := [0.00000000, 0.00000000];
    restitution := 0.50000000;
    onCollide := (e)=>{};
    killer := false;
    materialVelocity := 0.00000000;
    showForceArrows := false;
    controllerReverseXY := false;
    refractiveIndex := 1.5000000;
    textureMatrix := [1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000];
    protractor := false;
    immortal := false;
    area := 0.049087387;
    collideSet := 1;
    drawBorder := true;
    reflectiveness := 1.0000000;
    friction := 0.50000000;
    entityID := 728;
    velocityDamping := [0.00000000, 0.00000000, 0.00000000];
    _acc := 0;
    onClick := (e)=>{};
    color := [0.10213728, 0.16502188, 0.23271626, 1.0000000];
    collideWater := true;
    onSpawn := (e)=>{};
    materialName := "";
    onHitByLaser := (e)=>{};
    drawCake := false;
    pos := [0.12500000, 0.37500000];
    onDie := (e)=>{};
    density := 2.0000000;
    airFrictionMult := 1.0000000;
    controllerAcc := 11.000000;
    colorHSVA := [211.10503, 0.56110811, 0.23271626, 1.0000000];
    radius := 0.12500000;
    angvel := 0.00000000;
    heteroCollide := false;
    glued := false;
    onKey := (e)=>{};
    showVelocity := false;
    postStep := (e)=>{
        color = [0.30000001, _acc,  - _acc, 1];
        _acc = _acc / 64.000000
    };
    opaqueBorders := true;
    geomID := 6676637;
    body := 6676831;
    edgeBlur := 0.00000000;
    angle := 0.00000000;
    zDepth := 4.0000000;
    layer := 0
};
Scene.addCircle {
    inertiaMultiplier := 1.0000000;
    resources := [];
    timeToLive := +inf;
    textureClamped := [false, false];
    adhesion := 0.00000000;
    attractionType := 2;
    attraction := 0.00000000;
    texture := "";
    update := (e)=>{};
    controllerInvertX := false;
    controllerInvertY := false;
    showMomentum := false;
    vel := [0.00000000, 0.00000000];
    restitution := 0.50000000;
    onCollide := (e)=>{};
    killer := false;
    materialVelocity := 0.00000000;
    showForceArrows := false;
    controllerReverseXY := false;
    refractiveIndex := 1.5000000;
    textureMatrix := [1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000];
    protractor := false;
    immortal := false;
    area := 0.049087387;
    collideSet := 1;
    drawBorder := true;
    reflectiveness := 1.0000000;
    friction := 0.50000000;
    entityID := 588;
    velocityDamping := [0.00000000, 0.00000000, 0.00000000];
    _acc := 0;
    onClick := (e)=>{};
    color := [0.10213728, 0.16502188, 0.23271626, 1.0000000];
    collideWater := true;
    onSpawn := (e)=>{};
    materialName := "";
    onHitByLaser := (e)=>{};
    drawCake := false;
    pos := [-0.12500000, 0.37500000];
    onDie := (e)=>{};
    density := 2.0000000;
    airFrictionMult := 1.0000000;
    controllerAcc := 11.000000;
    colorHSVA := [211.10503, 0.56110811, 0.23271626, 1.0000000];
    radius := 0.12500000;
    angvel := 0.00000000;
    heteroCollide := false;
    glued := false;
    onKey := (e)=>{};
    showVelocity := false;
    postStep := (e)=>{
        color = [0.30000001, _acc,  - _acc, 1];
        _acc = _acc / 64.000000
    };
    opaqueBorders := true;
    geomID := 6149479;
    body := 6149892;
    edgeBlur := 0.00000000;
    angle := 0.00000000;
    zDepth := 3.0000000;
    layer := 0
};
Scene.addLaserPen {
    geom := 0;
    relPoint := [-0.37500000, 0.43750000];
    collideWater := true;
    _acc := 1;
    color := [0.00000000, 1.0000000, 0.81476569, 1.0000000];
    showLaserBodyAttrib := true;
    opaqueBorders := true;
    timeToLive := +inf;
    update := (e)=>{};
    followGeometry := true;
    entityID := 532;
    onSpawn := (e)=>{};
    cutter := false;
    zDepth := 1.0000000;
    resources := [];
    fadeDist := 300.00000;
    size := 0.13000000;
    maxRays := 1;
    maxCuts := 0;
    _weight := 1;
    rotation := 0.00000000;
    legacyMode := 1;
    velocity := +inf;
    onDie := (e)=>{};
    onClick := (e)=>{};
    postStep := (e)=>{
        _acc = _weight * math.atan((scene.entityByGeomID((readable(entity)).geom))._acc) / math.pi / 0.50000000;
        color = [1, _acc,  - _acc, 1]
    };
    onLaserHit := (e)=>{
        e.geom._acc = e.geom._acc + _acc
    };
    collideSet := 1023;
    onKey := (e)=>{};
    colorHSVA := [168.88594, 1.0000000, 1.0000000, 1.0000000];
    layer := 0;
    activationButton := "w"
};
Scene.addLaserPen {
    geom := 0;
    relPoint := [-0.37500000, 0.31250000];
    collideWater := true;
    _acc := -1;
    color := [0.00000000, 1.0000000, 0.81476569, 1.0000000];
    showLaserBodyAttrib := true;
    opaqueBorders := true;
    timeToLive := +inf;
    update := (e)=>{};
    followGeometry := true;
    entityID := 533;
    onSpawn := (e)=>{};
    cutter := false;
    zDepth := 2.0000000;
    resources := [];
    fadeDist := 300.00000;
    size := 0.13000000;
    maxRays := 1;
    maxCuts := 0;
    _weight := 1;
    rotation := 0.00000000;
    legacyMode := 1;
    velocity := +inf;
    onDie := (e)=>{};
    onClick := (e)=>{};
    postStep := (e)=>{
        _acc = _weight * math.atan((scene.entityByGeomID((readable(entity)).geom))._acc) / math.pi / 0.50000000;
        color = [1, _acc,  - _acc, 1]
    };
    onLaserHit := (e)=>{
        e.geom._acc = e.geom._acc + _acc
    };
    collideSet := 1023;
    onKey := (e)=>{};
    colorHSVA := [168.88594, 1.0000000, 1.0000000, 1.0000000];
    layer := 0;
    activationButton := "s"
};
Scene.addLineEndPoint {
    geom := 6149479;
    relPoint := [0.00000000, 0.00000000];
    followGeometry := true;
    opaqueBorders := true;
    rotation := 0.00000000;
    size := 0.055911731;
    colorHSVA := [273.13718, 0.81999999, 0.13320202, 1.0000000];
    _weight := 1;
    onKey := (e)=>{};
    update := (e)=>{};
    postStep := (e)=>{};
    timeToLive := +inf;
    entityID := 726;
    resources := [];
    color := [0.084300190, 0.023976363, 0.13320202, 1.0000000];
    onSpawn := (e)=>{};
    zDepth := 6.0000000;
    onDie := (e)=>{};
    onClick := (e)=>{};
    layer := 0
};
Scene.addLineEndPoint {
    geom := 6676637;
    relPoint := [0.00000000, 0.00000000];
    followGeometry := true;
    opaqueBorders := true;
    rotation := 0.00000000;
    size := 0.027955865;
    colorHSVA := [164.67188, 0.37813368, 0.80820179, 1.0000000];
    _weight := 1;
    onKey := (e)=>{};
    update := (e)=>{};
    postStep := (e)=>{};
    timeToLive := +inf;
    entityID := 725;
    resources := [];
    color := [0.50259346, 0.80820179, 0.73012841, 1.0000000];
    onSpawn := (e)=>{};
    zDepth := 7.0000000;
    onDie := (e)=>{};
    onClick := (e)=>{};
    layer := 0
};
Scene.addSpring {
    lineEndPoint0 := 726;
    lineEndPoint1 := 725;
    legacyMode := 3;
    opaqueBorders := true;
    dampingFactor := 0.00000000;
    size := 0.069889665;
    constant := 0.00000000;
    texture := "";
    colorHSVA := [0.00000000, 1.0000000, 1.0000000, 1.0000000];
    length := 0.50000000;
    onKey := (e)=>{};
    update := (e)=>{};
    postStep := (e)=>{
        endPoint0 = (entityByID((readable(owner)).lineEndPoint0));
        endPoint1 = (entityByID((readable(owner)).lineEndPoint1));
        box0 = (entityByGeomID((readable(endPoint0)).geom));
        box1 = (entityByGeomID((readable(endPoint1)).geom));
        box1._acc = box1._acc + box0._acc * _weight * 64
    };
    allowDirectSolve := true;
    _weight := 1;
    timeToLive := +inf;
    entityID := 727;
    resources := [];
    color := [1.0000000, 0.00000000, 0.00000000, 1.0000000];
    forceDirectSolve := false;
    onSpawn := (e)=>{};
    disableCollisions := false;
    zDepth := 5.0000000;
    onDie := (e)=>{};
    onClick := (e)=>{};
    layer := 0;
    totImp := 1.0000000
}
ALL HAIL THYME!
UnityDogGaming04
 
Posts: 17
Joined: Tue Oct 05, 2021 8:35 pm
Location: Buckeye, AZ

Re: How to make better spring-based neurons

Postby UnityDogGaming04 » Sun Oct 10, 2021 7:01 am

Nevermind, I found a way to do it all! Check this scene for hastily-excitedly-written details! Super excited about actually getting these to work exactly as I want!
http://www.algodoo.com/algobox/details.php?id=244329
ALL HAIL THYME!
UnityDogGaming04
 
Posts: 17
Joined: Tue Oct 05, 2021 8:35 pm
Location: Buckeye, AZ


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 4 guests

cron