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