Author: Michel Langeveld
Date: 01:27:57 09/21/01
I made a program in a few minutes to convert an epdfile to
In this way it's possible to test a testsuite with the command 'test <testfile>'
in crafty.
I couldn't find this option for this in the epd commands. There's no such
command described in epdhelp and crafty.doc. (Crafty.doc doesn't describe epd
commands at all. But anyway here's the program
The code is a little hack. But I promise to fix all bugs people will send me.
Michel
---------------------- CUT HERE ---------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void process(char *s)
{
static int epdcounter = 0;
char *epdend;
char *bmstart, *bmend;
char *idstart, *idend;
char epd[100];
char bm[100];
char id[100];
epdcounter++;
/////////////////////////////
// epd
/////////////////////////////
epdend = strstr(s, " bm ");
strncpy(epd, s, epdend-s);
epd[epdend-s] = '\0';
/////////////////////////////
// bm
/////////////////////////////
bmstart = strstr(s, " bm ");
if (bmstart == NULL)
{
printf("Error: No bm found in [%s]", s);
exit(1);
}
bmstart += 4;
bmend = strstr(bmstart, ";");
strncpy(bm, bmstart, bmend-bmstart);
bm[bmend-bmstart] = '\0';
/////////////////////////////
//id
/////////////////////////////
idstart = strstr(s, " id ");
if (idstart == NULL)
{
printf("Error: No bm found in [%s]", s);
exit(1);
}
idstart += 5;
idend = strstr(idstart, "\"");
strncpy(id, idstart, idend-idstart);
id[idend-idstart] = '\0';
printf("title %s\n", id);
printf("setboard %s\n", epd);
printf("solution %s\n", bm);
printf("\n");
}
int main(int argc, char *argv[])
{
char s [1000];
if (argc != 2)
{
printf("Epd2sol v1.0 by Michel Langeveld
(michel.langeveld@wanadoo.nl)\n");
printf("\n");
printf("Usage: epd2sol <inputfile>\n");
printf("\n");
printf("Example: epd2sol ecm.epd > ecm.sol\n");
printf("In Crafty: test ecm.sol\n");
exit(0);
}
FILE *f = fopen(argv[1], "r");
while ( !feof(f) && fgets( s, 1000, f ) != NULL )
{
//delete line-end
s[strlen(s)-1] = '\0';
process(s);
}
printf("end\n");
return 0;
}
---------------------- CUT HERE ---------------------------
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.