From c2b94b30fd4bcc679bcd09c38eabe4596b64d1c5 Mon Sep 17 00:00:00 2001 From: "T. Teijeiro" Date: Tue, 21 Jun 2016 12:03:38 +0200 Subject: [PATCH] =?UTF-8?q?Inicializaci=C3=B3n=20ad-hoc=20de=20todos=20os?= =?UTF-8?q?=20xenes.=20A=20Pablo=20non=20lle=20gusta,=20pero=20a=20respons?= =?UTF-8?q?abilidade=20e=20o=20sentido=20de=20estado=20fanlle=20ceder=20ne?= =?UTF-8?q?sta=20li=C3=B1a=20vermella.=20O=20pobo=20agradecerallo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/Invader.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/js/Invader.js b/js/Invader.js index e032c52..2e5206c 100644 --- a/js/Invader.js +++ b/js/Invader.js @@ -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; }(); -- GitLab