From 6277a1100612989cf5913241d5dd168a8855b42f Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Fri, 10 Jul 2020 22:22:43 -0400 Subject: [PATCH] evaluate distance between path end and next path start --- src/algorithm.js | 12 ++++++------ src/main.js | 51 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/algorithm.js b/src/algorithm.js index 5eaeb71..a62581e 100644 --- a/src/algorithm.js +++ b/src/algorithm.js @@ -34,7 +34,7 @@ function tribulate() { //for(var i=0; i>1; i 0.5){ seq.reverse(); @@ -133,7 +133,7 @@ function preciseMutate(orseq) { //alert(bestv); return seq; } -function preciseMutate1(orseq) { +function preciseMutate1(orseq) { var seq = orseq.clone(); var bestv = evaluate(seq); @@ -246,7 +246,7 @@ function countDistances() { for(var i=0; i= 0; j--) { + let xy = getXY(some.followingLines[j]); + if (xy[0] !== false && xy[1] !== false) { + some.endsAt = { x: xy[0], y: xy[1] }; + break; + } + } + } + // add notG0 to the followingLines for the last entry in allG0 // this gets the lines after the last G0 in the file // we also need to check if the commands here are not G0, G1, G2, G3, or G4 @@ -196,16 +208,7 @@ r.onload = function(e) { sf = yf; } - for (var p=0; p= 3) { initData(); GAInitialize(); @@ -304,7 +307,8 @@ function initData() { roulette = new Array(POPULATION_SIZE); } -function drawCircle(point) { +function drawCircle(point, fillStyle = '#000') { + ctx.fillStyle = fillStyle; ctx.fillStyle = '#000'; ctx.beginPath(); ctx.arc(point.x, point.y, 3, 0, Math.PI*2, true); @@ -321,9 +325,15 @@ function drawLines(array) { ctx.moveTo(points[array[0]].x, points[array[0]].y); // loop through and draw lines to each other point - for(var i=1; i