|
发表于 2011-9-24 23:05:00
|
显示全部楼层
试了试。出现以下提示:
#OK: 2 ACTIONS LOADED.
function sendcmd (ses, command)
#ERROR: #UNKNOWN TINTIN-COMMAND '%s'.
print(string.format("sendcmd (%s) %s", ses, command))
end
function show (ses, command)
#ERROR: #UNKNOWN TINTIN-COMMAND '%s'.
print(string.format("show (%s) %s", ses, command))
end
function BianLi()
A,B,C,D=0,0,0,0
I=1
Result={}
for A=1,8 do
for B=1,8 do
for C=1,8 do
for D=1,8 do
if not (A==B or A==C or A==D or B==C or B==D or C==D) then
Result[I]=A..B..C..D
I=I+1
end
end
end
end
end
end
function PanDuan(Guess,TQ,TJ)
Temp={} J=1
a=string.sub(Guess,1,1)
b=string.sub(Guess,2,2)
c=string.sub(Guess,3,3)
d=string.sub(Guess,4,4)
for I=1,table.getn(Result) do
q,j=0,0
A=string.sub(Result[I],1,1)
B=string.sub(Result[I],2,2)
C=string.sub(Result[I],3,3)
D=string.sub(Result[I],4,4)
if a==A then q=q+1 end
if b==B then q=q+1 end
if c==C then q=q+1 end
if d==D then q=q+1 end
if a==B or a==C or a==D then j=j+1 end
if b==A or b==C or b==D then j=j+1 end
if c==A or c==B or c==D then j=j+1 end
if d==A or d==B or d==C then j=j+1 end
if q==tonumber(TQ) and j==tonumber(TJ) then
Temp[J]=Result[I]
J=J+1
end
end
Result={}
for I=1,table.getn(Temp) do
Result[I]=Temp[I]
end
Guess=Result[1]
sendcmd("pku","guess "..Guess)
sendcmd("pku","#var gnum "..Guess)
end
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> function sendcmd (ses, command)
#ERROR: #UNKNOWN TINTIN-COMMAND '%s'.
>> print(string.format("sendcmd (%s) %s", ses, command))
>> end
> function show (ses, command)
#ERROR: #UNKNOWN TINTIN-COMMAND '%s'.
>> print(string.format("show (%s) %s", ses, command))
>> end
> function BianLi()
>> A,B,C,D=0,0,0,0
>> I=1
>> Result={}
>> for A=1,8 do
>> for B=1,8 do
>> for C=1,8 do
>> for D=1,8 do
>> if not (A==B or A==C or A==D or B==C or B==D or C==D) then
>> Result[I]=A..B..C..D
>> I=I+1
>> end
>> end
>> end
>> end
>> end
>> end
> function PanDuan(Guess,TQ,TJ)
>> Temp={} J=1
>> a=string.sub(Guess,1,1)
>> b=string.sub(Guess,2,2)
>> c=string.sub(Guess,3,3)
>> d=string.sub(Guess,4,4)
>> for I=1,table.getn(Result) do
>> q,j=0,0
>> A=string.sub(Result[I],1,1)
>> B=string.sub(Result[I],2,2)
>> C=string.sub(Result[I],3,3)
>> D=string.sub(Result[I],4,4)
>> if a==A then q=q+1 end
>> if b==B then q=q+1 end
>> if c==C then q=q+1 end
>> if d==D then q=q+1 end
>> if a==B or a==C or a==D then j=j+1 end
>> if b==A or b==C or b==D then j=j+1 end
>> if c==A or c==B or c==D then j=j+1 end
>> if d==A or d==B or d==C then j=j+1 end
>> if q==tonumber(TQ) and j==tonumber(TJ) then
>> Temp[J]=Result[I]
>> J=J+1
>> end
>> end
>> Result={}
>> for I=1,table.getn(Temp) do
>> Result[I]=Temp[I]
>> end
>> Guess=Result[1]
>> sendcmd("pku","guess "..Guess)
ess)endcmd("pku","#var gnum "..Gu
>> end
这是怎么一回事呢? |
|