Skip to content

Instantly share code, notes, and snippets.

@kexoth
Created April 30, 2013 15:52
Show Gist options
  • Save kexoth/5489623 to your computer and use it in GitHub Desktop.
Save kexoth/5489623 to your computer and use it in GitHub Desktop.
Evolving
evolveWeight: function () {
var step = 0.01;
var index_to_decrease = Enemy.TypeWeight.indexOf(getBiasedRandomItem(Enemy.TypeWeight, Enemy.TypeWeight));
var min = Math.min.apply(Math, Enemy.TypeWeight);
var index_to_increase = Enemy.TypeWeight.indexOf(min);
Enemy.TypeWeight[index_to_increase] += step;
Enemy.TypeWeight[index_to_decrease] -= step;
cc.log("Weight: " + Enemy.TypeWeight);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment