'Another neural network test
'Just trying to figure out whats possible

'i1 : *.eye5
'i2 : *.refshoot *.myshoot !=
'i3 : *.refxpos *.refypos angle
'i4 : *.body
'-------
'o1 : .shoot
'o2 : .up
'o3 : .setaim
'o4 : .repro

def maxangle 1364
def maxeye 100
def maxbody 2000
def bias 1

def wi1h1 10
def wi2h1 200
def wi3h1 0
def wi4h1 0

def wi1h2 -10
def wi2h2 400
def wi3h2 0
def wi4h2 0

def wi1h3 0
def wi2h3 150
def wi3h3 0
def wi4h3 0

def wi1h4 0
def wi2h4 0
def wi3h4 500
def wi4h4 0

def wi1h5 0
def wi2h5 0
def wi3h5 0
def wi4h5 500

def wh1o1 500
def wh1o2 -200
def wh1o3 0
def wh1o4 0

def wh2o1 0
def wh2o2 50
def wh2o3 0
def wh2o4 0

def wh3o1 0
def wh3o2 300
def wh3o3 -100
def wh3o4 0

def wh4o1 0
def wh4o2 0
def wh4o3 500
def wh4o4 0

def wh5o1 0
def wh5o2 0
def wh5o3 0
def wh5o4 500


def h1 51
def h2 52
def h3 53
def h4 54
def h5 55



cond
*.robage 0 =
start
0 .shoot store
stop

start
.bias .h1 store
.bias .h2 store
.bias .h3 store
.bias .h4 store
.bias .h5 store
stop



'********** Inputs
'======= h1
'--- i1
start
 *.eye5 
stop

start
 200 mult .maxeye div 100 sub
stop

start
 .wi1h1 mult
stop

start
 100 div
stop

start
 *.h1 add .h1 store
stop


'--- i2
start
 *.refshoot *.myshoot sub abs sgn 200 mult 100 sub
stop

start
 .wi2h1 mult
stop

start
 100 div
stop

start
 *.h1 add .h1 store
stop


'--- i3
start
 *.refxpos *.refypos angle .maxangle mod
stop

start
 200 mult .maxangle div 100 sub
stop

start
 .wi3h1 mult
stop

start
 100 div
stop

start
 *.h1 add .h1 store
stop


'--- i4
start
 *.body
stop

start
 200 mult .maxbody div 100 sub
stop

start
 .wi4h1 mult
stop

start
 100 div
stop

start
 *.h1 add .h1 store
stop

start
 *.h1 5 div .h1 store
stop



'======= h2
'--- i1
start
 *.eye5 

 200 mult .maxeye div 100 sub

 .wi1h2 mult

 100 div

 *.h2 add .h2 store
stop


'--- i2
start
 *.refshoot *.myshoot sub abs sgn 200 mult 100 sub

 .wi2h2 mult

 100 div

 *.h2 add .h2 store
stop
 

'--- i3
start
 *.refxpos *.refypos angle .maxangle mod

 200 mult .maxangle div 100 sub

 .wi3h2 mult

 100 div

 *.h2 add .h2 store
stop


'--- i4
start
 *.body

 200 mult .maxbody div 100 sub

 .wi4h2 mult

 100 div

 *.h2 add .h2 store
stop

start
 *.h2 5 div .h2 store
stop



'======= h3
'--- i1
start
 *.eye5 

 200 mult .maxeye div 100 sub

 .wi1h3 mult

 100 div

 *.h3 add .h3 store
stop


'--- i2
start
 *.refshoot *.myshoot sub abs sgn 200 mult 100 sub

 .wi2h3 mult

 100 div

 *.h3 add .h3 store
stop


'--- i3
start
 *.refxpos *.refypos angle .maxangle mod

 200 mult .maxangle div 100 sub

 .wi3h3 mult

 100 div

 *.h3 add .h3 store
stop


'--- i4
start
 *.body

 200 mult .maxbody div 100 sub

 .wi4h3 mult

 100 div

 *.h3 add .h3 store
stop

start
 *.h3 5 div .h3 store
stop


'======= h4
'--- i1
start
 *.eye5 

 200 mult .maxeye div 100 sub

 .wi1h4 mult

 100 div

 *.h4 add .h4 store
stop


'--- i2
start
 *.refshoot *.myshoot sub abs sgn 200 mult 100 sub

 .wi2h4 mult

 100 div

 *.h4 add .h4 store
stop


'--- i3
start
 *.refxpos *.refypos angle .maxangle mod

 200 mult .maxangle div 100 sub

 .wi3h4 mult

 100 div

 *.h4 add .h4 store
stop


'--- i4
start
 *.body

 200 mult .maxbody div 100 sub

 .wi4h4 mult

 100 div

 *.h4 add .h4 store
stop

start
 *.h4 5 div .h4 store
stop


'======= h5
'--- i1
start
 *.eye5 

 200 mult .maxeye div 100 sub

 .wi1h5 mult

 100 div

 *.h5 add .h5 store
stop


'--- i2
start
 *.refshoot *.myshoot sub abs sgn 200 mult 100 sub

 .wi2h5 mult

 100 div

 *.h5 add .h5 store
stop


'--- i3
start
 *.refxpos *.refypos angle .maxangle mod

 200 mult .maxangle div 100 sub

 .wi3h5 mult

 100 div

 *.h5 add .h5 store
stop


'--- i4
start
 *.body

 200 mult .maxbody div 100 sub

 .wi4h5 mult

 100 div

 *.h5 add .h5 store
stop

start
 *.h5 5 div .h5 store
stop


'in
'-----------------------------------------------------------------
'out


'********** Outputs
'======= o1
start
 *.h1

 .wh1o1 mult

 *.h2

 .wh2o1 mult

 add

 *.h3

 .wh3o1 mult

 add

 *.h4

 .wh4o1 mult

 add

 *.h5

 .wh5o1 mult

 add

 100 div 

 5 div

 sgn 1 mult - 0 ceil

.shoot store
stop


'======= o2
start
 *.h1
stop

start
 .wh1o2 mult
stop

start
 *.h2
stop

start
 .wh2o2 mult
stop

start
 add
stop

start
 *.h3
stop

start
 .wh3o2 mult
stop

start
 add
stop

start
 *.h4
stop

start
 .wh4o2 mult
stop

start
 add
stop

start
 *.h5
stop

start
 .wh5o2 mult
stop

start
 add
stop

start
 100 div 
stop

start
 5 div
stop

start
 *.maxvel mult 100 div
stop

start
 .up store
stop



'======= o3
start
 *.h1
stop

start
 .wh1o3 mult
stop

start
 *.h2
stop

start
 .wh2o3 mult
stop

start
 add
stop

start
 *.h3
stop

start
 .wh3o3 mult
stop

start
 add
stop

start
 *.h4
stop

start
 .wh4o3 mult
stop

start
 add
stop

start
 *.h5
stop

start
 .wh5o3 mult
stop

start
 add
stop

start
 100 div 
stop

start
 5 div
stop

start
 100 add 2 div .maxangle mult 100 div
stop

start
 .setaim store
stop




'======= o4
start
 *.h1
stop

start
 .wh1o4 mult
stop

start
 *.h2
stop

start
 .wh2o4 mult
stop

start
 add
stop

start
 *.h3
stop

start
 .wh3o4 mult
stop

start
 add
stop

start
 *.h4
stop

start
 .wh4o4 mult
stop

start
 add
stop

start
 *.h5
stop

start
 .wh5o4 mult
stop

start
 add
stop

start
 100 div 
stop

start
 5 div
stop

start
 sgn 50 mult 0 floor
stop

start
 .repro store
stop


'----- some regular genes, it does fine without them, but they help a litle. (Not going to increase this network...)

cond
*.nrg *.body 3 mult >
start
100 .strbody store
stop

cond
*.fertilized 5 >
*.nrg 1000 >
*.body 200 >
*.robage 50 >
start
40 .sexrepro store
stop

cond
*.robage 300 >
*.nrg 1000 >
*.body 500 >
*.kills 5 >
*.eye5 0 >
*.refshoot *.myshoot =
*.robage 350 mod 300 >
start
-8 .shoot store
*.refxpos *.refypos angle .setaim store
*.refvelup 5 add .up store
stop

end