-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode-run.js
82 lines (75 loc) · 2.5 KB
/
node-run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var util = require('util');
_ = require('./underscore-min.js')._;
require('./ladds_object.js');
require('./graph_prototype.js');
function Graph() {
this.node_hash = {};
this.streets = [];
this.out = function(txt) {console.info(txt);};
}
Graph.prototype = Graph_prototype;
var g = new Graph();
g.graph = Ladds;
g.initialize_node_data();
var p1 = g.generate_loop();
var score1 = g.score(p1);
var p2 = g.generate_loop();
var score2 = g.score(p2);
var parents = [p1,p2];
console.info('Adam and Eve:');
console.info(util.inspect(score1));
console.info('file:///Users/davemiller/Ladds/index.html#' + p1.toString());
console.info(util.inspect(score2));
console.info('file:///Users/davemiller/Ladds/index.html#' + p2.toString());
console.info('********');
var best = _.last([score1,score2].sort(g.sort_score));
while(true) {
var children = g.breed(p1,p2);
console.info('children:', children.length);
for(var i=0;i<children.length;i++) {
var score = g.score(children[i]);
if (g.sort_score(score,best) == 1) {
best = score;
p1 = children[i];
console.info(score);
console.info('file:///Users/davemiller/Ladds/index.html#' + p1.toString());
}
}
p2 = g.generate_loop();
}
// var max = _.first([score1,score2].sort(g.sort_score));
// var prodigies = [p1,p2];
// while(true) {
// var children = g.breed(p1,p2);
// console.info('children:', children.length);
// var prodigy_max = max;
// for(var i=0;i<children.length;i++){
// var score = g.score(children[i]);
// if (g.sort_score(children[i], prodigy_max) > 0) {
// prodigies.push(children[i]);
// prodigies.sort(g.sort_score);
// if (prodigies.length > 4) prodigies.slice(0,1);
// prodigy_max = _.first(prodigies);
// }
// }
// while (prodigies.length < 4) prodigies.push(g.generate_loop());
// var grandchildren = g.breed(prodigies[0], prodigies[1]).concat(g.breed(prodigies[2], prodigies[3]));
// console.info('grandchildren:', grandchildren.length);
// for(var i=0;i<grandchildren.length;i++){
// var score = g.score(grandchildren[i]);
// if (g.sort_score(score, max) > 0) {
// max = score;
// p1 = grandchildren[i];
// console.info(util.inspect(score));
// console.info('file:///Users/davemiller/Ladds/index.html#' + p1.toString());
// }
// }
// var hot = g.hot_nodes(p1);
// if (_.isEmpty(hot)) {
// p2 = g.generate_loop();
// } else {
// console.info('*' + hot.toString());
// p2 = g.generate_hot_loop( hot );
// }
// prodigies = [p1];
// }