Commit c2b94b30 authored by Tomás Teijeiro Campo's avatar Tomás Teijeiro Campo

Inicialización ad-hoc de todos os xenes. A Pablo non lle gusta, pero a...

Inicialización ad-hoc de todos os xenes. A Pablo non lle gusta, pero a responsabilidade e o sentido de estado fanlle ceder nesta liña vermella. O pobo agradecerallo.
parent 937680ad
......@@ -40,23 +40,14 @@ invadersApp.Invader = function (ctx, genes, x, y) {
// Initialize genes by getting the default values from settings.json
this.genes = genes || function () {
var settings = ctx.settings;
var genes = {};
for (var gen in settings.genes) {
var min = settings.genes[gen].min;
var max = settings.genes[gen].max;
//genes[gen] = chance.normal({mean: ((max-min)/2)+min, dev: (max-min)/6});
genes[gen] = chance.floating({min: settings.genes[gen].min, max: settings.genes[gen].max});
//genes[gen] = chance.normal({mean: settings.genes[gen].mean, dev: (max - min) / 6});
//if (genes[gen] < min) genes[gen] = min;
//if (genes[gen] > max) genes[gen] = max;
}
var genes = {};
//TODO guarrada para comprobar a influencia da primeira xeración
// genes['scale'] = bound_value(gammavariate(4, 0.5) + 1, 1, 7);
// genes['alpha'] = chance.integer({min: 20, max: 255});
// genes['xvelocity'] = 120 * bound_value(gammavariate(2, 0.4), 0.01, 5);
// genes['yvelocity'] = 120 * bound_value(gammavariate(2, 0.3), 0.01, 5);
// genes['x_prob_change_dir'] = chance.floating({min: 0.01, max: 0.05});
// genes['y_prob_change_dir'] = chance.floating({min: 0.01, max: 0.05});
genes['scale'] = bound_value(gammavariate(4, 0.5) + 1, 1, 7);
genes['alpha'] = chance.integer({min: 20, max: 255});
genes['xvelocity'] = 120 * bound_value(gammavariate(2, 0.4), 0.01, 5);
genes['yvelocity'] = 120 * bound_value(gammavariate(2, 0.3), 0.01, 5);
genes['x_prob_change_dir'] = chance.floating({min: 0.01, max: 0.05});
genes['y_prob_change_dir'] = chance.floating({min: 0.01, max: 0.05});
return genes;
}();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment