Rev 535 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
535 | bpr | 1 | # Variable calculations should be done in this file. |
2 | # It is read and interpreted by wims for all valid calls to the module. |
||
3 | |||
4 | F=F |
||
5 | Z=Z |
||
6 | r=<i>r</i> |
||
7 | |||
8 | !if $cmd=reply and $status=waiting |
||
9 | reply_cnt=$[$reply_cnt+1] |
||
10 | !endif |
||
11 | try_cnt=$[$reply_cnt+1] |
||
12 | |||
13 | # Computation of the locations of pieces |
||
14 | |||
15 | !if $q=4 or $q=8 or $q=9 |
||
16 | |||
17 | field=notprime |
||
18 | !read data/qpuzzle/table.F$q |
||
19 | !for x = 0 to $q-1 |
||
20 | !if $x<=1 |
||
21 | el$x=$x |
||
22 | !else |
||
23 | el$x=$r<sup>$[$x-1]</sup> |
||
24 | !endif |
||
25 | !for y = 0 to $q-1 |
||
26 | s=!item $a11+1 of $(mul$x) |
||
27 | t=!item $a12+1 of $(mul$y) |
||
28 | x1=!item $s+1 of $(add$t) |
||
29 | x1=!item $x1+1 of $(add$xt) |
||
30 | |||
31 | s=!item $a21+1 of $(mul$x) |
||
32 | t=!item $a22+1 of $(mul$y) |
||
33 | y1=!item $s+1 of $(add$t) |
||
34 | y1=!item $y1+1 of $(add$yt) |
||
35 | |||
36 | s=!item $r11+1 of $(mul$x1) |
||
37 | t=!item $r12+1 of $(mul$y1) |
||
38 | xx=!item $s+1 of $(add$t) |
||
39 | xx=!item $xx+1 of $(add$xr) |
||
40 | |||
41 | s=!item $r21+1 of $(mul$x1) |
||
42 | t=!item $r22+1 of $(mul$y1) |
||
43 | yy=!item $s+1 of $(add$t) |
||
44 | yy=!item $yy+1 of $(add$yr) |
||
45 | |||
46 | n$(xx)_$yy=$x.$y |
||
47 | !next y |
||
48 | !next x |
||
49 | |||
50 | s=!item $r11+1 of $(mul$r22) |
||
51 | t=!item $r21+1 of $(mul$r12) |
||
52 | !for i = 1 to $q |
||
53 | j=!item $i of $(add$t) |
||
54 | !if $j = $s |
||
55 | det=!eval $i-1 |
||
56 | break |
||
57 | !endif |
||
58 | !next i |
||
59 | |||
60 | !else q=p |
||
61 | |||
62 | field=prime |
||
63 | !for x = 0 to $q-1 |
||
64 | el$x=$x |
||
65 | !for y = 0 to $q-1 |
||
66 | x1=($a11*$x+$a12*$y+$xt)%$q |
||
67 | y1=($a21*$x+$a22*$y+$yt)%$q |
||
68 | xx=!eval ($r11*$x1+$r12*$y1+$xr)%$q |
||
69 | yy=!eval ($r21*$x1+$r22*$y1+$yr)%$q |
||
70 | n$(xx)_$yy=$x.$y |
||
71 | !next y |
||
72 | !next x |
||
73 | det=!eval ($r11*$r22-$r21*$r12)%$q |
||
74 | |||
75 | !endif q or p |
||
76 | |||
77 | !if $det = 0 |
||
78 | !for x = 0 to $q-1 |
||
79 | !for y = 0 to $q-1 |
||
80 | !if $(n$(x)_$y) = $empty |
||
81 | n$(x)_$y = bad |
||
82 | !endif |
||
83 | !next y |
||
84 | !next x |
||
85 | !endif |
||
86 | |||
87 | !if $n0_0=0.0 and $n1_0=1.0 and $n0_1=0.1 and $status=waiting and $reply_cnt>0 |
||
88 | found=yes |
||
89 | wims_module_log=success after $reply_cnt tries from $httpd_REMOTE_HOST |
||
90 | wims_print_precision=4 |
||
91 | module_score=$[10*($q-1)/$reply_cnt] |
||
92 | !if $module_score>10 |
||
93 | module_score=10 |
||
94 | !endif |
||
95 | status=found |
||
96 | !endif |
||
97 | |||
98 | !if $cmd=help |
||
8077 | bpr | 99 | hdcolor=style="background-color:#D0D060" |
100 | opcolor=style="background-color:#A0A0A0" |
||
535 | bpr | 101 | !endif |