Example #1
0
 // /////////////////////////////////////////////////////////////////////////////////////////
 // BRAIN FUNCTIONS
 // TODO: implementar esses métodos em brainActions().
 public void train() {
   for (int i = 0; i < repeat_teaching; i++) {
     float r = p.random(1);
     if (r < 0.25f) {
       brain.setInput(0, p.random(0.5f, 1f));
       brain.setInput(1, p.random(0.5f, 1f));
       brain.setDesiredOutput(0, 1f);
       brain.setDesiredOutput(1, 0f);
       brain.feedForward();
       brain.backPropagate();
     } else if (r >= 0.25f && r < 0.5f) {
       brain.setInput(0, p.random(0f, 0.5f));
       brain.setInput(1, p.random(0f, 0.5f));
       brain.setDesiredOutput(0, 0.5f);
       brain.setDesiredOutput(1, 0.5f);
       brain.feedForward();
       brain.backPropagate();
     } else if (r >= 0.5f && r < 0.75f) {
       brain.setInput(0, p.random(0.5f, 1f));
       brain.setInput(1, p.random(0f, 0.5f));
       brain.setDesiredOutput(0, 0.5f);
       brain.setDesiredOutput(1, 0.5f);
       brain.feedForward();
       brain.backPropagate();
     } else {
       brain.setInput(0, p.random(0f, 0.5f));
       brain.setInput(1, p.random(0f, 0.5f));
       brain.setDesiredOutput(0, 0f);
       brain.setDesiredOutput(1, 0f);
       brain.feedForward();
       brain.backPropagate();
     }
   }
 }
Example #2
0
 public void ask(float inOne, float inTwo) {
   brain.setInput(0, inOne);
   brain.setInput(1, inTwo);
   brain.feedForward();
   // p.println(id + ": " + "output 0   " + brain.getOutput(0));
   // p.println(id + ": " + "output 1   " + brain.getOutput(1));
 }