Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39821 additions and 8315 deletions
|
|
@ -0,0 +1,28 @@
|
|||
USING: io kernel math random sequences ;
|
||||
IN: rosetta-code.chess960
|
||||
|
||||
: empty ( seq -- n ) 32 swap indices random ; ! return a random empty index (i.e. equal to 32) of seq
|
||||
: next ( seq -- n ) 32 swap index ; ! return the leftmost empty index of seq
|
||||
: place ( seq elt n -- seq' ) rot [ set-nth ] keep ; ! set nth member of seq to elt, keeping seq on the stack
|
||||
|
||||
: white-bishop ( -- elt n ) CHAR: ♗ 4 random 2 * ;
|
||||
: black-bishop ( -- elt n ) white-bishop 1 + ;
|
||||
: queen ( seq -- seq elt n ) CHAR: ♕ over empty ;
|
||||
: knight ( seq -- seq elt n ) CHAR: ♘ over empty ;
|
||||
: rook ( seq -- seq elt n ) CHAR: ♖ over next ;
|
||||
: king ( seq -- seq elt n ) CHAR: ♔ over next ;
|
||||
|
||||
: chess960 ( -- str )
|
||||
" " clone
|
||||
black-bishop place
|
||||
white-bishop place
|
||||
queen place
|
||||
knight place
|
||||
knight place
|
||||
rook place
|
||||
king place
|
||||
rook place ;
|
||||
|
||||
: chess960-demo ( -- ) 5 [ chess960 print ] times ;
|
||||
|
||||
MAIN: chess960-demo
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
USING: chess960 prettyprint ;
|
||||
|
||||
chess960-position .
|
||||
Loading…
Add table
Add a link
Reference in a new issue