This is the code:
The problem now is that I cant change nsim. If I for example change it to
nsim:=10: I get:
Error, invalid subscript selector
I must say maples debug tools suck. I dont even know from what line the error comes from :-(

restart; with(Statistics); randomize(); with(combinat); with(ListTools); X := proc (w) local p1has, z, p1, p11, p11N, p11NN, p11L, c1, c2, c3; p1 := w; unassign('p1has'); if verify(convert([CA, CK, CQ, CJ], set), convert(p1, set), `subset`) = true or verify(convert([DA, DK, DQ, DJ], set), convert(p1, set), `subset`) = true or verify(convert([HA, HK, HQ, HJ], set), convert(p1, set), `subset`) = true or verify(convert([SA, SK, SQ, SJ], set), convert(p1, set), `subset`) = true then p1has := 10 end if; unassign('c1'); unassign('c2'); unassign('c3'); z := {CA = C14, CJ = C11, CK = C13, CQ = C12, DA = D14, DJ = D11, DK = D13, DQ = D12, HA = H14, HJ = H11, HK = H13, HQ = H12, SA = S14, SJ = S11, SK = K13, SQ = S12}; p11 := subs(z, p1); p11N := [parse(convert(p11[1], string)[2 .. 3]), parse(convert(p11[2], string)[2 .. 3]), parse(convert(p11[3], string)[2 .. 3]), parse(convert(p11[4], string)[2 .. 3]), parse(convert(p11[5], string)[2 .. 3]), parse(convert(p11[6], string)[2 .. 3]), parse(convert(p11[7], string)[2 .. 3])]; p11NN := max(p11N); p11L := [parse(convert(p11[1], string)[1]), parse(convert(p11[3], string)[1]), parse(convert(p11[4], string)[1]), parse(convert(p11[5], string)[1]), parse(convert(p11[6], string)[1]), parse(convert(p11[7], string)[1])]; if 5 <= nops([SearchAll(C, p11L)]) then c1 := [SearchAll(C, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(D, p11L)]) then c1 := [SearchAll(D, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(H, p11L)]) then c1 := [SearchAll(H, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(S, p11L)]) then c1 := [SearchAll(S, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] end if; if assigned(c1) = true then c3 := Occurrences(1, [Occurrences(min(c2)+1, c2), Occurrences(min(c2)+2, c2), Occurrences(min(c2)+3, c2), Occurrences(min(c2)+4, c2)]) end if; if assigned(c1) = true and 4 <= c3 then p1has := 9 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 8 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 and Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 7 end if; if 5 <= max([nops([SearchAll(C, p11L)]), nops([SearchAll(D, p11L)]), nops([SearchAll(H, p11L)]), nops([SearchAll(S, p11L)])]) then p1has := 6 end if; c3 := Occurrences(1, [Occurrences(min(p11N)+1, p11N), Occurrences(min(p11N)+2, p11N), Occurrences(min(p11N)+3, p11N), Occurrences(min(p11N)+4, p11N)]); if 4 <= c3 then p1has := 5 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 then p1has := 4 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 3 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 2 end if; if assigned(p1has) = false then p1has := evalf((1/10)*max(p11N), 4) end if; return [p1has, p11NN] end proc; XX := proc () local rr; if X(p2)[1] < X(p1)[1] then rr := "Player 1 Win" elif X(p1)[1] < X(p2)[1] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p2)[2] < X(p1)[2] then rr := "Player 1 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] < X(p2)[2] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] = X(p2)[2] then rr := "Draw" end if; return rr end proc; nsim := 5; cpu := Array(1 .. nsim, 1 .. 1); for j from 2 to 10 do for i from 2 to 10 do cc[i, j] := 0; Clubs := [CA, CK, CQ, CJ, seq(cat(C, i), i = 2 .. 10)]; Diamonds := [DA, DK, DQ, DJ, seq(cat(D, i), i = 2 .. 10)]; Hearts := [HA, HK, HQ, HJ, seq(cat(H, i), i = 2 .. 10)]; Spades := [SA, SK, SQ, SJ, seq(cat(S, i), i = 2 .. 10)]; Cards := [op(Clubs), op(Diamonds), op(Hearts), op(Spades)]; M := Matrix(52, 52); M(1, () .. ()) := `<,>`(Cards[]); M(() .. (), 1) := `<,>`(Cards[]); Get := [M[i, 1], M[1, j]]; for sim to nsim do p1 := [Get[1]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); p1 := [Get[1], Get[2]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [op(p2), Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); flop := Shuffle(Cards)[1 .. 3]; Cards := subs([seq(t = NULL, `in`(t, flop))], Cards); turn := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, turn))], Cards); river := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, river))], Cards); p1 := [op(p1), op(flop), op(turn), op(river)]; p2 := [op(p2), op(flop), op(turn), op(river)]; cpu[sim, 1] := XX(); if cpu[sim, 1] = "Player 1 Win" then cc[i, j] := cc[i, j]+1 end if end do; A[i, j] := evalf(cc[i, j]/nsim, 2); if i = j then A[i, j] := 0 end if end do end do; AA := Matrix(52, 52, proc (i, j) options operator, arrow; A[i, j] end proc); Clubs := [CA, CK, CQ, CJ, seq(cat(C, i), i = 2 .. 10)]; Diamonds := [DA, DK, DQ, DJ, seq(cat(D, i), i = 2 .. 10)]; Hearts := [HA, HK, HQ, HJ, seq(cat(H, i), i = 2 .. 10)]; Spades := [SA, SK, SQ, SJ, seq(cat(S, i), i = 2 .. 10)]; Cards := [op(Clubs), op(Diamonds), op(Hearts), op(Spades)]; AA[() .. (), 1] := `<,>`(Cards[]); AA[1, () .. ()] := `<,>`(Cards[]); AA
Compare this to:

0.39600
Which is working beautifuly.
restart; with(Statistics); randomize(); with(combinat); with(ListTools); X := proc (w) local p1has, z, p1, p11, p11N, p11NN, p11L, c1, c2, c3; p1 := w; unassign('p1has'); if verify(convert([CA, CK, CQ, CJ], set), convert(p1, set), `subset`) = true or verify(convert([DA, DK, DQ, DJ], set), convert(p1, set), `subset`) = true or verify(convert([HA, HK, HQ, HJ], set), convert(p1, set), `subset`) = true or verify(convert([SA, SK, SQ, SJ], set), convert(p1, set), `subset`) = true then p1has := 10 end if; unassign('c1'); unassign('c2'); unassign('c3'); z := {CA = C14, CJ = C11, CK = C13, CQ = C12, DA = D14, DJ = D11, DK = D13, DQ = D12, HA = H14, HJ = H11, HK = H13, HQ = H12, SA = S14, SJ = S11, SK = K13, SQ = S12}; p11 := subs(z, p1); p11N := [parse(convert(p11[1], string)[2 .. 3]), parse(convert(p11[2], string)[2 .. 3]), parse(convert(p11[3], string)[2 .. 3]), parse(convert(p11[4], string)[2 .. 3]), parse(convert(p11[5], string)[2 .. 3]), parse(convert(p11[6], string)[2 .. 3]), parse(convert(p11[7], string)[2 .. 3])]; p11NN := max(p11N); p11L := [parse(convert(p11[1], string)[1]), parse(convert(p11[3], string)[1]), parse(convert(p11[4], string)[1]), parse(convert(p11[5], string)[1]), parse(convert(p11[6], string)[1]), parse(convert(p11[7], string)[1])]; if 5 <= nops([SearchAll(C, p11L)]) then c1 := [SearchAll(C, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(D, p11L)]) then c1 := [SearchAll(D, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(H, p11L)]) then c1 := [SearchAll(H, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(S, p11L)]) then c1 := [SearchAll(S, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] end if; if assigned(c1) = true then c3 := Occurrences(1, [Occurrences(min(c2)+1, c2), Occurrences(min(c2)+2, c2), Occurrences(min(c2)+3, c2), Occurrences(min(c2)+4, c2)]) end if; if assigned(c1) = true and 4 <= c3 then p1has := 9 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 8 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 and Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 7 end if; if 5 <= max([nops([SearchAll(C, p11L)]), nops([SearchAll(D, p11L)]), nops([SearchAll(H, p11L)]), nops([SearchAll(S, p11L)])]) then p1has := 6 end if; c3 := Occurrences(1, [Occurrences(min(p11N)+1, p11N), Occurrences(min(p11N)+2, p11N), Occurrences(min(p11N)+3, p11N), Occurrences(min(p11N)+4, p11N)]); if 4 <= c3 then p1has := 5 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 then p1has := 4 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 3 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 2 end if; if assigned(p1has) = false then p1has := evalf((1/10)*max(p11N), 4) end if; return [p1has, p11NN] end proc; XX := proc () local rr; if X(p2)[1] < X(p1)[1] then rr := "Player 1 Win" elif X(p1)[1] < X(p2)[1] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p2)[2] < X(p1)[2] then rr := "Player 1 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] < X(p2)[2] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] = X(p2)[2] then rr := "Draw" end if; return rr end proc; nsim := 500; cc := 0; cpu := Array(1 .. nsim, 1 .. 1); for sim to nsim do Clubs := [CA, CK, CQ, CJ, seq(cat(C, i), i = 2 .. 10)]; Diamonds := [DA, DK, DQ, DJ, seq(cat(D, i), i = 2 .. 10)]; Hearts := [HA, HK, HQ, HJ, seq(cat(H, i), i = 2 .. 10)]; Spades := [SA, SK, SQ, SJ, seq(cat(S, i), i = 2 .. 10)]; Cards := [op(Clubs), op(Diamonds), op(Hearts), op(Spades)]; Get := [CJ, CK]; p1 := [Get[1]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); p1 := [Get[1], Get[2]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [op(p2), Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); flop := Shuffle(Cards)[1 .. 3]; Cards := subs([seq(t = NULL, `in`(t, flop))], Cards); turn := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, turn))], Cards); river := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, river))], Cards); p1 := [op(p1), op(flop), op(turn), op(river)]; p2 := [op(p2), op(flop), op(turn), op(river)]; cpu[sim, 1] := XX(); if cpu[sim, 1] = "Player 1 Win" then cc := cc+1 end if end do; evalf(cc/nsim, 5)
LL_61)_Poker.mw