From: Chunyun Zhao Date: 2006-12-17T23:08:23+09:00 Subject: Re: [QUIZ] Chess960 (#106) ------=_Part_528_33120105.1166364500153 Content-Type: multipart/alternative; boundary="----=_Part_529_15141212.1166364500153" ------=_Part_529_15141212.1166364500153 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Attached is my solution. -Chunyun Sample output: Generated 960 starting positions. Starting position 93: |+++++++++++++++++++++++++++++++| | b | n | r | b | k | q | r | n | |+++++++++++++++++++++++++++++++| | p | p | p | p | p | p | p | p | |+++++++++++++++++++++++++++++++| | | | | | | | | | |+++++++++++++++++++++++++++++++| | | | | | | | | | |+++++++++++++++++++++++++++++++| | | | | | | | | | |+++++++++++++++++++++++++++++++| | | | | | | | | | |+++++++++++++++++++++++++++++++| | P | P | P | P | P | P | P | P | |+++++++++++++++++++++++++++++++| | B | N | R | B | K | Q | R | N | |+++++++++++++++++++++++++++++++| On 12/15/06, Ruby Quiz wrote: > > The three rules of Ruby Quiz: > > 1. Please do not post any solutions or spoiler discussion for this quiz > until > 48 hours have passed from the time on this message. > > 2. Support Ruby Quiz by submitting ideas as often as you can: > > http://www.rubyquiz.com/ > > 3. Enjoy! > > Suggestion: A [QUIZ] in the subject of emails about the problem helps > everyone > on Ruby Talk follow the discussion. Please reply to the original quiz > message, > if you can. > > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > > by Kieran Wild > > Chess960, is a chess variant produced by Grandmaster Bobby Fischer by > formalizing the rules of Shuffle Chess. Its goal was to create a chess > variant > in which chess creativity and talent would be more important than > memorization > and analysis of opening moves. His approach was to create a randomized > initial > chess position, which would thus make memorizing chess opening move > sequences > far less helpful. The initial position is set up in a special way and > there are > 960 such positions, thus the name Chess960. > > The starting position for Chess960 must meet certain rules. White pawns > are > placed on the second rank as in chess. All remaining white pieces are > placed > randomly on the first rank, but with the following restrictions: > > * The king is placed somewhere between the two rooks. > * The bishops are placed on opposite-colored squares. > > The black pieces are placed equal-and-opposite to the white pieces. For > example, > if the white king is placed on b1, then the black king is placed on b8. > Note > that the king never starts on file a or h, because there would be no room > for a > rook > > Can I suggest a nice little ruby program to generates all 960 possible > starting > positions and outputs a random one on request. > > Output could be as follows. > > Starting Position 432: > > White > > a1 b1 c1 d1 e1 f1 g1 h1 > N B B R K R Q N > > Black > > a8 b8 c8 d8 e8 f8 g8 h8 > N B B R K R Q N > > Or some better output. > > ------=_Part_529_15141212.1166364500153 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Attached is my solution.

-Chunyun

Sample output:

Generated 960 starting positions.

Starting position 93:

|+++++++++++++++++++++++++++++++|
| b | n | r | b | k | q | r | n |
|+++++++++++++++++++++++++++++++|
| p | p | p | p | p | p | p | p |
|+++++++++++++++++++++++++++++++|
|   |   |   |   |   |   |   |   |
|+++++++++++++++++++++++++++++++|
|   |   |   |   |   |   |   |   |
|+++++++++++++++++++++++++++++++|
|   |   |   |   |   |   |   |   |
|+++++++++++++++++++++++++++++++|
|   |   |   |   |   |   |   |   |
|+++++++++++++++++++++++++++++++|
| P | P | P | P | P | P | P | P |
|+++++++++++++++++++++++++++++++|
| B | N | R | B | K | Q | R | N |
|+++++++++++++++++++++++++++++++|


On 12/15/06, Ruby Quiz <james@grayproductions.net > wrote:
The three rules of Ruby Quiz:

1.  Please do not post any solutions or spoiler discussion for this quiz until
48 hours have passed from the time on this message.

2.  Support Ruby Quiz by submitting ideas as often as you can:

http://www.rubyquiz.com/

3.  Enjoy!

Suggestion:  A [QUIZ] in the subject of emails about the problem helps everyone
on Ruby Talk follow the discussion.  Please reply to the original quiz message,
if you can.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

by Kieran Wild

Chess960, is a chess variant produced by Grandmaster Bobby Fischer by
formalizing the rules of Shuffle Chess. Its goal was to create a chess variant
in which chess creativity and talent would be more important than memorization
and analysis of opening moves. His approach was to create a randomized initial
chess position, which would thus make memorizing chess opening move sequences
far less helpful. The initial position is set up in a special way and there are
960 such positions, thus the name Chess960.

The starting position for Chess960 must meet certain rules. White pawns are
placed on the second rank as in chess. All remaining white pieces are placed
randomly on the first rank, but with the following restrictions:

        * The king is placed somewhere between the two rooks.
        * The bishops are placed on opposite-colored squares.

The black pieces are placed equal-and-opposite to the white pieces. For example,
if the white king is placed on b1, then the black king is placed on b8. Note
that the king never starts on file a or h, because there would be no room for a
rook

Can I suggest a nice little ruby program to generates all 960 possible starting
positions and outputs a random one on request.

Output could be as follows.

        Starting Position 432:

        White

        a1 b1 c1 d1 e1 f1 g1 h1
        N  B  B   R  K  R  Q  N

        Black

        a8 b8 c8 d8 e8 f8 g8 h8
        N  B  B   R  K  R  Q  N

Or some better output.


------=_Part_529_15141212.1166364500153-- ------=_Part_528_33120105.1166364500153 Content-Type: application/octet-stream; name=chess960.rb Content-Transfer-Encoding: base64 X-Attachment-Id: f_evwebg3h Content-Disposition: attachment; filename="chess960.rb" IwojPT0gU3lub3BzaXMKIwojIFRoaXMgcHJvZ3JhbSBpcyB0byBnZW5lcmF0ZSA5NjAgcG9zc2li bGUgc3RhcnRpbmcKIyBwb3NpdGlvbnMgYW5kIG91dHB1dHMgYSByYW5kb20gb25lIG9uIHJlcXVl c3QuCiMKIz09IFVzYWdlCiMgcnVieSBjaGVzczk2MC5yYgojCiM9PSBBdXRob3IKIyBDaHVueXVu IFpoYW8gKGNodW55dW4uemhhb0BnbWFpbC5jb20pCiMKY2xhc3MgQ2hlc3M5NjAKICBCSVNIT1As IFJPT0ssIEtOSUdIVCwgUVVFRU4sIEtJTkcgPSAiQiIsICJSIiwgIk4iLCAiUSIsICJLIgogIFBQ X1BPU0lUSU9OX1RFTVBMQVRFID0gPDxURU1QTEFURS5zcGxpdCgiXG4iKQp8KysrKysrKysrKysr KysrKysrKysrKysrKysrKysrK3wKfCAwIHwgMSB8IDIgfCAzIHwgNCB8IDUgfCA2IHwgNyB8Cnwr KysrKysrKysrKysrKysrKysrKysrKysrKysrKysrfAp8IHAgfCBwIHwgcCB8IHAgfCBwIHwgcCB8 IHAgfCBwIHwKfCsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKyt8CnwgICB8ICAgfCAgIHwg ICB8ICAgfCAgIHwgICB8ICAgfAp8KysrKysrKysrKysrKysrKysrKysrKysrKysrKysrK3wKfCAg IHwgICB8ICAgfCAgIHwgICB8ICAgfCAgIHwgICB8CnwrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrfAp8ICAgfCAgIHwgICB8ICAgfCAgIHwgICB8ICAgfCAgIHwKfCsrKysrKysrKysrKysr KysrKysrKysrKysrKysrKyt8CnwgICB8ICAgfCAgIHwgICB8ICAgfCAgIHwgICB8ICAgfAp8Kysr KysrKysrKysrKysrKysrKysrKysrKysrKysrK3wKfCBQIHwgUCB8IFAgfCBQIHwgUCB8IFAgfCBQ IHwgUCB8CnwrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrfAp8IDAgfCAxIHwgMiB8IDMg fCA0IHwgNSB8IDYgfCA3IHwKfCsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKyt8ClRFTVBM QVRFCgogIGRlZiBzZWxmLnBvc2l0aW9ucwogICAgQEBwb3NpdGlvbnMKICBlbmQgCgogIGRlZiBz ZWxmLmdldF9wcF9wb3NpdGlvbihpbmRleCkKICAgIHBwX3Bvc2l0aW9uID0gUFBfUE9TSVRJT05f VEVNUExBVEUuZHVwCiAgICBwcF9wb3NpdGlvblsxXSA9IHBwX3Bvc2l0aW9uWzFdLmdzdWIoL1xk Lykge3x4fCBwb3NpdGlvbnNbaW5kZXhdW3gudG9faV0uZG93bmNhc2V9CiAgICBwcF9wb3NpdGlv blstMl0gPSBwcF9wb3NpdGlvblstMl0uZ3N1YigvXGQvKSB7fHh8IHBvc2l0aW9uc1tpbmRleF1b eC50b19pXS51cGNhc2V9CiAgICBwcF9wb3NpdGlvbgogIGVuZAoKICBkZWYgc2VsZi5nZW5lcmF0 ZV9hbGxfcG9zaXRpb25zCiAgICBAQHBvc2l0aW9ucyA9IFtdCiAgICA0LnRpbWVzIGRvIHxiMXwK ICAgICAgNC50aW1lcyBkbyB8YjJ8CiAgICAgICAgNi50aW1lcyBkbyB8cXwKICAgICAgICAgIDUu dGltZXMgZG8gfG4xfAogICAgICAgICAgICAobjErMSkudXB0byg0KSBkbyB8bjJ8CiAgICAgICAg ICAgICAgcG9zaXRpb24gPSBBcnJheS5uZXcoOCkKICAgICAgICAgICAgICBmaWxsX2JsYW5rIShw b3NpdGlvbiwgQklTSE9QLCBiMSoyLCBiMioyKzEpCiAgICAgICAgICAgICAgZmlsbF9ibGFuayEo cG9zaXRpb24sIFFVRUVOLCBxKQogICAgICAgICAgICAgIGZpbGxfYmxhbmshKHBvc2l0aW9uLCBL TklHSFQsIG4xLCBuMikKICAgICAgICAgICAgICBmaWxsX2JsYW5rIShwb3NpdGlvbiwgUk9PSywg MCwgMikKICAgICAgICAgICAgICBmaWxsX2JsYW5rIShwb3NpdGlvbiwgS0lORywgMCkKICAgICAg ICAgICAgICBAQHBvc2l0aW9ucyA8PCBwb3NpdGlvbgogICAgICAgICAgICBlbmQgICAgICAgICAg ICAKICAgICAgICAgIGVuZAogICAgICAgIGVuZAogICAgICBlbmQKICAgIGVuZAogICAgcHV0cyAi R2VuZXJhdGVkICN7QEBwb3NpdGlvbnMubGVuZ3RofSBzdGFydGluZyBwb3NpdGlvbnMuXG5cbiIg ICAgCiAgZW5kCgogIGRlZiBzZWxmLmZpbGxfYmxhbmshKHBvc2l0aW9uLCBwaWVjZSwgKmluZGlj ZXMpCiAgICBuaWxJbmRleCA9IDAKICAgIHBvc2l0aW9uLmVhY2hfd2l0aF9pbmRleCBkbyB8cCwg eHwKICAgICAgdW5sZXNzIHAKICAgICAgICBwb3NpdGlvblt4XSA9IHBpZWNlIGlmIGluZGljZXMu aW5jbHVkZT8gbmlsSW5kZXgKICAgICAgICBuaWxJbmRleCArPSAxCiAgICAgIGVuZAogICAgZW5k CiAgZW5kCiAgCiAgZ2VuZXJhdGVfYWxsX3Bvc2l0aW9ucwplbmQKCmluZGV4ID0gcmFuZCg5NjAp CnB1dHMgIlN0YXJ0aW5nIHBvc2l0aW9uICN7aW5kZXh9OlxuXG4iCnB1dHMgQ2hlc3M5NjA6Omdl dF9wcF9wb3NpdGlvbihpbmRleCkKCg== ------=_Part_528_33120105.1166364500153--