Index: Makefile =================================================================== --- Makefile (revision 7384) +++ Makefile (revision 7385) @@ -1,3 +1,3 @@ -CFLAGS = -Wall -g +CFLAGS = -Wall -g -O3 LDFLAGS = -lm cap: cap.o pcb_draw.o gp.o c24lib/image/draw.o c24lib/image/image.o c24lib/image/pnm.o \ No newline at end of file Index: cap.c =================================================================== --- cap.c (revision 7384) +++ cap.c (revision 7385) @@ -10,6 +10,8 @@ #include "pcb_draw.h" #include "gp.h" +#define DUMPDIR "/tmp/gpstroke/" + #define MAX_STROKES 64 int max_strokes = 16; image_t *ref, *canvas; @@ -105,14 +107,36 @@ pcb_clear(canvas); pcb_draw(canvas, data); scr = pcb_diff(canvas, ref); - return scr + (p->len+1)*100.0; + return scr + (p->len+1)*20.0; } static inline void pcb_mutate_add(pcb_t *p) { + int loc, end, x, y; if (p->len >= MAX_STROKES) return; - rand_stroke(&p->str[p->len]); + + end = ref->sx * ref->sy; + loc = myrand(0, end); + if (rand() % 2) { + for(; ref->pixmap[loc].r > 0; loc--) + if (loc < 1) + return; + } + else { + for(; ref->pixmap[loc].r > 0; loc++) + if (loc >= end) + return; + } + + x = image_x(ref, ref->pixmap+loc); + y = image_y(ref, ref->pixmap+loc); + + p->str[p->len].x1 = x; + p->str[p->len].x2 = y; + p->str[p->len].x2 = x + myrand(2, 6); + p->str[p->len].y2 = y + myrand(2, 6); + p->str[p->len].th = myrand(3, 6); p->len++; } @@ -175,7 +199,7 @@ FILE *f; int n; - snprintf(s, sizeof(s), "/tmp/stroke_%04d_%02d.str", population_id, individual_id); + snprintf(s, sizeof(s), DUMPDIR "stroke_%04d_%02d.str", population_id, individual_id); f = fopen(s, "w"); for(n = 0; n < p->len; n++) fprintf(f,"stroke %d %d %d %d %d\n", p->str[n].x1, p->str[n].y1, p->str[n].x2, p->str[n].y2, p->str[n].th); @@ -183,7 +207,7 @@ pcb_shadow(img, ref); pcb_draw(img, data); - snprintf(s, sizeof(s), "/tmp/stroke_%04d_%02d.pnm", population_id, individual_id); + snprintf(s, sizeof(s), DUMPDIR "stroke_%04d_%02d.pnm", population_id, individual_id); pnm_save(img, s); return s; } @@ -219,5 +243,5 @@ if ((pop.pop_cnt % 20) == 0) gp_dump(stdout, &pop, 1); } - pnm_save(ref, "/tmp/ref.pnm"); + pnm_save(ref, DUMPDIR "ref.pnm"); }