FRC start position generator

Archive of the old Parsimony forum. Some messages couldn't be restored. Limitations: Search for authors does not work, Parsimony specific formats do not work, threaded view does not work properly. Posting is disabled.

FRC start position generator

Postby Dann Corbit » 08 Jun 2004, 01:19

Geschrieben von:/Posted by: Dann Corbit at 08 June 2004 02:19:47:

ftp://cap.connx.com/pub/chess-engines/n ... h/frcpos.c


my ftp site {remove http:// unless you like error messages}
Dann Corbit
 

Re: FRC start position generator

Postby Dann Corbit » 08 Jun 2004, 02:02

Geschrieben von:/Posted by: Dann Corbit at 08 June 2004 03:02:43:
Als Antwort auf:/In reply to: FRC start position generator geschrieben von:/posted by: Dann Corbit at 08 June 2004 02:19:47:
ftp://cap.connx.com/pub/chess-engines/new-approach/frcpos.c
use 960 instead of 980.



my ftp site {remove http:// unless you like error messages}
Dann Corbit
 

Re: FRC start position generator

Postby Volker Pittlik » 08 Jun 2004, 07:32

Geschrieben von:/Posted by: Volker Pittlik at 08 June 2004 08:32:08:
Als Antwort auf:/In reply to: Re: FRC start position generator geschrieben von:/posted by: Dann Corbit at 08 June 2004 03:02:43:

ftp://cap.connx.com/pub/chess-engines/new-approach/frcpos.c
use 960 instead of 980.
Done but:

D:\Schach\frc>cl frcpos.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3052 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
frcpos.c
Microsoft (R) Incremental Linker Version 7.10.3052
Copyright (C) Microsoft Corporation.  All rights reserved.
/out:frcpos.exe
frcpos.obj
frcpos.obj : error LNK2019: unresolved external symbol __ftol2 referenced in fun
ction _get_frc_start_pos
LIBC.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced
in function _mainCRTStartup
frcpos.exe : fatal error LNK1120: 2 unresolved externals
D:\Schach\frc>

Volker
Volker Pittlik
 

Re: 960 FRC start positions derived from numbers

Postby Reinhard Scharnagl » 08 Jun 2004, 07:54

Geschrieben von:/Posted by: Reinhard Scharnagl at 08. June 2004 08:54:
Als Antwort auf:/In reply to: FRC start position generator geschrieben von:/posted by: Dann Corbit at 08 June 2004 02:19:47:


Well, there has been a FRC position generator for nearly one year, and you
can download the "FRC FullChess FEN Editor and Position-Generator" from:
http://homepages.compuserve.de/rescharn ... ss7_e.html
(German/English)
Additionally from that time I have suggested a derivation from numbers to
well defined positions (implemented in FEN Editor) documented in (German):
http://homepages.compuserve.de/rescharn ... 960Pos.pdf
This two pages are part of a new FRC book (German) to be published in July:
http://homepages.compuserve.de/rescharn ... ialien.pdf
Regards, Reinhard.



FRC pages R. Scharnagl
Reinhard Scharnagl
 

Re: FRC start position generator

Postby Fabien Letouzey » 08 Jun 2004, 10:39

Geschrieben von:/Posted by: Fabien Letouzey at 08 June 2004 11:39:42:
Als Antwort auf:/In reply to: Re: FRC start position generator geschrieben von:/posted by: Volker Pittlik at 08 June 2004 08:32:08:

ftp://cap.connx.com/pub/chess-engines/new-approach/frcpos.c
use 960 instead of 980.
Done but:
...
Volker
define UNIT_TEST while compiling (or remove Dann's #define).
Fabien.
Fabien Letouzey
 

Re: FRC start position generator

Postby Tord Romstad » 08 Jun 2004, 11:04

Geschrieben von:/Posted by: Tord Romstad at 08 June 2004 12:04:11:
Als Antwort auf:/In reply to: FRC start position generator geschrieben von:/posted by: Dann Corbit at 08 June 2004 02:19:47:
ftp://cap.connx.com/pub/chess-engines/new-approach/frcpos.c
Just for fun, I wrote an alternative solution in Common Lisp. I like this one better than Dann's program, but that's of course just a
matter of taste.
Tord
Tord Romstad
 

Re: 960 FRC start positions derived from numbers - cpp metho

Postby Reinhard Scharnagl » 09 Jun 2004, 11:32

Geschrieben von:/Posted by: Reinhard Scharnagl at 09. June 2004 12:32:
Als Antwort auf:/In reply to: Re: 960 FRC start positions derived from numbers geschrieben von:/posted by: Reinhard Scharnagl at 08. June 2004 08:54:



// FRC 960 Starting-Position FEN string Generator
// identifying each position to a special number
// (C) 2004 Reinhard Scharnagl, Munich, Germany
#include
using namespace std;
// position sequence synthesize working array
static char piece[9];
// 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
};
// placing a piece at a counted free position, optional only on selected color
void place_at(int nr_free, char new_piece, char square_color = '\0')
{
for (int pos = 0, cnt_free = 0; ; ++pos) {
// skip wrong colored squares, (targeting at first row, white side)
if ((square_color != '\0') && ((square_color == 'w') == ((pos & 1) == 0)))
continue;
// detect the correct free field and fill it with the piece
if ((piece[pos] == '\0') && (nr_free == cnt_free++)) {
piece[pos] = new_piece;
break;
}
}
}
int main(void)
{
cout
Reinhard Scharnagl
 

Re: 960 FRC start positions derived from numbers - cpp metho

Postby Volker Pittlik » 09 Jun 2004, 12:20

Geschrieben von:/Posted by: Volker Pittlik at 09 June 2004 13:20:37:
Als Antwort auf:/In reply to: Re: 960 FRC start positions derived from numbers - cpp method geschrieben von:/posted by: Reinhard Scharnagl at 09. June 2004 12:32:


// FRC 960 Starting-Position FEN string Generator
// identifying each position to a special number
// (C) 2004 Reinhard Scharnagl, Munich, Germany


#include <iostream>
using namespace std&#59;
// position sequence synthesize working array
static char piece[9]&#59;
// 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
}&#59;
// placing a piece at a counted free position, optional only on selected color
void place_at(int nr_free, char new_piece, char square_color = '\0')
{
  for (int pos = 0, cnt_free = 0&#59; &#59; ++pos) {
    // skip wrong colored squares, (targeting at first row, white side)
    if ((square_color != '\0') && ((square_color == 'w') == ((pos & 1) == 0)))
      continue&#59;
    // detect the correct free field and fill it with the piece
    if ((piece[pos] == '\0') && (nr_free == cnt_free++)) {
      piece[pos] = new_piece&#59;
      break&#59;
    }
  }
}
int main(void)
{
  cout << "960 FRC positions (0..959):" << endl << endl&#59;
  // generate all 960 positions
  for (int nr_cnt = 0&#59; nr_cnt < 960&#59; ++nr_cnt) {
    int pos, nr = nr_cnt&#59;
    // clear all pieces 
    for (pos = 9&#59; --pos >= 0&#59; )
      piece[pos] = '\0'&#59;
    // set the bishop by dividing 4 on white fields
    // (targeting at first row, white side)
    place_at((nr % 4), 'b', 'w')&#59;
    nr /= 4&#59;
    // set the bishop by dividing 4 on black fields
    // (targeting at first row, white side)
    place_at((nr % 4), 'b', 'b')&#59;
    nr /= 4&#59;
    // set the queen in her free field dividing 6
    place_at((nr % 6), 'q')&#59;
    nr /= 6&#59;
    // calculate the knight positions by nr and set them
    pos = knight_pos[nr]&#59;
    for (int bit = 5&#59; --bit >= 0&#59; )
      if ((pos & (1 << bit)) != 0)
        place_at(bit, 'n')&#59;
    // set the remaining pieces, rooks and king
    place_at(2, 'r')&#59;
    place_at(1, 'k')&#59;
    place_at(0, 'r')&#59;
    // print out the resulting line
    cout << piece << "/pppppppp/8/8/8/8/PPPPPPPP/"&#59;
    for (pos = 8&#59; --pos >= 0&#59; )
      piece[pos] ^= 'A'^'a'&#59;
    cout << piece << " w KQkq - 0 1" << endl&#59;
  }
  return 0&#59;
}



How to post formatted text (tables, source code, the winboard.debug, HTML-tags)?
Volker Pittlik
 

Re: 960 FRC start positions derived from numbers - cpp metho

Postby Reinhard Scharnagl » 09 Jun 2004, 13:41

Geschrieben von:/Posted by: Reinhard Scharnagl at 09. June 2004 14:41:
Als Antwort auf:/In reply to: Re: 960 FRC start positions derived from numbers geschrieben von:/posted by: Reinhard Scharnagl at 08. June 2004 08:54:

sorry, previous posting has been sent too fast.
But therefore the code is able to generate both:
FRC random positions by number and also for
the Capablanca Random Chess on a 10x8 board.
(Maybe someone is interested!?)


// FRC 960 Starting-Position FEN string Generator
// identifying each position to a special number
// (C) 2004 Reinhard Scharnagl, Munich, Germany
#include <iostream>
#include <iomanip>
#include <string>
using namespace std&#59;
// position sequence synthesize working array
static char FEN_area[80]&#59;
// 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
}&#59;
// placing a piece at a counted free position, optional only on selected color
void place_at(int nr_free, char piece, char square_color = '\0')
{
  for (int pos = 0, cnt_free = 0&#59; &#59; ++pos) {
    // skip wrong colored squares, (targeting at first row, white side)
    if ((square_color != '\0') && ((square_color == 'w') == ((pos & 1) == 0)))
      continue&#59;
    // detect the correct free field and fill it with the piece
    if ((FEN_area[pos] == '\0') && (nr_free == cnt_free++)) {
      FEN_area[pos] = piece&#59;
      break&#59;
    }
  }
}
const char *genFen(unsigned nr, bool capablanca = false)
{
  int pos&#59;
  // clear all pieces 
  for (pos = sizeof(FEN_area)/sizeof(*FEN_area)&#59; --pos >= 0&#59; )
    FEN_area[pos] = '\0'&#59;
  // Capablanca special (e.g. GothicChess = 25933)
  if (capablanca) {
    // filter to Capablanca FRC range
    nr %= 48000&#59;
    // decide whether Queen placed on white or black
    bool queen_on_white = ((nr % 2) != 0)&#59;
    nr /= 2&#59;
    // set the queen by dividing 5 on selected color
    // (targeting at first row, white side)
    place_at((nr % 5), 'q', queen_on_white ? 'w' : 'b')&#59;
    nr /= 5&#59;
    // set the archbishop by dividing 5 on remaining color
    // (targeting at first row, white side)
    place_at((nr % 5), 'a', queen_on_white ? 'b' : 'w')&#59;
    nr /= 5&#59;
  } else {
    // filter to FRC range
    nr %= 960&#59;
  }
  // set the bishop by dividing 4 on white fields
  // (targeting at first row, white side)
  place_at((nr % 4), 'b', 'w')&#59;
  nr /= 4&#59;
  // set the bishop by dividing 4 on black fields
  // (targeting at first row, white side)
  place_at((nr % 4), 'b', 'b')&#59;
  nr /= 4&#59;
  // set the queen or chancellor in a free field dividing 6
  place_at((nr % 6), capablanca ? 'c' : 'q')&#59;
  nr /= 6&#59;
  // calculate the knight positions by nr and set them
  pos = knight_pos[nr]&#59;
  for (int bit = 5&#59; --bit >= 0&#59; )
    if ((pos & (1 << bit)) != 0)
      place_at(bit, 'n')&#59;
  // set the remaining pieces, rooks and king
  place_at(2, 'r')&#59;
  place_at(1, 'k')&#59;
  place_at(0, 'r')&#59;
  // generate the resulting FEN line
  if (capablanca) {
    strcat(FEN_area, "/pppppppppp/0/0/0/0/PPPPPPPPPP/")&#59;
    strncat(FEN_area, FEN_area, 10)&#59;
  } else {
    strcat(FEN_area, "/pppppppp/8/8/8/8/PPPPPPPP/")&#59;
    strncat(FEN_area, FEN_area, 8)&#59;
  }
  for (char *pc = strrchr(FEN_area, '/')&#59; *(++pc) != '\0'&#59; )
    *pc ^= 'A'^'a'&#59;
  strcat(FEN_area, " w KQkq - 0 1")&#59;
  return FEN_area&#59;
}

int main(void)
{
  const int anz = 960&#59;
  cout << anz << " FRC positions:" << endl << endl&#59;
  // generate and show positions
  for (unsigned nr_cnt = 0&#59; nr_cnt < anz&#59; ++nr_cnt) {
    cout << setw(5) << nr_cnt << ' ' << genFen(nr_cnt, false) << endl&#59;
  }
  return 0&#59;
}




FRC pages R. Scharnagl
Reinhard Scharnagl
 


Return to Archive (Old Parsimony Forum)

Who is online

Users browsing this forum: No registered users and 62 guests

cron