Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let loopLymphocytes = function () {
- ...
- // update each creature
- let lymphocytes = world.lymphocytes;
- let bacterias = world.bacterias;
- lymphocytes.forEach(function (creature) {
- // move
- let input = [];
- for (let i in bacterias) {
- input.push(bacterias[i].location.x);
- input.push(bacterias[i].location.y);
- input.push(bacterias[i].velocity.x);
- input.push(bacterias[i].velocity.y);
- }
- let output = creature.network.activate(input);
- creature.moveTo(output);
- // learn
- let learningRate = .3;
- let target = [targetXLymphocyte(creature), targetYLymphocyte(creature), targetAngleLymphocyte(creature)];
- creature.network.propagate(learningRate, target);
- // draw
- creature.draw();
- });
- if (true)
- setTimeout(loopLymphocytes, 1000 / fps);
- }
Add Comment
Please, Sign In to add comment