Rev 7691 | Rev 11697 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
:option:color=" " noanswer
!!option=noorder (plusieurs réponses dans n'importe quel ordre) non documenté car n'est peut-être
!! pas très utile : ne peut pas servir pour énumérer les déplacements possibles d'une seule pièce.
!!option=noanswer : does not give the good answer in the answer
ans_lettre=a,b,c,d,e,f,g,h
!set ans_color=!getopt color in $(replyoption$i)
ans_rep=!rows2lines $(reply$i)
ans_rep_cnt=!linecnt $ans_rep
ans_Rep$i=
ans_rep$i=
Feed_r=
!for j=1 to $ans_rep_cnt
z=!line $j of $ans_rep
d_y=$[($(z[1])-1)%8 +1]
d_xx=$[($(z[1]) - $d_y)/8+1]
d_x=!item $d_xx of $ans_lettre
a_y=$[($(z[3])-1)%8 +1]
a_xx=$[($(z[3]) - $a_y)/8 +1]
a_x=!item $a_xx of $ans_lettre
ans_rep$i=!append line $d_x$d_y $(z[2]) $a_x$a_y to $(ans_rep$i)
ans_Rep$i=!append line $d_x$d_y,$a_x$a_y to $(ans_Rep$i)
Feed_r=!append item $(d_xx)_$d_y,$(a_xx)_$a_y to $(Feed_r)
!next
!set ans_rep$i=!lines2rows $(ans_rep$i)
!set ans_Rep$i=!lines2rows $(ans_Rep$i)
!set g_answer=!lines2rows $(replygood$i)
!set g_answer=!rows2lines $g_answer
!set ans_initial=!line 1 of $g_answer
!set ans_initial=!declosing $ans_initial
!set g_answer=!line 2 of $g_answer
!set g_answer=!declosing $g_answer
!!pas d'analyse de la réponse
!if $g_answer=$empty
replygood$i=?analyze
!endif
score=0
tmp=!lines2rows $(ans_Rep$i)
tmp_order=!rows2lines $(ans_Rep$i)
tmp_order=!replace internal , by | in $tmp_order
tmp_order=!lines2items $tmp_order
tmp_order=!nospace $tmp_order
g_ans=!replace internal | by $\
$ in $g_answer
g_ans=!translate internal -+x# to ,,,, in $g_ans
g_prom=!replace internal = by XX in $g_mv
!if XX isin $g_prom
g_ans=!translate =[A-Z] to $ $ in $g_ans
!else
!reset slib_prom
!endif
g_ans=!translate [A-Z] to $ $ in $g_ans
g_ans_cnt=!linecnt $g_ans
!reset G_answer
on cherche la meilleure réponse
test=0
sol=1
!for l_ = 1 to $g_ans_cnt
u=!line $l_ of $g_ans
test$l_=0
ans_cnt$l_=!itemcnt $(u[;1])
!if noorder notwordof $(replyoption$i)
!for p=1 to $(ans_cnt$l_)
u_= $(u[$p;])
!for s = 1 to 2
v_ = $(u_[$s])
!if $v_ issametext $(tmp[$p;$s])
!advance test$l_
!endif
!next s
!next p
!else noorder
uorder=!rows2lines $u
uorder=!replace internal , by | in $uorder
uorder=!lines2items $uorder
uorder=!nospace $uorder
inter=!listintersect $uorder and $tmp_order
diff1=!listcomplement $uorder in $tmp_order
diff2=!listcomplement $tmp_order in $uorder
diff1_cnt=!itemcnt $diff1
diff2_cnt=!itemcnt $diff2
test$l_=!itemcnt $inter_cnt
test$l_=$[2*$(test$l_)]
!endif
!if $(test$l_) > $test
test=$(test$l_)
sol=$l_
!endif
!next l_
!!sol est la solution la plus proche d'une bonne solution
G_answer=!line $sol of $g_answer
!for p=1 to $(ans_cnt$sol)
!for s=1 to 2
uu=!text expand $(G_answer[$p;$s]) using 01
uu=!words2items $uu
u1=!positionof item $(uu[1]) in $ans_lettre
Feed_g=!append item $(u1)_$(uu[2]) to $Feed_g
!next
!next
!if noorder notwordof $(replyoption$i)
score=$[$(test$sol)/(2*$(ans_cnt$sol))]
!else
score=$[1-$test/$(ans_cnt$sol)]
!endif
G_answer=!lines2rows $G_answer
!readproc slib/games/chessboard [$ans_initial],$ans_color
ans_init=$slib_out
!readproc slib/games/chessmv [$ans_initial],[$(ans_Rep$i)]
!set r_final=$slib_out
!readproc slib/games/chessboard $(r_final[-1;1]),$ans_color
reply_$i=$slib_out
!if $g_answer !=$empty
!readproc slib/games/chessmv [$ans_initial],[$G_answer]
!set g_final=$slib_out
!if noanswer notwordof $(replyoption$i)
!readproc slib/games/chessboard $(g_final[-1;1]),$ans_color
replyGood$i=$slib_out
!endif
!endif
m_r=$(ans_rep$i)
reply__$i=$m_r
!reset m_reply$i
r_final_=$(r_final)
!for j = 1 to $ans_rep_cnt
m_reply$i=!append line $(m_r[$j;]),$(r_final_[$j;2]),$(r_final_[$j;1]) to $(m_reply$i)
!next
m_reply$i=!lines2rows $(m_reply$i)
m_reply$i=!singlespace $(m_reply$i)
m_reply$i=!words2items $(m_reply$i)
ans_init=!replace internal <table> by <table style="color:black;"> in $(ans_init)
reply_$i=!replace internal td_ by r_ in $(reply_$i)
!if $g_answer=$empty
reply_$i=!replace internal <table> by <table style="color:black;"> in $(reply_$i)
!for j=1 to 2*$ans_rep_cnt
reply_$i=!replace internal <td id="r_$(Feed_r[$j])" style=" by <td id="r_$(Feed_r[$j])" style="border:2px solid blue; in $(reply_$i)
!next
reply_$i=<table style="color:black"><tr><td>$ans_init</td><td>\
$(reply_$i)\
</td></tr></table>
!exit
!endif
!if $score=1
diareply$i=good
!advance freegot
!else
diareply$i=bad
!endif
!if $score=1
reply_$i=!replace internal <table> by <table style="border:4px solid green;color:black;"> in $(reply_$i)
reply_$i=<table style="color:black"><tr><td>$ans_init</td><td>\
$(reply_$i)\
</td></tr></table>
!else
!if noanswer notwordof $(replyoption$i)
replyGood$i=!replace internal <table> by <table style="border:4px solid green;color:black;"> in $(replyGood$i)
replyGood$i=!replace internal td_ by g_ in $(replyGood$i)
reply_$i=!replace internal <table> by <table style="border:4px solid red;color:black;"> in $(reply_$i)
reply_$i=<table style="color:black"><tr><td>$ans_init</td><td>\
$(reply_$i) \
</td><td>\
$(replyGood$i)\
</td></tr></table>
!else
reply_$i=<table style="color:black"><tr><td>$ans_init</td><td>\
$(reply_$i) \
</td></tr></table>
!endif
!endif
!for j=1 to 2*$ans_rep_cnt
reply_$i=!replace internal <td id="r_$(Feed_r[$j])" style=" by <td id="r_$(Feed_r[$j])" style="border:2px solid blue; in $(reply_$i)
!next
!for j=1 to 2*$(ans_cnt$sol)
reply_$i=!replace internal <td id="g_$(Feed_g[$j])" style=" by <td id="g_$(Feed_g[$j])" style="border:2px solid blue; in $(reply_$i)
!next
g_reply_=$(g_final[;2])
g_reply__=
!for u =1 to $(ans_cnt$sol)
c=!declosing $(g_reply_[$u])
c_nt=!itemcnt $c
!if $c_nt=2
g_reply__=!append line $(G_answer[$u;1]) x $(G_answer[$u;2]) to $g_reply__
!else
g_reply__=!append line $(G_answer[$u;1])$ $(G_answer[$u;2]) to $g_reply__
!endif
!next
g_reply__=!lines2rows $(g_reply__)
!if $score<1
reply__$i=$(reply__$i) ; $ch_good1 : <span class="tt">$g_reply__</span>.
!endif