Skip to content

Commit

Permalink
Fixed DRUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
ZombieStriker authored Oct 29, 2017
1 parent 0bb5060 commit af742d1
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 133 deletions.
6 changes: 6 additions & 0 deletions src/me/zombie_striker/neuralnetwork/NNAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public static NNAI generateAI(NNBaseEntity nnEntityBase,

public boolean[] think() {
this.tick();
for(Layer l : this.layers){
for(Neuron n: l.neuronsInLayer){
n.forceTriggerStengthUpdate();
}
}
boolean[] points = new boolean[getOutputNeurons().size()];
for (Neuron n : getOutputNeurons()) {
if (n.isTriggered()) {
Expand Down Expand Up @@ -189,6 +194,7 @@ public NNAI(Map<String, Object> map) {
if (n != null) {
n.setAI(this);
addNeuron(n);
//getNeuronsInLayer(n.layer).add(n);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/me/zombie_striker/neuralnetwork/NNBaseEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public void randomizeNeurons(){
}

public boolean[] tickAndThink(){
ai.tick();
return ai.think();
}

Expand Down
2 changes: 1 addition & 1 deletion src/me/zombie_striker/neuralnetwork/neurons/Neuron.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Neuron(NNAI ai, int layer) {
}

public boolean isTriggered() {
return getTriggeredStength() > threshold;
return getThreshold() < getTriggeredStength();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
import me.zombie_striker.neuralnetwork.senses.Senses2D;
import me.zombie_striker.neuralnetwork.senses.Sensory2D_Numbers;

/**
* DO NOT USE. Still updating!
* @author ZombieStriker
*
*/

public class InputBlockNeuron extends InputNeuron {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,24 @@ public static InputNeuron generateNeuronStatically(NNAI ai, int index,
if(letters[index2]==letter)
break;
InputNeuron link = new InputLetterNeuron(ai, index, index2, sl);
// link.addNeuronData(ai);
return link;
}
public static InputNeuron generateNeuronStatically(NNAI ai, int index,
int letter, Sensory2D_Letters sl) {
InputNeuron link = new InputLetterNeuron(ai, index, letter, sl);
// link.addNeuronData(ai);
return link;
}

@Override
public boolean isTriggered() {
//if (((Sensory2D_Letters) s).getWord().length() > xlink)
if (((Sensory2D_Letters) s).getCharacterAt(xlink) == letter)
return true;
return false;
}

public InputLetterNeuron(Map<String, Object> map) {
super(map);
this.letter=(char) map.get("char");
this.letter= (map.get("char")+"").toCharArray()[0];
}
@Override
public Map<String, Object> serialize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
import me.zombie_striker.neuralnetwork.NNAI;
import me.zombie_striker.neuralnetwork.senses.*;

/**
* DO NOT USE. Still updating!
* @author ZombieStriker
*
*/
public class InputMobNeuron extends InputNeuron {

public InputMobNeuron(NNAI ai,Sensory2D_Numbers sn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class InputNeuron extends Neuron {
public int ylink;
public int zlink;

protected Senses s;
public Senses s;


///public Sensory_Vision entitiesVision;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/

import java.util.Map;

import me.zombie_striker.neuralnetwork.NNAI;
import me.zombie_striker.neuralnetwork.senses.*;

Expand All @@ -27,6 +29,10 @@ public InputNumberNeuron(NNAI ai, Sensory2D_Numbers sl) {
this.s = sl;
}

public InputNumberNeuron(Map<String,Object> map) {
super(map);
}

public InputNumberNeuron(NNAI ai, int row, int col,
Sensory2D_Numbers sl) {
super(ai, row, col,sl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
import me.zombie_striker.neuralnetwork.NNAI;
import me.zombie_striker.neuralnetwork.senses.*;

/**
* DO NOT USE. Still updating!
* @author ZombieStriker
*
*/
public class InputTickNeuron extends InputNeuron {

int maxTick=0;
Expand Down
14 changes: 10 additions & 4 deletions src/me/zombie_striker/neuralnetwork/senses/Sensory2D_Letters.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class Sensory2D_Letters implements Senses2D{


private char[] letters= InputLetterNeuron.letters;
private String word;
private String fullWord;
private String word="null";
private String fullWord="null";
public static final int MAX_LETTERS = 19;

@Override
Expand All @@ -49,7 +49,15 @@ public Sensory2D_Letters(String word) {
}

public char getCharacterAt(int index) {
if(fullWord==null)return ' ';
try{
return fullWord.charAt(index);
}catch(Exception e){
/**
* Seriously, I have tried doing a length check, a null check. Do I seriously need to add a catch statement?>
*/
return ' ';
}
}
public String getWord(){
return word;
Expand All @@ -64,8 +72,6 @@ public void changeWord(String word) {
fullWord = sb.toString();
}
public Sensory2D_Letters(Map<String, Object> map) {
word = null;
fullWord=null;
}

@Override
Expand Down
Loading

0 comments on commit af742d1

Please sign in to comment.