31

**TI Z80 / Re: The best Mastermind Deluxe ever !**

« **on:**May 17, 2013, 06:03:58 am »

UP

The program is now 100% bug-free !

Thanks to Bisam for some great optimisations ! :thumbup:

A TI-82 Stats/TI-83 version is now included !

New code: (version 83+/84+):

Version 82 stats/83:

The program is now 100% bug-free !

Thanks to Bisam for some great optimisations ! :thumbup:

A TI-82 Stats/TI-83 version is now included !

New code: (version 83+/84+):

**Spoiler**For

*Spoiler*:

Code: [Select]

`:G-T:Full`

:FnOff :AxesOff

:0→Xmin:0→Ymin

:1→ΔX:1→ΔY

:DelVar L9→dim(∟MS

:If not(∟MS(4:{4,0,0,1,99,99,99,99,0→∟MS

:Lbl M

:ClrDraw

:1→C

:RecallPic 9

:{0,36,39,44,39,50,57→L1

:Repeat max(K={45,105

:getKey→K

:Text(L1(2C),L1(2C+1),"[

:If K:Text(L1(2C),L1(2C+1),"

:C-(K=25)+(K=34→C

:If not(C:3→C

:If C=4:1→C

:End

:If C=3 or K=45:Goto Q

:If C=2:Then

:∟MS→L1

:Horizontal 0

:For(A,1,39

:Line(0,A,94,A,0

:Pt-On(0,A

:Pt-On(94,A

:End

:Horizontal 40

:Text(26,6,"-Answers :

:Text(33,6,"-Difficulty :

:Text(40,6,"-Nbr players:

:Text(47,6,"-Several same

:Text(54,10,"colors :

:1→C

:{26,33,40,54→L2

:Repeat K=45 or K=105

:L2(C→A

:getKey→K

:Text(26,56,sub("PlacedDigits",6L1(9)+1,6

:Text(33,56,sub(" Easy Normal Medium Hardcore",8L1(1)-16,8

:Text(40,56,1+L1(2

:Text(54,56,sub("DisabledEnabled ",8L1(3)+1,8

:Text(A,51,"<

:Text(A,90,">

:If K:Then

:Text(A,51,"

:Text(A,90,"

:C+(K=34)-(K=25→C

:If not(C:4→C

:If C=5:1→C

:If C=2:Then

:L1(1)+(K=26)-(K=24→L1(1

:If 3>L1(1:6→L1(1

:If 6<L1(1:3→L1(1

:End

:If max(K={24,26:Then

:If C=1:not(L1(9→L1(9

:If C=3:not(L1(2→L1(2

:If C=4:not(L1(3→L1(3

:If max(C={2,1,4

:Text(26+7(C=2)+28(C=4),56,"

:End

:End

:End

:2→C

:L1→∟MS

:End

:If C=2:Goto M

:∟MS(1→N

:N+3→P

:If ∟MS(2

:Then

:Split

:RecallPic 9

:Line(10,7,84,6

:For(A,8,55

:Line(11,A,83,A,0

:Pt-On(10,A

:Pt-On(84,A

:End

:Line(10,56,84,56

:Text(6,18,"ENTER ",N," DIGITS

:Text(14,18,"BETWEEN 1 AND ",P

:Lbl A

:DelVar BDelVar L2

:Input ">",Str1

:If N≠length(Str1:1→B

:N→dim(L2

:If not(B:Then

:For(A,1,N

:expr(sub(Str1,A,1→L2(A

:If Ans>P:1→B

:If 3=sum(seq(L2(A)=L2(K),K,1,N))+not(∟MS(3:2→B

:End

:End

:If B:Disp "ERROR

:If B=2:Disp "Same digits.

:If B:Goto A

:Full

:Else

:If ∟MS(3:Then

:randInt(1,P,N→L2

:Else

:Repeat min(DeltaList(L2

:randInt(1,P,N→L1

:L1→L2

:SortA L2

:End

:L1→L2

:End:End

:1+12N→N

:{N-1,61,1,61,0,60,0,1,1,0,N,0,N,1,N,60,N+1,1,N+1,59,77,53,94,53,76,46,94,46,76,60,76,0,76,0,94,0,94,0,94,60,94,60,76,60

:ClrDraw

:For(A,1,44,4

:Line(Ans(A),Ans(A+1),Ans(A+2),Ans(A+3

:End

:{59,54,52,47

:For(A,1,4

:Pt-On(77,Ans(A

:Pt-On(93,Ans(A

:End

:{1,1,1,60,N-1,1,N-1,60

:For(A,1,8,2

:Pt-On(Ans(A),Ans(A+1

:End

:Line(3,16,N-3,16

:Line(3,59,N-3,59

:(N-1)/12→N

:For(A,7,7N,7

:{A-5,4,A,4,A,11,A-5,11,A-5,4

:For(B,1,7,2

:Line(Ans(B),Ans(B+1),Ans(B+2),Ans(B+3

:End

:End

:Text(47,78,"BEST

:Text(54,78,"= ",∟MS(2+∟MS(1

:{1,N→dim([J]

:[J]→[H]

:Fill(1,L1

:DelVar VDelVar C1→B

:{0→L4

:Lbl I

:L1(V+1→R:C+1→C

:2+dim(L4→dim(L4

:For(A,0,N-1

:Text(52,7A+3,L1(A+1

:End

:Repeat max(K={105,45

:Text(52,7V+3,R

:getKey→K

:R+(K=25)-(K=34→R

:If max(K={92,93,94,82,83,84,72,73,74:Then

:2-(K=92)+(K=94)+2(K=82)+3(K=83)+4(K=84)+5(K=72)+6(K=73)+7(K=74

:If Ans≤P:Ans→R

:End

:If not(R:P→R

:If R>P:1→R

:If B xor max(K={24,26

:Then

:7V

:Pt-Change(Ans+4,2

:Pt-Change(Ans+5,1

:Pt-Change(Ans+6,2

:Pt-Change(Ans+4,13

:Pt-Change(Ans+5,14

:Pt-Change(Ans+6,13

:End

:DelVar BDelVar YIf max(K={24,26,105:Then

:R→L1(V+1

:V+(K=26)-(K=24→V

:If V=N:0→V

:If V<0:N-1→V

:L1(V+1→R

:1-(K=105→B

:End

:If 6<Cmax(K={21,31:Then

:L-(K=21 and L)+(K=31 and L<C-7→L

:Lbl B

:For(A,1,6

:For(K,1,N

:Text(7A-3,7K-4,[J](A+L,K

:End

:If ∟MS(9:Then

:Y=9

:dim(L4)-1-2(A+L)+3Ans+not(Ans

:Text(7A-3,7N+5(N>3),"□",L4(Ans-1),"┼",L4(Ans

:Else

:7N+4

:For(K,1,N

:Ans+3

:Pt-Off(Ans,63-7A,2

:Pt-Off(Ans,63-7A

:Pt-On(Ans,63-7A,[H](A+L,K

:End

:End

:End

:If Y=9:Goto C

:End

:End

:If K=45:Goto M

:DelVar LN→dim(L1

:List►matr(L1,[I]

:augment([I],[J]T)T→[J]

:Text(3,82,C

:Text(10,82,15-C,"

:N→dim(L3

:For(A,1,N

:1→K

:If L1(A)=L2(A

:Then

:2→K

:Else

:If max(seq(L2(B)=L1(A),B,1,N

:3→K

:End

:K→L3(A

:End

:List►matr(L3,[G]

:augment([G],[H]T)T→[H]

:For(A,1,N

:If 2=L3(A:1+L4(2C→L4(2C

:If 3=L3(A:1+L4(2C+1→L4(2C+1

:End

:If C<7:Then

:For(A,0,N-1

:Text(46-7C,7A+3,L1(A+1

:End

:If ∟MS(9

:Then

:Text(46-7C,7N+5(N>3),"□",L4(2C),"┼",L4(2C+1

:Else

:For(A,1,N

:Pt-On(7N+3A+4,14+7C,L3(A

:End

:End

:Else

:9→Y

:Goto B

:Lbl C

:End

:DelVar BIf N=sum(L2=L1 or C=15:Then

:Horizontal 10

:For(A,11,51

:Line(0,A,94,A,0

:End

:Horizontal 52

:If C=15:Then

:Text(12,10,"THE CODE WAS :

:Text(37,30,"YOU LOSE !

:Else

:Text(12,10,"CODE BROKEN ! :

:If C<∟MS(2+∟MS(1

:C→∟MS(2+∟MS(1

:End

:For(A,1,N

:Text(12,60+5A,L2(A

:End

:Text(21,25,"- Tries : ",C

:Text(28,25,"- Best : ",∟MS(2+∟MS(1

:Text(45,10,"1: Replay

:Text(45,60,"2: Quit

:Repeat max(B={92,93,45

:getKey→B

:End

:End

:If not(B:Goto I

:If B=92:Goto M

:Lbl Q

:ZStandard:AxesOn

:DelVar [J]DelVar [I]DelVar [H]DelVar [G]DelVar L1DelVar L2DelVar L4DelVar L3DelVar Str1DelVar ADelVar BDelVar CDelVar KDelVar NDelVar PDelVar RDelVar LDelVar YDelVar VOutput(1,1,"

Version 82 stats/83:

**Spoiler**For

*Spoiler*:

Code: [Select]

`:FnOff :AxesOff`

:0→Xmin:0→Ymin

:1→ΔX:1→ΔY

:DelVar L9→dim(∟MS

:If not(∟MS(4:{4,0,0,1,99,99,99,99,0→∟MS

:Lbl M

:ClrDraw

:1→C

:RecallPic 9

:{0,36,39,44,39,50,57→L1

:Repeat max(K={45,105

:getKey→K

:Text(L1(2C),L1(2C+1),"[

:If K:Text(L1(2C),L1(2C+1),"

:C-(K=25)+(K=34→C

:If not(C:3→C

:If C=4:1→C

:End

:If C=3 or K=45:Goto Q

:If C=2:Then

:∟MS→L1

:Horizontal 0

:For(A,1,39

:Line(0,A,94,A,0

:Pt-On(0,A

:Pt-On(94,A

:End

:Horizontal 40

:Text(26,6,"-A[n][s]|w[e][r][s] :

:Text(33,6,"-Di|F|Fi[|c]|u1[t][yhat] :

:Text(40,6,"-N[|b][r] [p]1[|a][yhat][e][r][s]:

:Text(47,6,"-S[e]|v[e][r][|a]1 [s][|a]M[e]

:Text(54,10,"[c]O1O[r][s] :

:1→C

:{26,33,40,54→L2

:Repeat K=45 or K=105

:L2(C→A

:getKey→K

:Text(26,56,sub("P1[|a][|c][e][|d]DiGi[t][s]",6L1(9)+1,6

:Text(33,56,sub(" E[|a][s][yhat] NO[r]M[|a]1 M[e][|d]i|uM H[|a][r][|d][|c]O[|r][e]",8L1(1)-16,8

:Text(40,56,1+L1(2

:Text(54,56,sub("Di[s][|a][|b]1[e][|d]E[n][|a][|b]1[e][|d] ",8L1(3)+1,8

:Text(A,51,"<

:Text(A,90,">

:If K:Then

:Text(A,51,"

:Text(A,90,"

:C+(K=34)-(K=25→C

:If not(C:4→C

:If C=5:1→C

:If C=2:Then

:L1(1)+(K=26)-(K=24→L1(1

:If 3>L1(1:6→L1(1

:If 6<L1(1:3→L1(1

:End

:If max(K={24,26:Then

:If C=1:not(L1(9→L1(9

:If C=3:not(L1(2→L1(2

:If C=4:not(L1(3→L1(3

:If max(C={2,1,4

:Text(26+7(C=2)+28(C=4),56,"

:End

:End

:End

:2→C

:L1→∟MS

:End

:If C=2:Goto M

:∟MS(1→N

:N+3→P

:If ∟MS(2

:Then

:Split

:RecallPic 9

:Line(10,7,84,6

:For(A,8,55

:Line(11,A,83,A,0

:Pt-On(10,A

:Pt-On(84,A

:End

:Line(10,56,84,56

:Text(6,18,"ENTER ",N," DIGITS

:Text(14,18,"BETWEEN 1 AND ",P

:Lbl A

:DelVar BDelVar L2

:Input ">",Str1

:If N≠length(Str1:1→B

:N→dim(L2

:If not(B:Then

:For(A,1,N

:expr(sub(Str1,A,1→L2(A

:If Ans>P:1→B

:If 3=sum(seq(L2(A)=L2(K),K,1,N))+not(∟MS(3:2→B

:End

:End

:If B:Disp "ERROR

:If B=2:Disp "SAME [|d]iGi[t][s]!

:If B:Goto A

:Full

:Else

:If ∟MS(3:Then

:randInt(1,P,N→L2

:Else

:Repeat min(DeltaList(L2

:randInt(1,P,N→L1

:L1→L2

:SortA L2

:End

:L1→L2

:End:End

:1+12N→N

:{N-1,61,1,61,0,60,0,1,1,0,N,0,N,1,N,60,N+1,1,N+1,59,77,53,94,53,76,46,94,46,76,60,76,0,76,0,94,0,94,0,94,60,94,60,76,60

:ClrDraw

:For(A,1,44,4

:Line(Ans(A),Ans(A+1),Ans(A+2),Ans(A+3

:End

:{59,54,52,47

:For(A,1,4

:Pt-On(77,Ans(A

:Pt-On(93,Ans(A

:End

:{1,1,1,60,N-1,1,N-1,60

:For(A,1,8,2

:Pt-On(Ans(A),Ans(A+1

:End

:Line(3,16,N-3,16

:Line(3,59,N-3,59

:(N-1)/12→N

:For(A,7,7N,7

:{A-5,4,A,4,A,11,A-5,11,A-5,4

:For(B,1,7,2

:Line(Ans(B),Ans(B+1),Ans(B+2),Ans(B+3

:End

:End

:Text(47,78,"BEST

:Text(54,78,"= ",∟MS(2+∟MS(1

:{1,N→dim([J]

:[J]→[H]

:Fill(1,L1

:DelVar VDelVar C1→B

:{0→L4

:Lbl I

:L1(V+1→R:C+1→C

:2+dim(L4→dim(L4

:For(A,0,N-1

:Text(52,7A+3,L1(A+1

:End

:Repeat max(K={105,45

:Text(52,7V+3,R

:getKey→K

:R+(K=25)-(K=34→R

:If max(K={92,93,94,82,83,84,72,73,74:Then

:2-(K=92)+(K=94)+2(K=82)+3(K=83)+4(K=84)+5(K=72)+6(K=73)+7(K=74

:If Ans≤P:Ans→R

:End

:If not(R:P→R

:If R>P:1→R

:If B xor max(K={24,26

:Then

:7V

:Pt-Change(Ans+4,2

:Pt-Change(Ans+5,1

:Pt-Change(Ans+6,2

:Pt-Change(Ans+4,13

:Pt-Change(Ans+5,14

:Pt-Change(Ans+6,13

:End

:DelVar BDelVar YIf max(K={24,26,105:Then

:R→L1(V+1

:V+(K=26)-(K=24→V

:If V=N:0→V

:If V<0:N-1→V

:L1(V+1→R

:1-(K=105→B

:End

:If 6<Cmax(K={21,31:Then

:L-(K=21 and L)+(K=31 and L<C-7→L

:Lbl B

:For(A,1,6

:For(K,1,N

:Text(7A-3,7K-4,[J](A+L,K

:End

:If ∟MS(9:Then

:Y=9

:dim(L4)-1-2(A+L)+3Ans+not(Ans

:Text(7A-3,7N+5(N>3),"□",L4(Ans-1),"┼",L4(Ans

:Else

:7N+4

:For(K,1,N

:Ans+3

:Pt-Off(Ans,63-7A,2

:Pt-Off(Ans,63-7A

:Pt-On(Ans,63-7A,[H](A+L,K

:End

:End

:End

:If Y=9:Goto C

:End

:End

:If K=45:Goto M

:DelVar LN→dim(L1

:List►matr(L1,[I]

:augment([I],[J]T)T→[J]

:Text(3,82,C

:Text(10,82,15-C,"

:N→dim(L3

:For(A,1,N

:1→K

:If L1(A)=L2(A

:Then

:2→K

:Else

:If max(seq(L2(B)=L1(A),B,1,N

:3→K

:End

:K→L3(A

:End

:List►matr(L3,[G]

:augment([G],[H]T)T→[H]

:For(A,1,N

:If 2=L3(A:1+L4(2C→L4(2C

:If 3=L3(A:1+L4(2C+1→L4(2C+1

:End

:If C<7:Then

:For(A,0,N-1

:Text(46-7C,7A+3,L1(A+1

:End

:If ∟MS(9

:Then

:Text(46-7C,7N+5(N>3),"□",L4(2C),"┼",L4(2C+1

:Else

:For(A,1,N

:Pt-On(7N+3A+4,14+7C,L3(A

:End

:End

:Else

:9→Y

:Goto B

:Lbl C

:End

:DelVar BIf N=sum(L2=L1 or C=15:Then

:Horizontal 10

:For(A,11,51

:Line(0,A,94,A,0

:End

:Horizontal 52

:If C=15:Then

:Text(12,10,"THE CODE WAS :

:Text(37,30,"YOU LOSE !

:Else

:Text(12,10,"CODE BROKEN ! :

:If C<∟MS(2+∟MS(1

:C→∟MS(2+∟MS(1

:End

:For(A,1,N

:Text(12,60+5A,L2(A

:End

:Text(21,25,"- T[r]i[e][s] : ",C

:Text(28,25,"- B[e][s][t] : ",∟MS(2+∟MS(1

:Text(45,10,"1: R[e][p]1[|a][yhat]

:Text(45,60,"2: Q|ui[t]

:Repeat max(B={92,93,45

:getKey→B

:End

:End

:If not(B:Goto I

:If B=92:Goto M

:Lbl Q

:ZStandard:AxesOn

:DelVar [J]DelVar [I]DelVar [H]DelVar [G]DelVar L1DelVar L2DelVar L4DelVar L3DelVar Str1DelVar ADelVar BDelVar CDelVar KDelVar NDelVar PDelVar RDelVar LDelVar YDelVar VOutput(1,1,"

- Download Mastermind Deluxe : http://ti-pla.net/a12483