tree drawing tool?

Discussion of chess software programming and technical issues.

Moderator: Ras

Daniel Shawul
Posts: 4186
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

tree drawing tool?

Post by Daniel Shawul »

Is there such a tool to draw trees with circles and numbers inside. There are some that can do primitive ones with texts, but they look bad. It may be as useful as the bitboard drawing tools , if anyone needs initiative.
mar
Posts: 2672
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: tree drawing tool?

Post by mar »

You can try yEd, not sure if that's what you need though:
http://www.yworks.com/en/products_yed_about.html
Daniel Shawul
Posts: 4186
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: tree drawing tool?

Post by Daniel Shawul »

Thanks. I downloaded it and now drawing my bushy trees :)
User avatar
jshriver
Posts: 1371
Joined: Wed Mar 08, 2006 9:41 pm
Location: Morgantown, WV, USA

Re: tree drawing tool?

Post by jshriver »

I use gnuplot.
Rein Halbersma
Posts: 751
Joined: Tue May 22, 2007 11:13 am

Re: tree drawing tool?

Post by Rein Halbersma »

User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Re: tree drawing tool?

Post by Kempelen »

Daniel Shawul wrote:Is there such a tool to draw trees with circles and numbers inside. There are some that can do primitive ones with texts, but they look bad. It may be as useful as the bitboard drawing tools , if anyone needs initiative.
You can print to a file the search as it goes, putting appropiate xml tags, then can you can see the whole tree with its indents in a xml viewer. This has the adventaje you can put any information you want in each node as xml attributes.
For me this system has been very usefull, althought it is sometimes slow to i/o a big tree.
A quick example:

Code: Select all

                
                MakeMove(mov)
		          Print_xml("<%s>\n", StrMovimiento(mov));
                Print_xml("Nodo: %lu\n", stats.nodos + stats.qnodos);
                Print_xml("valor_orden: %d\n", (n - 1)->valor_movs[(n - 1)->nmov]);
...
                Print_xml("Extensiones: %d\n", ext);

                eval = -SEARCH(profundidad - 1 + ext - red, -beta, -alpha, peso + movs_legales);

                UnMake();
                Print_xml("eval: %d, alpha: %d, beta: %d\n", eval, alpha, beta);
                Print_xml("</%s>\n", StrMovimiento(mov));
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/
Daniel Shawul
Posts: 4186
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: tree drawing tool?

Post by Daniel Shawul »

I have a follow up question. Is there a standard to share trees? It seems to me xml could be a good way. I didn't ask this question for the hell of it, but i got a real need to get 5-ply data from steven's perft and use it in my engine. I can't use hashkeys as is commonly done in books, for obvious reasons. Xml is a lot more convinient and is robust for many things.
@Fermin, Do you happen to have code for reading xml tree?
Daniel Shawul
Posts: 4186
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: tree drawing tool?

Post by Daniel Shawul »

Maybe we need to define a communication protocol. Later on GUIs could help to display different information. An engine can put any entry but i think the something has to be standardized I guess. Here is an elementary ply = 3 xml tree with moves only.

Code: Select all

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<node depth="0">
<node depth="1">
<node depth="2">
<node depth="3">
<move>h3h4</move>
</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<node depth="3">...</node>
<move>h7h6</move>
</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<node depth="2">...</node>
<move>h2h3</move>
</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<node depth="1">...</node>
<move>a1a1</move>
</node>
User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Re: tree drawing tool?

Post by Kempelen »

Sorry, I dont have code to import xml, have never need it. I print to xml only to debug trees.
I dont do <move>h3h4</move> , I only close </move> tag after all search tress has finished and unmake do it. So you can indent the tree as it goes deeper.
Also I use <qmove> tag to know when entering qsearch
For faster xml load and memory, I generate one file per depth (1.xml, 2.xml and so on).

This are the functions I use:

Code: Select all

/* --------------------------------------------------------------------
 * 30-Abril-2008 : Open_xml()
 *
 * CREA UN FICHERO PARA HACER VOLCADOS DE BUSQUEDAS
 *
 * --------------------------------------------------------------------
 */
void Open_xml(int x) {
        if (x != IMPRIMIR_ARBOL_PROF) {
                return;
        }

        char            s[50];

        sprintf(s, "%d.xml", x);
        fXML = fopen(s, "w");

        if (fXML == NULL) {
                return;
        }

        Print_xml("<?xml version=\"1.0\" encoding='iso-8859-1' ?>\n");
}

/* --------------------------------------------------------------------
 * 30-Abril-2008 : Close_xml()
 *
 * CIERRA EL FICHERO XML USADO PARA VOLCAR LAS BUSQUEDAS
 *
 * --------------------------------------------------------------------
 */
void Close_xml() {
        if (fXML != NULL) {
                fclose(fXML);
        }
}

/* --------------------------------------------------------------------
 * 30-Abril-2008 : Print_xml()
 *
 * Volcado de la busqueda a xml
 *
 * --------------------------------------------------------------------
 */
void Print_xml(const char *formato, ...) {
        ASSERT(strlen(formato) > 0 && formato != NULL);
        va_list         pa;

        char           *p;

        char            internal_format[512];

        if (fXML == NULL) {
                return;
        }

        va_start(pa, formato);

        for (p = formato; *p; p++) {
                if (*p != '%') {
                        fprintf(fXML, "%c", *p);
                        continue;
                }

                internal_format[0] = *p;
                int             cont = 1;

                do {
                        p++;
                        internal_format[cont] = *p;
                        cont++;
                } while (*p != 'd' && *p != 's' && *p != 'c');

                internal_format[cont] = '\0';
                int             x;

                char           *s;

                char            c;

                switch (internal_format[cont - 1]) {
                case 'd':
                        x = va_arg(pa, int);

                        fprintf(fXML, internal_format, x);
                        break;
                case 's':
                        s = va_arg(pa, char *);

                        fprintf(fXML, internal_format, s);
                        break;
                case 'c':
                        c = va_arg(pa, int);

                        fprintf(fXML, internal_format, c);
                        break;
                default:
                        fprintf(fXML, "%c", *p);
                }
        }

        va_end(pa);
        fflush(fXML);
}
I use this software to see generated xml:
http://www.mindfusion.eu/product1.html

If you are very interested, I can send you a dumped xml tree. Let me know.
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/
Daniel Shawul
Posts: 4186
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: tree drawing tool?

Post by Daniel Shawul »

@Fermin, please send me the dumped tree so that I follow the essence of your format. Right now my data will probably be very different since the tree i generate is not from alpha-beta.