Need Help with Simplifying Rules and reduce global variables

Mummis Modifier

2015-12-01 11:22:58

i want to play a game on my Launchpad. Ship Wars

4 Players, have to hide 5 Ships one after another (1x4pads, 2x3pads, 2x2pads)
every player use all 64 pads to hide his ships.
when all finished with that the game starts and the players alternately guess where the others ships are and gives up shots.

my problem is that i need so much global variables to save the position of the ships and to save the status of the ships
that i´m afraid there will not be enough of it.
i need to save 14x ship-positions, 5x sink-status, 64x where I have already shot down. this all x4 for 4 players.
how can i use the variables and rules more efficient to realize that ?

here a few examples of my way until now:

player 1 hides the ships:

Code: Select all

if k0!=1 then exit rules, skip Outgoing Action

if k1==0 then Goto "4-1"
if k1==1 then Goto "4-2"
if k1==2 then Goto "4-3"
if k1==3 then Goto "4-4"
if k1==4 then Goto "3A-1"
if k1==5 then Goto "3A-2"
if k1==6 then Goto "3A-3"
if k1==7 then Goto "3B-1"
if k1==8 then Goto "3B-2"
if k1==9 then Goto "3B-3"
if k1==10 then Goto "2A-1"
if k1==11 then Goto "2A-2"
if k1==12 then Goto "2B-1"
if k1==13 then Goto "2B-2"
if k1==14 then exit rules, skip Outgoing Action

Label "4-1"
ka=qq
l1=l1+1
k1=k1+1
pp=1
exit rules, execute Outgoing Action
Label "4-2"
kb=qq
l1=l1+1
k1=k1+1
pp=1
exit rules, execute Outgoing Action
Label "4-3"
kc=qq
l1=l1+1
k1=k1+1
pp=1
exit rules, execute Outgoing Action
Label "4-4"
kd=qq
l1=l1+1
k1=k1+1
pp=1
exit rules, execute Outgoing Action

Label "3A-1"
ke=qq
l2=l2+1
k1=k1+1
pp=23
exit rules, execute Outgoing Action
Label "3A-2"
kf=qq
l2=l2+1
k1=k1+1
pp=23
exit rules, execute Outgoing Action
Label "3A-3"
kg=qq
l2=l2+1
k1=k1+1
pp=23
exit rules, execute Outgoing Action

Label "3B-1"
kh=qq
l3=l3+1
k1=k1+1
pp=1
exit rules, execute Outgoing Action
Label "3B-2"
ki=qq
l3=l3+1
k1=k1+1
pp=1
exit rules, execute Outgoing Action
Label "3B-3"
kj=qq
l3=l3+1
k1=k1+1
pp=1
exit rules, execute Outgoing Action

Label "2A-1"
kl=qq
l4=l4+1
k1=k1+1
pp=23
exit rules, execute Outgoing Action
Label "2A-2"
km=qq
l4=l4+1
k1=k1+1
pp=23
exit rules, execute Outgoing Action

Label "2B-1"
kn=qq
l5=l5+1
k1=k1+1
pp=1
exit rules, execute Outgoing Action
Label "2B-2"
ko=qq
l5=l5+1
k1=k1+1
pp=1
exit rules, execute Outgoing Action
player 2 gives off a shot and failed:

Code: Select all

if k0!=4 then exit rules, skip Outgoing Action

if qq==ka then exit rules, skip Outgoing Action
if qq==kb then exit rules, skip Outgoing Action
if qq==kc then exit rules, skip Outgoing Action
if qq==kd then exit rules, skip Outgoing Action
if qq==ke then exit rules, skip Outgoing Action
if qq==kf then exit rules, skip Outgoing Action
if qq==kg then exit rules, skip Outgoing Action
if qq==kh then exit rules, skip Outgoing Action
if qq==ki then exit rules, skip Outgoing Action
if qq==kj then exit rules, skip Outgoing Action
if qq==kl then exit rules, skip Outgoing Action
if qq==km then exit rules, skip Outgoing Action
if qq==kn then exit rules, skip Outgoing Action
if qq==ko then exit rules, skip Outgoing Action

if qq==0 then Goto "Pad 1-1"
if qq==1 then Goto "Pad 1-2"
if qq==2 then Goto "Pad 1-3"
if qq==3 then Goto "Pad 1-4"
if qq==4 then Goto "Pad 1-5"
if qq==5 then Goto "Pad 1-6"
if qq==6 then Goto "Pad 1-7"
if qq==7 then Goto "Pad 1-8"
if qq==16 then Goto "Pad 2-1"
if qq==17 then Goto "Pad 2-2"
if qq==18 then Goto "Pad 2-3"
if qq==19 then Goto "Pad 2-4"
if qq==20 then Goto "Pad 2-5"
if qq==21 then Goto "Pad 2-6"
if qq==22 then Goto "Pad 2-7"
if qq==23 then Goto "Pad 2-8"
if qq==32 then Goto "Pad 3-1"
if qq==33 then Goto "Pad 3-2"
if qq==34 then Goto "Pad 3-3"
if qq==35 then Goto "Pad 3-4"
if qq==36 then Goto "Pad 3-5"
if qq==37 then Goto "Pad 3-6"
if qq==38 then Goto "Pad 3-7"
if qq==39 then Goto "Pad 3-8"
if qq==48 then Goto "Pad 4-1"
if qq==49 then Goto "Pad 4-2"
if qq==50 then Goto "Pad 4-3"
if qq==51 then Goto "Pad 4-4"
if qq==52 then Goto "Pad 4-5"
if qq==53 then Goto "Pad 4-6"
if qq==54 then Goto "Pad 4-7"
if qq==55 then Goto "Pad 4-8"
if qq==64 then Goto "Pad 5-1"
if qq==65 then Goto "Pad 5-2"
if qq==66 then Goto "Pad 5-3"
if qq==67 then Goto "Pad 5-4"
if qq==68 then Goto "Pad 5-5"
if qq==69 then Goto "Pad 5-6"
if qq==70 then Goto "Pad 5-7"
if qq==71 then Goto "Pad 5-8"
if qq==80 then Goto "Pad 6-1"
if qq==81 then Goto "Pad 6-2"
if qq==82 then Goto "Pad 6-3"
if qq==83 then Goto "Pad 6-4"
if qq==84 then Goto "Pad 6-5"
if qq==85 then Goto "Pad 6-6"
if qq==86 then Goto "Pad 6-7"
if qq==87 then Goto "Pad 6-8"
if qq==96 then Goto "Pad 7-1"
if qq==97 then Goto "Pad 7-2"
if qq==98 then Goto "Pad 7-3"
if qq==99 then Goto "Pad 7-4"
if qq==100 then Goto "Pad 7-5"
if qq==101 then Goto "Pad 7-6"
if qq==102 then Goto "Pad 7-7"
if qq==103 then Goto "Pad 7-8"
if qq==112 then Goto "Pad 8-1"
if qq==113 then Goto "Pad 8-2"
if qq==114 then Goto "Pad 8-3"
if qq==115 then Goto "Pad 8-4"
if qq==116 then Goto "Pad 8-5"
if qq==117 then Goto "Pad 8-6"
if qq==118 then Goto "Pad 8-7"
if qq==119 then Goto "Pad 8-8"

Label "Pad 1-1"
if ia!=0 then exit rules, skip Outgoing Action
ia=1
exit rules, execute Outgoing Action
Label "Pad 1-2"
if ib!=0 then exit rules, skip Outgoing Action
ib=1
exit rules, execute Outgoing Action
Label "Pad 1-3"
if ic!=0 then exit rules, skip Outgoing Action
ic=1
exit rules, execute Outgoing Action
Label "Pad 1-4"
if id!=0 then exit rules, skip Outgoing Action
id=1
exit rules, execute Outgoing Action
Label "Pad 1-5"
if ie!=0 then exit rules, skip Outgoing Action
ie=1
exit rules, execute Outgoing Action
Label "Pad 1-6"
if if!=0 then exit rules, skip Outgoing Action
if=1
exit rules, execute Outgoing Action
Label "Pad 1-7"
if ig!=0 then exit rules, skip Outgoing Action
ig=1
exit rules, execute Outgoing Action
Label "Pad 1-8"
if ih!=0 then exit rules, skip Outgoing Action
ih=1
exit rules, execute Outgoing Action

Label "Pad 2-1"
if ij!=0 then exit rules, skip Outgoing Action
ij=1
exit rules, execute Outgoing Action
Label "Pad 2-2"
if ik!=0 then exit rules, skip Outgoing Action
ik=1
exit rules, execute Outgoing Action
Label "Pad 2-3"
if il!=0 then exit rules, skip Outgoing Action
il=1
exit rules, execute Outgoing Action
Label "Pad 2-4"
if im!=0 then exit rules, skip Outgoing Action
im=1
exit rules, execute Outgoing Action
Label "Pad 2-5"
if in!=0 then exit rules, skip Outgoing Action
in=1
exit rules, execute Outgoing Action
Label "Pad 2-6"
if io!=0 then exit rules, skip Outgoing Action
io=1
exit rules, execute Outgoing Action
Label "Pad 2-7"
if ip!=0 then exit rules, skip Outgoing Action
ip=1
exit rules, execute Outgoing Action
Label "Pad 2-8"
if iq!=0 then exit rules, skip Outgoing Action
iq=1
exit rules, execute Outgoing Action

Label "Pad 3-1"
if ir!=0 then exit rules, skip Outgoing Action
ir=1
exit rules, execute Outgoing Action
Label "Pad 3-2"
if is!=0 then exit rules, skip Outgoing Action
is=1
exit rules, execute Outgoing Action
Label "Pad 3-3"
if it!=0 then exit rules, skip Outgoing Action
it=1
exit rules, execute Outgoing Action
Label "Pad 3-4"
if iu!=0 then exit rules, skip Outgoing Action
iu=1
exit rules, execute Outgoing Action
Label "Pad 3-5"
if iv!=0 then exit rules, skip Outgoing Action
iv=1
exit rules, execute Outgoing Action
Label "Pad 3-6"
if iw!=0 then exit rules, skip Outgoing Action
iw=1
exit rules, execute Outgoing Action
Label "Pad 3-7"
if ix!=0 then exit rules, skip Outgoing Action
ix=1
exit rules, execute Outgoing Action
Label "Pad 3-8"
if iy!=0 then exit rules, skip Outgoing Action
iy=1
exit rules, execute Outgoing Action

Label "Pad 4-1"
if iz!=0 then exit rules, skip Outgoing Action
iz=1
exit rules, execute Outgoing Action
Label "Pad 4-2"
if i0!=0 then exit rules, skip Outgoing Action
i0=1
exit rules, execute Outgoing Action
Label "Pad 4-3"
if i1!=0 then exit rules, skip Outgoing Action
i1=1
exit rules, execute Outgoing Action
Label "Pad 4-4"
if i2!=0 then exit rules, skip Outgoing Action
i2=1
exit rules, execute Outgoing Action
Label "Pad 4-5"
if i3!=0 then exit rules, skip Outgoing Action
i3=1
exit rules, execute Outgoing Action
Label "Pad 4-6"
if i4!=0 then exit rules, skip Outgoing Action
i4=1
exit rules, execute Outgoing Action
Label "Pad 4-7"
if i5!=0 then exit rules, skip Outgoing Action
i5=1
exit rules, execute Outgoing Action
Label "Pad 4-8"
if i6!=0 then exit rules, skip Outgoing Action
i6=1
exit rules, execute Outgoing Action

Label "Pad 5-1"
if ja!=0 then exit rules, skip Outgoing Action
ja=1
exit rules, execute Outgoing Action
Label "Pad 5-2"
if jb!=0 then exit rules, skip Outgoing Action
jb=1
exit rules, execute Outgoing Action
Label "Pad 5-3"
if jc!=0 then exit rules, skip Outgoing Action
jc=1
exit rules, execute Outgoing Action
Label "Pad 5-4"
if jd!=0 then exit rules, skip Outgoing Action
jd=1
exit rules, execute Outgoing Action
Label "Pad 5-5"
if je!=0 then exit rules, skip Outgoing Action
je=1
exit rules, execute Outgoing Action
Label "Pad 5-6"
if jf!=0 then exit rules, skip Outgoing Action
jf=1
exit rules, execute Outgoing Action
Label "Pad 5-7"
if jg!=0 then exit rules, skip Outgoing Action
jg=1
exit rules, execute Outgoing Action
Label "Pad 5-8"
if jh!=0 then exit rules, skip Outgoing Action
jh=1
exit rules, execute Outgoing Action

Label "Pad 6-1"
if ji!=0 then exit rules, skip Outgoing Action
ji=1
exit rules, execute Outgoing Action
Label "Pad 6-2"
if jk!=0 then exit rules, skip Outgoing Action
jk=1
exit rules, execute Outgoing Action
Label "Pad 6-3"
if jl!=0 then exit rules, skip Outgoing Action
jl=1
exit rules, execute Outgoing Action
Label "Pad 6-4"
if jm!=0 then exit rules, skip Outgoing Action
jm=1
exit rules, execute Outgoing Action
Label "Pad 6-5"
if jn!=0 then exit rules, skip Outgoing Action
jn=1
exit rules, execute Outgoing Action
Label "Pad 6-6"
if jo!=0 then exit rules, skip Outgoing Action
jo=1
exit rules, execute Outgoing Action
Label "Pad 6-7"
if jp!=0 then exit rules, skip Outgoing Action
jp=1
exit rules, execute Outgoing Action
Label "Pad 6-8"
if jq!=0 then exit rules, skip Outgoing Action
jq=1
exit rules, execute Outgoing Action

Label "Pad 7-1"
if jr!=0 then exit rules, skip Outgoing Action
jr=1
exit rules, execute Outgoing Action
Label "Pad 7-2"
if js!=0 then exit rules, skip Outgoing Action
js=1
exit rules, execute Outgoing Action
Label "Pad 7-3"
if jt!=0 then exit rules, skip Outgoing Action
jt=1
exit rules, execute Outgoing Action
Label "Pad 7-4"
if ju!=0 then exit rules, skip Outgoing Action
ju=1
exit rules, execute Outgoing Action
Label "Pad 7-5"
if jv!=0 then exit rules, skip Outgoing Action
jv=1
exit rules, execute Outgoing Action
Label "Pad 7-6"
if jw!=0 then exit rules, skip Outgoing Action
jw=1
exit rules, execute Outgoing Action
Label "Pad 7-7"
if jx!=0 then exit rules, skip Outgoing Action
jx=1
exit rules, execute Outgoing Action
Label "Pad 7-8"
if jy!=0 then exit rules, skip Outgoing Action
jy=1
exit rules, execute Outgoing Action

Label "Pad 8-1"
if jz!=0 then exit rules, skip Outgoing Action
jz=1
exit rules, execute Outgoing Action
Label "Pad 8-2"
if j0!=0 then exit rules, skip Outgoing Action
j0=1
exit rules, execute Outgoing Action
Label "Pad 8-3"
if j1!=0 then exit rules, skip Outgoing Action
j1=1
exit rules, execute Outgoing Action
Label "Pad 8-4"
if j2!=0 then exit rules, skip Outgoing Action
j2=1
exit rules, execute Outgoing Action
Label "Pad 8-5"
if j3!=0 then exit rules, skip Outgoing Action
j3=1
exit rules, execute Outgoing Action
Label "Pad 8-6"
if j4!=0 then exit rules, skip Outgoing Action
j4=1
exit rules, execute Outgoing Action
Label "Pad 8-7"
if j5!=0 then exit rules, skip Outgoing Action
j5=1
exit rules, execute Outgoing Action
Label "Pad 8-8"
if j6!=0 then exit rules, skip Outgoing Action
j6=1
exit rules, execute Outgoing Action
player 2 gives up a shot and hits: (label: Treffer)

Code: Select all

if k0!=4 then exit rules, skip Outgoing Action

if qq==ka then Goto "Treffer 4er1"
if qq==kb then Goto "Treffer 4er2"
if qq==kc then Goto "Treffer 4er3"
if qq==kd then Goto "Treffer 4er4"
if qq==ke then Goto "Treffer 3erA1"
if qq==kf then Goto "Treffer 3erA2"
if qq==kg then Goto "Treffer 3erA3"
if qq==kh then Goto "Treffer 3erB1"
if qq==ki then Goto "Treffer 3erB2"
if qq==kj then Goto "Treffer 3erB3"
if qq==kl then Goto "Treffer 2erA1"
if qq==km then Goto "Treffer 2erA2"
if qq==kn then Goto "Treffer 2erB1"
if qq==ko then Goto "Treffer 2erB2"

exit rules, skip Outgoing Action

Label "Treffer 4er1"
l1=l1-1
if ka<200 then ka=ka+200
Goto "Treffer"
Label "Treffer 4er2"
l1=l1-1
if kb<200 then kb=kb+200
if l1!=0 then skip next rule
Goto "VollTreffer"
Goto "Treffer"
Label "Treffer 4er3"
l1=l1-1
if kc<200 then kc=kc+200
Goto "Treffer"
Label "Treffer 4er4"
l1=l1-1
if kd<200 then kd=kd+200
Goto "Treffer"

Label "Treffer 3erA1"
l2=l2-1
if ke<200 then ke=ke+200
Goto "Treffer"
Label "Treffer 3erA2"
l2=l2-1
if kf<200 then kf=kf+200
Goto "Treffer"
Label "Treffer 3erA3"
l2=l2-1
if kg<200 then kg=kg+200
Goto "Treffer"

Label "Treffer 3erB1"
l3=l3-1
if kh<200 then kh=kh+200
Goto "Treffer"
Label "Treffer 3erB2"
l3=l3-1
if ki<200 then ki=ki+200
Goto "Treffer"
Label "Treffer 3erB3"
l3=l3-1
if kj<200 then kj=kj+200
Goto "Treffer"

Label "Treffer 2erA1"
l4=l4-1
if kl<200 then kl=kl+200
Goto "Treffer"
Label "Treffer 2erA2"
l4=l4-1
if km<200 then km=km+200
Goto "Treffer"

Label "Treffer 2erB1"
l5=l5-1
if kn<200 then kn=kn+200
Goto "Treffer"
Label "Treffer 2erB2"
l5=l5-1
if ko<200 then ko=ko+200
Goto "Treffer"

Label "Treffer"
if qq==0 then Goto "Pad 1-1"
if qq==1 then Goto "Pad 1-2"
if qq==2 then Goto "Pad 1-3"
if qq==3 then Goto "Pad 1-4"
if qq==4 then Goto "Pad 1-5"
if qq==5 then Goto "Pad 1-6"
if qq==6 then Goto "Pad 1-7"
if qq==7 then Goto "Pad 1-8"
if qq==16 then Goto "Pad 2-1"
if qq==17 then Goto "Pad 2-2"
if qq==18 then Goto "Pad 2-3"
if qq==19 then Goto "Pad 2-4"
if qq==20 then Goto "Pad 2-5"
if qq==21 then Goto "Pad 2-6"
if qq==22 then Goto "Pad 2-7"
if qq==23 then Goto "Pad 2-8"
if qq==32 then Goto "Pad 3-1"
if qq==33 then Goto "Pad 3-2"
if qq==34 then Goto "Pad 3-3"
if qq==35 then Goto "Pad 3-4"
if qq==36 then Goto "Pad 3-5"
if qq==37 then Goto "Pad 3-6"
if qq==38 then Goto "Pad 3-7"
if qq==39 then Goto "Pad 3-8"
if qq==48 then Goto "Pad 4-1"
if qq==49 then Goto "Pad 4-2"
if qq==50 then Goto "Pad 4-3"
if qq==51 then Goto "Pad 4-4"
if qq==52 then Goto "Pad 4-5"
if qq==53 then Goto "Pad 4-6"
if qq==54 then Goto "Pad 4-7"
if qq==55 then Goto "Pad 4-8"
if qq==64 then Goto "Pad 5-1"
if qq==65 then Goto "Pad 5-2"
if qq==66 then Goto "Pad 5-3"
if qq==67 then Goto "Pad 5-4"
if qq==68 then Goto "Pad 5-5"
if qq==69 then Goto "Pad 5-6"
if qq==70 then Goto "Pad 5-7"
if qq==71 then Goto "Pad 5-8"
if qq==80 then Goto "Pad 6-1"
if qq==81 then Goto "Pad 6-2"
if qq==82 then Goto "Pad 6-3"
if qq==83 then Goto "Pad 6-4"
if qq==84 then Goto "Pad 6-5"
if qq==85 then Goto "Pad 6-6"
if qq==86 then Goto "Pad 6-7"
if qq==87 then Goto "Pad 6-8"
if qq==96 then Goto "Pad 7-1"
if qq==97 then Goto "Pad 7-2"
if qq==98 then Goto "Pad 7-3"
if qq==99 then Goto "Pad 7-4"
if qq==100 then Goto "Pad 7-5"
if qq==101 then Goto "Pad 7-6"
if qq==102 then Goto "Pad 7-7"
if qq==103 then Goto "Pad 7-8"
if qq==112 then Goto "Pad 8-1"
if qq==113 then Goto "Pad 8-2"
if qq==114 then Goto "Pad 8-3"
if qq==115 then Goto "Pad 8-4"
if qq==116 then Goto "Pad 8-5"
if qq==117 then Goto "Pad 8-6"
if qq==118 then Goto "Pad 8-7"
if qq==119 then Goto "Pad 8-8"

Label "Pad 1-1"
if ia!=0 then exit rules, skip Outgoing Action
ia=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 1-2"
if ib!=0 then exit rules, skip Outgoing Action
ib=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 1-3"
if ic!=0 then exit rules, skip Outgoing Action
ic=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 1-4"
if id!=0 then exit rules, skip Outgoing Action
id=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 1-5"
if ie!=0 then exit rules, skip Outgoing Action
ie=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 1-6"
if if!=0 then exit rules, skip Outgoing Action
if=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 1-7"
if ig!=0 then exit rules, skip Outgoing Action
ig=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 1-8"
if ih!=0 then exit rules, skip Outgoing Action
ih=3
k2=k2-1
exit rules, execute Outgoing Action

Label "Pad 2-1"
if ij!=0 then exit rules, skip Outgoing Action
ij=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 2-2"
if ik!=0 then exit rules, skip Outgoing Action
ik=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 2-3"
if il!=0 then exit rules, skip Outgoing Action
il=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 2-4"
if im!=0 then exit rules, skip Outgoing Action
im=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 2-5"
if in!=0 then exit rules, skip Outgoing Action
in=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 2-6"
if io!=0 then exit rules, skip Outgoing Action
io=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 2-7"
if ip!=0 then exit rules, skip Outgoing Action
ip=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 2-8"
if iq!=0 then exit rules, skip Outgoing Action
iq=3
k2=k2-1
exit rules, execute Outgoing Action

Label "Pad 3-1"
if ir!=0 then exit rules, skip Outgoing Action
ir=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 3-2"
if is!=0 then exit rules, skip Outgoing Action
is=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 3-3"
if it!=0 then exit rules, skip Outgoing Action
it=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 3-4"
if iu!=0 then exit rules, skip Outgoing Action
iu=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 3-5"
if iv!=0 then exit rules, skip Outgoing Action
iv=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 3-6"
if iw!=0 then exit rules, skip Outgoing Action
iw=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 3-7"
if ix!=0 then exit rules, skip Outgoing Action
ix=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 3-8"
if iy!=0 then exit rules, skip Outgoing Action
iy=3
k2=k2-1
exit rules, execute Outgoing Action

Label "Pad 4-1"
if iz!=0 then exit rules, skip Outgoing Action
iz=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 4-2"
if i0!=0 then exit rules, skip Outgoing Action
i0=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 4-3"
if i1!=0 then exit rules, skip Outgoing Action
i1=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 4-4"
if i2!=0 then exit rules, skip Outgoing Action
i2=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 4-5"
if i3!=0 then exit rules, skip Outgoing Action
i3=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 4-6"
if i4!=0 then exit rules, skip Outgoing Action
i4=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 4-7"
if i5!=0 then exit rules, skip Outgoing Action
i5=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 4-8"
if i6!=0 then exit rules, skip Outgoing Action
i6=3
k2=k2-1
exit rules, execute Outgoing Action

Label "Pad 5-1"
if ja!=0 then exit rules, skip Outgoing Action
ja=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 5-2"
if jb!=0 then exit rules, skip Outgoing Action
jb=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 5-3"
if jc!=0 then exit rules, skip Outgoing Action
jc=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 5-4"
if jd!=0 then exit rules, skip Outgoing Action
jd=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 5-5"
if je!=0 then exit rules, skip Outgoing Action
je=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 5-6"
if jf!=0 then exit rules, skip Outgoing Action
jf=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 5-7"
if jg!=0 then exit rules, skip Outgoing Action
jg=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 5-8"
if jh!=0 then exit rules, skip Outgoing Action
jh=3
k2=k2-1
exit rules, execute Outgoing Action

Label "Pad 6-1"
if ji!=0 then exit rules, skip Outgoing Action
ji=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 6-2"
if jk!=0 then exit rules, skip Outgoing Action
jk=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 6-3"
if jl!=0 then exit rules, skip Outgoing Action
jl=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 6-4"
if jm!=0 then exit rules, skip Outgoing Action
jm=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 6-5"
if jn!=0 then exit rules, skip Outgoing Action
jn=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 6-6"
if jo!=0 then exit rules, skip Outgoing Action
jo=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 6-7"
if jp!=0 then exit rules, skip Outgoing Action
jp=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 6-8"
if jq!=0 then exit rules, skip Outgoing Action
jq=3
k2=k2-1
exit rules, execute Outgoing Action

Label "Pad 7-1"
if jr!=0 then exit rules, skip Outgoing Action
jr=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 7-2"
if js!=0 then exit rules, skip Outgoing Action
js=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 7-3"
if jt!=0 then exit rules, skip Outgoing Action
jt=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 7-4"
if ju!=0 then exit rules, skip Outgoing Action
ju=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 7-5"
if jv!=0 then exit rules, skip Outgoing Action
jv=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 7-6"
if jw!=0 then exit rules, skip Outgoing Action
jw=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 7-7"
if jx!=0 then exit rules, skip Outgoing Action
jx=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 7-8"
if jy!=0 then exit rules, skip Outgoing Action
jy=3
k2=k2-1
exit rules, execute Outgoing Action

Label "Pad 8-1"
if jz!=0 then exit rules, skip Outgoing Action
jz=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 8-2"
if j0!=0 then exit rules, skip Outgoing Action
j0=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 8-3"
if j1!=0 then exit rules, skip Outgoing Action
j1=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 8-4"
if j2!=0 then exit rules, skip Outgoing Action
j2=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 8-5"
if j3!=0 then exit rules, skip Outgoing Action
j3=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 8-6"
if j4!=0 then exit rules, skip Outgoing Action
j4=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 8-7"

if j5!=0 then exit rules, skip Outgoing Action
j5=3
k2=k2-1
exit rules, execute Outgoing Action
Label "Pad 8-8"
if j6!=0 then exit rules, skip Outgoing Action
j6=3
k2=k2-1
exit rules, execute Outgoing Action

DvlsAdvct

2015-12-01 15:41:04

Hi Mummis

By my math you should be utilizing 332 variables, where MT Pro has 360 global variables available (g0-g9, ga-gz for g, h, i, j, k, l, m, n, y, z)

But it's hard to help you optimize without really understanding what you're trying to do. Can you go into more depth on the layout of the launchpads and how the variables interact? There's just a LOT of code to parse through.

Thanks
Jared

florian

2015-12-09 01:29:05

Hi Mummis,

excellent project! Also I don't know some of the specifics, but here are a few ideas for reducing the number of variables:

1) ship positions
I would think that for the position of a single hidden ship, I'd use 1 variable for the position of the far left pad of the ship. If the shape is not pre-defined by ship number, use another variable per ship for the size.
It makes the hit test a bit more cumbersome, but you don't need to store all pads of the ships.

2) shot positions
For this kind of "boolean" storage, you can use bit wise arithmetic and store one or more rows in one single variable. If a bit is set, the corresponding position has already been shot. Example for using one variable "g0" for one row of 8 pads:
The bits go from 0...7 corresponding to pads 1...8.

Set bit 3:
g0=g0 | 8
where 8 is 2^3 (or 1<<3)
Set bit 0:
g0=g0 | 1

find out if g0 has bit 5 set:
pp=g0 & 32
if pp != 0 then "it's set"
where 32 is 2^5 (or 1<<5)

Reset all bits to 0:
g0=0

MT's variables are 32-bit signed, so you shouldn't use more than 31 bits. It's probably easiest to use one row per variable. This will cut your demand of variables by factor 8.

3) sink status
Just like shot positions, also the sink status can be stored in one variable, where bits 0...4 denote sink status of ships 1...5.

Please keep us posted, this seems like a fun application of MIDI Translator!
Thanks,
Florian

PS: have you seen our Pong implementation?

Mummis Modifier

2015-12-19 13:29:17

Hey Florian,

Thx, for your tip to use bitwise operators to simplifying the Rules.

i am really sure that this is the right way. i learned about the different operators and what they says,

but i don´t know how to use them practical.

i also understand the idea of your example but not the result of the rules you wrote.

why is: "where 8 is 2^3 (or 1<<3)" ?

how can be "where 32 is 2^5" ? (32 ist entweder 2 oder 5 ?)

is the result of bitwise operators ever "1" or "0" ???

i know that english is more useful for the forum, but maybe somebody could explain bitwise operating additionally in german ?

Mummis Modifier

2015-12-19 13:32:57

PS: no i don´t saw the pong implementation. what is it ? :D

florian

2015-12-19 15:35:55

sorry, I used the ^ sign as "power of" ("Potenz"), so 2^5 means 2 to the power of 5. I forgot that ^ is also the bitwise XOR operator. MT does not have a "power of" function, so you can use the left bit shift for that. 1 shifted left by 5 is the same as 2 to the power of 5, which is 32.

The bitwise operators work on the individual bits of a number. For each of the bits, the result is always either 1 or 0.
The simplest is with the lowest bit: if all other bits of the number are 0, it is just the number itself:
1&1=1
1&0=0
0&1=0
0&0=0

1|1=1
1|0=1
0|1=1
0|0=0

But it works with all other bits of a number, when displayed in binary form. For example, an 8-bit number has 8 bits (doh!). When using bitwise operators, the n-th bit of the first number is combined with the n-th bit of the second number:

Examples in binary form:
00000000 & 00000000=00000000
00001000 & 00001000=00001000
10000010 & 00010010=00000010
10000010 & 11111111=10000010
10000010 | 00010010=10010010

Now the same examples in decimal form:
0 & 0 = 0
8 & 8 = 8
130 & 18 = 2
130 & 255 = 130
130 | 18 = 146

There are calculator programs available with binary representation, e.g. the Windows built-in calculator.

But all this is not specific to MIDI Translator, I'm sure that other web pages on the web do a better job to explain binary arithmetic...

Thanks,
Florian

florian

2015-12-19 15:41:25

Pong: https://youtu.be/SUvZyb6zrB8
The project file is part of the example project files in Documents/Bome MIDI Translator/Presets.