[QUIZ] Chess Variants (I) (#35)

R

Ruby Quiz

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!

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

One of the greatest challenges in programming is modular design. Building code
that adapts well to change is a Holy Grail quest for most of us. This two-part
Ruby Quiz is designed to put your ability to predict the future to the test.

This week, the Ruby Quiz is to build an engine for two player chess. Note that
I said "two player" there. You are not expected to develop an AI at any point,
just a board and piece interface players can use for games. The game should
prevent illegal moves, make sure the right player moves at the right time,
declare a winner when a game ends, etc.

You can use any interface you like, but my recommendation is to keep it as
simple as possible. ASCII art is fine. Pieces are traditionally represented as
follows:

K = King
Q = Queen
B = Bishop
N = Knight
R = Rook
P = Pawn

Uppercase is usually used for white pieces, lowercase for black. It's fine to
assume that both players alternate turns at the same keyboard. Just provide
some means to make moves and see the resulting position. That's all we need.

Next week, in part two of this quiz, I will provide a list of chess variants you
are expected to modify your program to support. You may prepare for this with
your initial version in any way that you like (plug-in support, a domain
specific language for chess games, etc.) There is little point in trying to
predict my chosen variations exactly though. You don't want to know how many
different variations there are to chess, trust me.

Please do not post any variations this week, even after the spoiler period. For
now, we are concerned only with standard chess.

If you are not familiar with the rules of chess, you can read about them here:

http://www.chessvariants.com/d.chess/chess.html

Note the description of the "en-passant" rule for pawns. Some casual chess
players are not aware of this rule. Some people are also unaware that you can
castle to queenside, but you can as the rules show.

You do not need to concern yourself with chess notation (unless you want to use
it as an interface) or recognizing draws (other than stalemate). You should
recognize check (because it affects legal moves) and checkmate (as it signals
the end of the game).
 
G

Gavin Kistner

This week, the Ruby Quiz is to build an engine for two player
chess. Note that
I said "two player" there.
[...]
The game should
prevent illegal moves, make sure the right player moves at the
right time,
declare a winner when a game ends, etc.
[...]
If you are not familiar with the rules of chess, you can read about
them here:

http://www.chessvariants.com/d.chess/chess.html

Note the description of the "en-passant" rule for pawns.
[...]
Some people are also unaware that you can
castle to queenside, but you can as the rules show.
[...]
You should recognize check (because it affects legal moves) and
checkmate (as it signals
the end of the game).

This looks like a fun problem and (as my past two quizzes have shown)
I'm not a great judge of time required for a problem, but...is it
really expected that the above should take 30-60 minutes for an
average coder?

Am I that slow to imagine that the above is 3-5 hours (at minimum)?
 
J

James Edward Gray II

This looks like a fun problem and (as my past two quizzes have
shown) I'm not a great judge of time required for a problem,
but...is it really expected that the above should take 30-60
minutes for an average coder?

No, probably not. The time "goal" is, and has always been, a rough
guideline. This time I'm probably stretching it a little, but we've
also had quite a few easy quizzes lately, I think. Last week's may
have been the easiest one yet.
Am I that slow to imagine that the above is 3-5 hours (at minimum)?

Your guess sounds a little high to me, but they may be because I'm a
chess nut.

A chess game is basically defined by the moves of six pieces, many of
which are trivial. The King is the biggest challenge, because you
need to look for check and checkmate, but that gives you the ending
conditions as well. Bishop and rook are no challenge at all and a
queen is a bishop plus a rook, right? A knight's movements are
probably harder to teach a human than a computer. The pawn is the
only other piece that requires a little work, I think. Do a little
thinking before you code and my guess is that a good plan can be
implemented a little faster than you think.

Beyond that, it's my opinion that this will be a really fun problem.
You try to leave your solution open to next week's challenge and see
how you fair. I'm hoping that will entice someone to give it a
chance...

However, the ultimate choice is naturally yours. If you think it's
too much of a time sink, skip this round. You always have this
option and it seems to me that many people take advantage of it
regularly.

If you haven't noticed by now, I work every quiz that no one
touches. That's my way of telling you that I don't ask you to do
anything I wouldn't do. So if you really think it's ridiculous you
can votes with your silence and "call my bluff". I feel this did
happen on the Yahtzee quiz and you guys were right that it was harder
than I intended. (You were dead wrong about not working the Code
Cleaning quiz though and I'm still bitter about that! <laughs>)

The moral is that I'm trying something a little different with this
quiz. We'll see if it flies... ;) I'm also listening though and I
now know that at least one of you considers it over the top.

James Edward Gray II
 
G

Gavin Kistner

--Apple-Mail-3-518612876
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed

The moral is that I'm trying something a little different with this
quiz. We'll see if it flies... ;) I'm also listening though and
I now know that at least one of you considers it over the top.

Over the top for the stated 30-60 minutes, perhaps.

Certainly not over the top in terms of fun and worthiness. I'm coding
right now :)

--Apple-Mail-3-518612876--
 
J

James Edward Gray II

Over the top for the stated 30-60 minutes, perhaps.

Certainly not over the top in terms of fun and worthiness.

My biggest challenge in running Ruby Quiz is always coming up with
unique ideas. I try to find interesting challenges and sometimes I
think I even succeed. :)

Ruby Quiz fans have another right I forgot to mention in my last
message though. You can submit your own problems! I run your stuff
before mine, so the community could keep my quite for a good long
time if they desired. Instead, my inbox has been ghostly quiet lately.

Of course, I'm not targeting Gavin with that comment, since he holds
the Ruby Quiz submission record!

James Edward Gray II
 
G

Gavin Kistner

--Apple-Mail-4-520458707
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed

Some people are also unaware that you can castle to queenside, but
you can as the rules show.

As castling involves moving two pieces with one move, how is it
traditionally specified?

Do you simply specify to move the King to the appropriate square, and
(because it is a distance-two move with a rook in the right spot and
all other criteria met) it is allowed and the rook is moved at the
same time?

--Apple-Mail-4-520458707--
 
J

James Edward Gray II

As castling involves moving two pieces with one move, how is it
traditionally specified?

Do you simply specify to move the King to the appropriate square,
and (because it is a distance-two move with a rook in the right
spot and all other criteria met) it is allowed and the rook is
moved at the same time?

You nailed it. That's exactly how it's done in most of the software
I've ever seen. Or, if you were using notation to specify moves
castling is written:

O-O (kingside)
O-O-O (queenside)

James Edward Gray II
 
K

Kristof Bastiaensen

You can use any interface you like, but my recommendation is to keep it
as simple as possible. ASCII art is fine. Pieces are traditionally
represented as follows:

K = King
Q = Queen
B = Bishop
N = Knight
R = Rook
P = Pawn
You may be interested in my graphical Chess Board that I wrote. It works
for Ruby-Gtk. It doesn't implement an engine, but it is particularly well
suited for implementing Chess Variants. That is in fact what I intended
to do (write a program for variants of Shogi, Japanese Chess), but I
haven't found the time finish it. The board API however works very well
(even better that xboard if I may say so myself ;-). Adapting it for
another toolkit shouldn't be very difficult, but requires C-code, so may
be it would be to much effort for this quiz. I have some documentation,
but I haven't included it yet, so if anyone is interested I'll upload it.

You can find it at (http://gcboard.sourceforge.net)

KB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top