Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Nevermind. I did not see the rule about opposite colored bishops.

Author: Dann Corbit

Date: 17:38:56 06/07/04

Go up one level in this thread


On June 07, 2004 at 20:33:14, Dieter Buerssner wrote:

>On June 07, 2004 at 20:25:03, Dann Corbit wrote:
>
>>Mine was shorter.
>
>Well, I checked many conditions. Is the number of NBRs 2? is the number of Ks 1,
>is the number of Qs 1? Does the K lie in between the rooks? Was the position
>already seen? I believe, these are all the conditions, one could check, or did I
>miss one?

Yes, your routine was much more thorough.

Since I generated the positions from this array:
char chessmen[9] = "bbknnqrr";

I knew that all the counts were correct.

My first pass did this (after the initial combination generation):

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

static char     string[32767];
int             main(void)
{
    while (fgets(string, sizeof string, stdin)) {
        int             i;
        int             r0 = -1,
                        r1 = -1,
                        k = -1;
        for (i = 0; i < 8; i++) {
            if (string[i] == 'r')
                if (r0 == -1)
                    r0 = i;
                else
                    r1 = i;
            if (string[i] == 'k')
                k = i;
        }
        if (k > r0 && k < r1)
            puts(string);
    }
    return 0;
}

which neglected to check the bishop rule.

Interestingly, the standard chess castling rule is a pure subset of the FRC
castling rule.  So if you encode the FRC castling rule in your program, that is
the only change needed, I think.

Or am I missing something important?



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.