Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Open Source Chess Programs

Author: Dann Corbit

Date: 20:01:16 06/07/05

Go up one level in this thread


On June 07, 2005 at 21:32:33, Pedro Castro wrote:

>Tord, how I can count the line number (code) of the program?,  some interface

/* wc: count lines, words, chars */

#include <stdio.h>

int main(int argc, char *argv[])
{
    int             c,
                    i,
                    inword;
    FILE           *fp;
    long            linect,
                    wordct,
                    charct;
    long            tlinect = 0,
                    twordct = 0,
                    tcharct = 0;

    i = 1;
    fp = stdin;
    printf(" lines   words   chars   file\n");
    printf("======= ======= =======  =====\n");
    do {
        if (argc > 1 && (fp = fopen(argv[i], "r")) == NULL) {
            fprintf(stderr, "                        wc: can't open %s\n",
argv[i]);
            continue;
        }
        linect = wordct = charct = inword = 0;
        while ((c = getc(fp)) != EOF) {
            charct++;
            if (c == '\n')
                linect++;
            if (c == ' ' || c == '\t' || c == '\n')
                inword = 0;
            else if (inword == 0) {
                inword = 1;
                wordct++;
            }
        }
        printf("%7ld %7ld %7ld  ", linect, wordct, charct);
        printf(argc > 1 ? "%s\n" : "\n", argv[i]);
        fclose(fp);
        tlinect += linect;
        twordct += wordct;
        tcharct += charct;
    } while (++i < argc);
    if (argc > 2)
        printf("%7ld %7ld %7ld  total\n", tlinect, twordct, tcharct);
    return 0;
}

>I always have remained astonished at the code of Olithink, very compact, some
>times I wonder myself where is the evaluation?

It just counts the wood.

/* The complex evaluation function: */
int eval(int on_move) {
	return on_move ? matValue : -matValue;
}

>although I must recognize that I
>do not understand practically anything (bitboard), I am peculiar to see version
>5, although it seems that his author has a little stopped.
>
>Pedro



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.