Username: Passwort:
Neue User - Registrierung
Moderator: Walter Montego 
 Chess variants (10x8)

Sam has closed his piano and gone to bed ... now we can talk about the real stuff of life ... love, liberty and games such as
Janus, Capablanca Random, Embassy Chess & the odd mention of other 10x8 variants is welcome too


For posting:
- invitations to games (you can also use the New Game menu or for particular games: Janus; Capablanca Random; or Embassy)
- information about upcoming tournaments
- disussion of games (please limit this to completed games or discussion on how a game has arrived at a certain position
... speculation on who has an advantage or the benefits of potential moves is not permitted while that particular game is in progress)
- links to interesting related sites (non-promotional)


Liste der Diskussionsforen
Modus: Jeder kann schreiben
In Postings suchen:  

26. November 2004, 22:37:03
SMIRF Engine 
Thema: Code to generate CRC / FRC FEN strings
<well here is that part of code, with comments in mixed German and English, which creates FEN for FRC 1...960 or CRC 1...48000. The filtering of unwanted positions has to be done later. The castling rules are comparable to FRC, I do not know, what I shoul show additionally to that.

// Genese FEN-String normal (>=0) Capablanca (<0)
const char *CFig::GetFen(int nr)
{
// 0 ==> Capablanca generic Positioning

// knight distributions over 5 free squares
static const int knight_pos[10] = {
3, // xx---
5, // x-x--
9, // x--x-
17, // x---x
6, // -xx--
10, // -x-x-
18, // -x--x
12, // --xx-
20, // --x-x
24 // ---xx
};

// lösche den Ausgabebereich komplett
int pos = TXT_LIM;
while (--pos >= 0) { FenZone[pos] = '\0'; }

// wurde Capablanca Figurset verlangt ?
bool istCRC = (nr <= 0);

if (istCRC) {
// Vorzeichenwechsel beim CRC
nr = -nr;
// decide whether the queen should be set 1st
bool q_first = ((nr % 2) != 0);
nr /= 2;
// set the 1st piece by dividing 5 on bright
// (targeting at first row, white side)
PlatziereInFen(nr % 5,
q_first ? (DAME_SYM ^ TOLOW)
: (ERZBISCH_SYM ^ TOLOW), 0);
nr /= 5;
// set the 2nd piece by dividing 5 on dark
// (targeting at first row, white side)
PlatziereInFen(nr % 5,
q_first ? (ERZBISCH_SYM ^ TOLOW)
: (DAME_SYM ^ TOLOW), 1);
nr /= 5;
}

// set the bishop by dividing 4 on white fields
// (targeting at first row, white side)
PlatziereInFen(nr % 4, (LAEUFER_SYM ^ TOLOW), 0);
nr /= 4;
// set the bishop by dividing 4 on black fields
// (targeting at first row, white side)
PlatziereInFen(nr % 4, (LAEUFER_SYM ^ TOLOW), 1);
nr /= 4;
// set the queen or chancellor on a free field
// dividing 6
PlatziereInFen(nr % 6,
istCRC ? (KANZLER_SYM ^ TOLOW)
: (DAME_SYM ^ TOLOW) );
nr /= 6;
// calculate knight positions by nr and set them
pos = knight_pos[nr % 10];
for (int bit = 5; --bit >= 0; ) {
if ((pos & (1 < bit)) != 0)
PlatziereInFen(bit, (SPRINGER_SYM ^ TOLOW));
}
// set the remaining pieces, rooks and king
PlatziereInFen(2, (TURM_SYM ^ TOLOW));
PlatziereInFen(1, (KOENIG_SYM ^ TOLOW));
PlatziereInFen(0, (TURM_SYM ^ TOLOW));

// generate the resulting FEN line
int breite = istCRC ? 10 : 8;
char *pC = &FenZone[breite];
*pC++ = '/';
for (pos = breite; --pos >= 0; ) {
*pC++ = BAUER_SYM ^ TOLOW;
}
for (pos = 4; --pos >= 0; ) {
*pC++ = '/';
*pC++ = (char)('0' + breite % 10);
}
// große Buchstaben
*pC++ = '/';
for (pos = breite; --pos >= 0; ) {
*pC++ = BAUER_SYM;
}
*pC++ = '/';
for (pos = 0; pos breite; ++pos) {
*pC++ = FenZone[pos] ^ TOLOW;
}
*pC++ = ' ';
*pC++ = WEISS_SYM;
*pC++ = ' ';
*pC++ = KOENIG_SYM;
*pC++ = DAME_SYM;
*pC++ = KOENIG_SYM ^ TOLOW;
*pC++ = DAME_SYM ^ TOLOW;
strcpy(pC, " - 0 1");

// liefere den neuen FEN-String zurück
return FenZone;
}

// platziere Figur an vorgegebener freier Stelle
// (falls Color <0 gewählt wurde, ist diese egal)
void CFig::PlatziereInFen
(int nrFrei, char zeichen, int feldCol = -1)
{
// Suchschleife über den FEN-String
for (int pos = 0, frei = 0; ; ++pos) {
// falsch farbene Stellen überspringen
// (Perspektive Weiß, Grundreihe von links)
if (feldCol >= 0 && !((feldCol ^ pos) & 1)) {
continue;
}
// setze auf das erste so gefundene freie Feld
if (!FenZone[pos] && nrFrei == frei++) {
FenZone[pos] = zeichen;
break;
}
}
}

Datum und Zeit
Freunde Online
Abonnierte Foren
Vereine
Tip des Tages
Copyright © 2002 - 2024 Filip Rachunek, all rights reserved.
Zurück nach oben