Talk:Generate Chess960 starting position: Difference between revisions
Content added Content deleted
m (→random starting position: updated the REXX program which produces the histograph/histogram.) |
|||
Line 79: | Line 79: | ||
file 8=270847 ============================================================ |
file 8=270847 ============================================================ |
||
</pre> |
</pre> |
||
The REXX program to produce the |
The REXX program to produce the histograms (shown above) is: |
||
<lang rexx>/*REXX program generates a histogram of 100,000 rook placement positions*/ |
<lang rexx>/*REXX program generates a histogram of 100,000 rook placement positions*/ |
||
parse arg seed times . /*obtain optional args from C.L. */ |
parse arg seed times . /*obtain optional args from C.L. */ |
||
if times=='' then times=100000 |
if times=='' then times=100000 /*use default for TIMES? {100k} */ |
||
if seed\=='' then call random ,,seed /*if SEED specified, use the seed*/ |
if seed\=='' then call random ,,seed /*if SEED specified, use the seed*/ |
||
rooks.=0 /*zero the rook position counters*/ |
rooks.=0 /*zero the rook position counters*/ |
||
do t=1 for times /*═════════════════════════════════════════════════*/ |
|||
do t=1 for times /*════════════════════════════════════════════════════*/ |
|||
r1=random(1 |
r1=random(1,8) /*place the first rook on rank1.*/ |
||
r1m=r1-1; r1p=r1+1 /*used for faster comparisons. */ |
|||
do forever; r2=random(1,8) /*place the second rook on rank1.*/ |
|||
if r2==r1 then iterate /*position is the same as rook1. */ |
|||
if r2==r1m then iterate /*it's immediately before rook1. */ |
|||
⚫ | |||
leave /*found a good 2nd rook placement*/ |
|||
⚫ | |||
do until r2\==r1 & r2\==r1-1 & r2\==r1+1 |
|||
r2=random(1,8) /*find placement for the 2nd rook*/ |
|||
⚫ | |||
end /*t ══════════════════════════════════════════════════════════════*/ |
|||
rooks.r1=rooks.r1+1 /*bump rook (r1) position counter*/ |
|||
⚫ | |||
end /*t ════════════════════════════════════════════════════════════*/ |
|||
mx=0; do j=1 for 8; mx=max(mx,rooks.j); end /*find max histo value*/ |
mx=0; do j=1 for 8; mx=max(mx,rooks.j); end /*find max histo value*/ |