Move dots until connection do not intersect. Each level will have 1 more dot, and become easier overtime.
_='setInterval(rn,337pG,lG,H=3,mx,my,ck,U=-1,dsmove$mx%X;my%Y}down$ck_Qmx,my)F(U=i)}up$ck;U=-1}; gl(H++;pG;lGpLx:Cy:y=D})k=i+1lLf:i,:k}7k=4i=kidd,fgAb9;bAbmAe9;eAehAd9;dAdnAf9;fAf@; 0>((fzme(fzgb)F0>(qbhdqbnf)?0:1did,f(bzb-d)+qfe-f)dtdd;;8arc15,0,67Vda(8lineWid`=2;Oc,,8mov^f9jf@),8lin^9j@),OVch(s_kKN,p)if(i!=kFQk9jk@)KZ;s;break}cNl)i==kfJfJfJJf||id(lf,l,f,)||(lcZ,s7 srn("#aaa";Rect(0,0,CD7ckF-1<UF(U9=mxjU@=my7chVFglVdtK7da(71E3<ds++F(ds,)};function[i l[k Ma`.randomV*for(;i<H;i++)l.splice(~~(l.leng`),1) in ].(px,pyjp[8fill)*(;onmouse-h)/(n-h+.1)+d--g)/(m-g+.1)+b-var (b,e,8beginPa`V){;i} returnStyle=;k<H;k++)||l=0tokl)$=(b%=b.client7);8c.9 x@ yA=Ca.wid`,Da.heightF&&G=[]HlvlJ==KpclL.push({N="Blue"O8strokeQ400>diUdpV()Z="Red"^eTo(_=1p)`thj,q(e-z-d@;';for(Y in $='zqj`_^ZVUQONLKJHGFDCA@987%$ ')with(_.split($[Y]))_=join(pop());eval(_)
Xz0nc2V0SW50ZXJ2YWwocm4sMzM3E3BHLGxHLEg9MyxteCxteSxjax0sVT0tMSxkcx0QbW92ZSRteCVYO215JVl9EGRvd24kY2tfUW14LG15KUYoVT1pKX0QdXAkY2sdO1U9LTF9OwEgZ2woFkgrKztwRztsRxcdBnBMeDoEQ3k6eT0ERH0pFx0GBWs9aSsxG2xMZjppLB46a303BWs9NBsFaT1rBgcYaWQUZCxmFhNnQWI5O2JBYn9tQWU5O2VBZX9oQWQ5O2RBZH9uQWY5O2ZBZkA7GSAwPigoZnptEWUPKGZ6ZxFiKUYwP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var level=3;
var mx;
var my;
var clicked=false;
var draggingPoint=-1;
var desperation=0;
a.addEventListener("mousemove", function (e) { mx=e.clientX; my=e.clientY;});
a.addEventListener("mousedown", function (e) {
clicked=true;
for(i in points)
if( distance(points[i].x, points[i].y,mx,my) < 400)
draggingPoint=i;
});
a.addEventListener("mouseup", function (e) { clicked=false; draggingPoint=-1;});
function generateLevel()
{
level++;
points=[];
links=[];
//points
for(i=0;i<level;i++)
points.push({ x: Math.random()*a.width , y:y=Math.random()*a.height});
//links
for(i=0;i<level;i++)
for(k=i+1;k<level;k++)
links.push({from: i, to: k});
//make it solvable, kinda.
for(k=4;k<level;k++)
for(i=k;i<level;i++)
links.splice(~~(Math.random()*links.length),1)
}
function indipendenti(a,b,a1,b1)
{
//console.log("Controllo "+a+"-"+b+" con "+a1+"-"+b1);
var x = points[a].x;
var y = points[a].y;
var x1 = points[b].x;
var y1 = points[b].y;
var x2 = points[a1].x;
var y2 = points[a1].y;
var x3 = points[b1].x;
var y3 = points[b1].y;
//TRUST PAST ME.
if (
((y3-y2) * (x1-x2) / (x3-x2+0.1) + y2 - y1) *
((y3-y2) * (x-x2 ) / (x3-x2+0.1) + y2 - y ) < 0
&&
((y1-y) * (x2-x) / (x1-x +0.1) + y - y2) *
((y1-y) * (x3-x) / (x1-x +0.1) + y - y3) < 0)
return false;
return true;
}
function distance(ax,ay,bx,by)
{
return (ax-bx)*(ax-bx)+(ay-by)*(ay-by);
}
function drawPoint(x,y,color)
{
c.fillStyle=color;
c.beginPath();
c.arc(x,y,15,0,6);
c.fill();
}
function drawAllConnections()
{
c.lineWidth=2;
for(k in links)
{
c.strokeStyle=links[k].c;
c.beginPath();
c.moveTo(points[links[k].from].x,points[links[k].from].y);
c.lineTo(points[links[k].to].x,points[links[k].to].y);
c.stroke();
}
return;
}
//controlla e colora
function check()
{
allSafe=true;
//collisioni dei punti
for(i in points)
{
points[i].color="Blue";
for(k in points)
{
if(i==k)
continue;
if(distance(points[i].x,points[i].y,points[k].x,points[k].y)<400)
{
points[i].color="Red";
allSafe=false;
break;
}
}
}
//reset colori
for(k in links)
links[k].c="Blue";
//collisioni dei link
for(i in links)
for(k in links)
{
if(i==k || links[i].from==links[k].from || links[i].to==links[k].to || links[i].from==links[k].to || links[i].to==links[k].from)
continue;
if(!indipendenti(links[i].from, links[i].to, links[k].from, links[k].to))
{
links[i].c="Red";
//links[k].c="Red";
allSafe=false;
}
}
return allSafe;
}
function run()
{
//draw the background
c.fillStyle="Silver";
c.fillRect(0,0,a.width,a.height);
if(clicked && draggingPoint > -1)
{
points[draggingPoint].x=mx;
points[draggingPoint].y=my;
}
if(check())
generateLevel();
//Draw the points
for(i=0;i<level;i++)
drawPoint(points[i].x,points[i].y,points[i].color);
drawAllConnections();
//if you are desperated, we make the game easier
if(desperation++>1000)
{
desperation=0;
links.splice(~~(Math.random()*links.length),1)
}
}