- Author:
- Lác Neobým Helkár
- Twitter:
- @
- GitHub:
- kipkat
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- Compo:
- canvas
- Demo link:
- https://js1k.com/2019-x/demo/4143
- Shortlink:
- https://js1k.com/4143
- Blog post:
- please update here!
- Bytes:
- 910
- Chars:
- 910
- Submission
R=0;r=Math.random,A=K=>K/(K+1)-K*Math.sin(3.14/K);function l(e,X,Y){this.x=X;this.y=Y;this.v=this.b=0;this.e=e;this.N=[0];this.m=p=>{this.v+=Math.sin((this.e*this.x^this.e*this.y)/R+this.N[r()*this.N.length|0]*7+A(this.e)*this.e)/this.e;this.b+=Math.sin((this.e*this.x|this.e*this.y)/R+this.e**2+this.N[r()*this.N.length|0]*7)/this.e;this.x+=(this.v%=1)/this.e*5;this.y+=(this.b%=1)/this.e*5;if(this.x<0)this.x=a.width;if(this.x>a.width)this.x=0;if(this.y<0)this.y=a.height;if(this.y>a.height)this.y=0;c.fillStyle=`hsl(${this.v*this.b*this.e+this.N.length*this.e/9},99%,50%)`,c.fillRect(this.x-this.e/2,this.y-this.e/2,this.e,this.e);this.N.push((this.el*this.x^this.el*this.y)/(this.v+this.b+this.N[r()*this.N.length|0])+A(this.e**this.e))}};Q=[];f=A=>{c.fillStyle='#00000009';c.fillRect(0,0,a.width,a.height);for(i of Q)i.m();if(R<a.width/5)Q.push(new l(2+r()*8,a.width/2,a.height/2));R++};setInterval(f,9)
- Description
- Little neural networks eXploring the canvas - no interaction
- Base64 encoded
Uj0wO3I9TWF0aC5yYW5kb20sQT1LPT5LLyhLKzEpLUsqTWF0aC5zaW4oMy4xNC9LKTtmdW5jdGlvbiBsKGUsWCxZKXt0aGlzLng9WDt0aGlzLnk9WTt0aGlzLnY9dGhpcy5iPTA7dGhpcy5lPWU7dGhpcy5OPVswXTt0aGlzLm09cD0+e3RoaXMudis9TWF0aC5zaW4oKHRoaXMuZSp0aGlzLnhedGhpcy5lKnRoaXMueSkvUit0aGlzLk5bcigpKnRoaXMuTi5sZW5ndGh8MF0qNytBKHRoaXMuZSkqdGhpcy5lKS90aGlzLmU7dGhpcy5iKz1NYXRoLnNpbigodGhpcy5lKnRoaXMueHx0aGlzLmUqdGhpcy55KS9SK3RoaXMuZSoqMit0aGlzLk5bcigpKnRoaXMuTi5sZW5ndGh8MF0qNykvdGhpcy5lO3RoaXMueCs9KHRoaXMudiU9MSkvdGhpcy5lKjU7dGhpcy55Kz0odGhpcy5iJT0xKS90aGlzLmUqNTtpZih0aGlzLng8MCl0aGlzLng9YS53aWR0aDtpZih0aGlzLng+YS53aWR0aCl0aGlzLng9MDtpZih0aGlzLnk8MCl0aGlzLnk9YS5oZWlnaHQ7aWYodGhpcy55PmEuaGVpZ2h0KXRoaXMueT0wO2MuZmlsbFN0eWxlPWBoc2woJHt0aGlzLnYqdGhpcy5iKnRoaXMuZSt0aGlzLk4ubGVuZ3RoKnRoaXMuZS85fSw5OSUsNTAlKWAsYy5maWxsUmVjdCh0aGlzLngtdGhpcy5lLzIsdGhpcy55LXRoaXMuZS8yLHRoaXMuZSx0aGlzLmUpO3RoaXMuTi5wdXNoKCh0aGlzLmVsKnRoaXMueF50aGlzLmVsKnRoaXMueSkvKHRoaXMudit0aGlzLmIrdGhpcy5OW3IoKSp0aGlzLk4ubGVuZ3RofDBdKStBKHRoaXMuZSoqdGhpcy5lKSl9fTtRPVtdO2Y9QT0+e2MuZmlsbFN0eWxlPScjMDAwMDAwMDknO2MuZmlsbFJlY3QoMCwwLGEud2lkdGgsYS5oZWlnaHQpO2ZvcihpIG9mIFEpaS5tKCk7aWYoUjxhLndpZHRoLzUpUS5wdXNoKG5ldyBsKDIrcigpKjgsYS53aWR0aC8yLGEuaGVpZ2h0LzIpKTtSKyt9O3NldEludGVydmFsKGYsOSkNCg==
- Original source
// messy because I commented after the golfing and now it looks weird. not golfed enough i know
R=0
r=Math.random
A=K=>K/(K+1)-K*Math.sin(3.14/K) // small chain activation
function l(e,X,Y)
{
this.x=X
this.y=Y
this.v=this.b=0 // velocities
this.e=e // property number
this.N=[0] // neural data
this.m=p=>
{
this.v+=Math.sin((this.e*this.x^this.e*this.y)/R+
this.N[r()*this.N.length|0]*7+A(this.e)*this.e)/this.e // velocity X
this.b+=Math.sin((this.e*this.x|this.e*this.y)/R+
this.e**2+this.N[r()*this.N.length|0]*7)/this.e // velocity Y
this.x+=(this.v%=1)/this.e*5
this.y+=(this.b%=1)/this.e*5
// canvas size limiting start
if(this.x<0)this.x=a.width
if(this.x>a.width)this.x=0
if(this.y<0)this.y=a.height
if(this.y>a.height)this.y=0
// canvas size limiting end
c.fillStyle=`hsl(${this.v*this.b*this.e+
this.N.length*this.e/9},99%,50%)` // color
c.fillRect(this.x-this.e/2,this.y-this.e/2,this.e,this.e)
this.N.push(
(this.el*this.x^this.el*this.y)/
(this.v+this.b+this.N[r()*this.N.length|0])+
A(this.e**this.e) // neural data
)
}
}
Q=[] // the array of the cells
f=A=> // main drawing function
{
c.fillStyle='#00000009' // little alpha for trailing effect
c.fillRect(0,0,a.width,a.height)
for(i of Q)
i.m()
if(R<a.width/5) // optimization condition
Q.push(new l(2+r()*8,a.width/2,a.height/2));R++ // add cells for first frames
}
setInterval(f,9) // draw function looper