/*
**  gp_strct
**
**   genetic programming structure stuff
**
*/

/* 
**   Scott "Jerry" Lawrence
**   2000 January 23-25
**   j@absynth.com
*/

/*
** $Id: gp_strct.h,v 1.6 2000/02/08 01:13:48 sdlpci Exp sdlpci $
**
** $Log: gp_strct.h,v $
 * Revision 1.6  2000/02/08  01:13:48  sdlpci
 * moved enumerate line into here
 *
 * Revision 1.5  2000/02/07  22:21:02  sdlpci
 * removed the conditional structure -- it was not needed.
 *
 * Revision 1.4  2000/01/25  17:38:49  sdlpci
 * changed the indent
 * removed the "and" clause from the conditional structure
 *
 * Revision 1.3  2000/01/25  17:08:36  sdlpci
 * added indent & commented code
 *
 * Revision 1.2  2000/01/25  05:18:39  sdlpci
 * added line creation & dump tools.
 *
 * Revision 1.1  2000/01/24  16:38:31  sdlpci
 * Initial revision
 *
*/

/*
** the tree needs to have:
 
[line]
	if [conditional] then [line] else [line]
	move in that direction
	noop

[conditional]
	[conditional] and [conditional]
	piece to the [NSEW] is [LGS] this char
	piece to the [NSEW] has been travelled X or fewer times 
 
*/

#define DIR_0    (0x00)
#define DIR_N    (0x01)
#define DIR_S    (0x02)
#define DIR_E    (0x03)
#define DIR_W    (0x04)

#define LINE_TYPE_NOOP   (0)
#define LINE_TYPE_MOVE   (1)
#define LINE_TYPE_COND   (2)

#define CONDITIONAL_TYPE_FALSE  (0)    /* always false                   */
#define CONDITIONAL_TYPE_TRUE   (1)    /* always true                    */
#define CONDITIONAL_TYPE_TRAV   (2)    /* travelled V times or fewer     */
#define CONDITIONAL_TYPE_LT     (3)    /* direction is less than this    */
#define CONDITIONAL_TYPE_GT     (4)    /* direction is greater than this */
#define CONDITIONAL_TYPE_EQ     (5)    /* direction is equal to this     */

#define CONDITIONAL_MAX (5)

typedef struct gp_line
{
    int id;
    int type;
    int cond_type;
    int cond_value;
    int direction;                /* if this is NULL ALSO, this is a noop */
    struct gp_line *line_then;
    struct gp_line *line_else;
} GP_LINE;




/*  creation / alloc features  */
GP_LINE * gp_line_new(void);


/*  deletion / free features  */
void gp_line_free(GP_LINE * l);


/*   generation features  */
GP_LINE * gp_line_gen(void);
GP_LINE * gp_line_clone(GP_LINE * src);


/*   utility features */
// enumerate the id's of the line.  (pass it in 0 or some other number)
int gp_enumerate_line(GP_LINE * node, int i);


/*  dump features  */
#define GP_LINE_INDENT_SW  (4)
extern char *move_dirs[];
void gp_line_indent(int indent);
void gp_line_dump(GP_LINE * l, int indent);
