WIP: premiers essais avec de petits nombres aléatoires. Une erreur systématique (couleurs).
This commit is contained in:
parent
a3f0483891
commit
d29c19636b
|
@ -41,7 +41,7 @@ void show_arrows_array (struct arrow_t *arrows, int arrows_nb, int x, int y, int
|
||||||
void print_arrows_array (struct arrow_t *arrows, int arrows_nb, int invoked_by);
|
void print_arrows_array (struct arrow_t *arrows, int arrows_nb, int invoked_by);
|
||||||
void print_user_action(struct arrow_t *arrows, int arrows_nb, int address, int requested_weight,
|
void print_user_action(struct arrow_t *arrows, int arrows_nb, int address, int requested_weight,
|
||||||
int current_weight, int site, int x, int y, int z);
|
int current_weight, int site, int x, int y, int z);
|
||||||
void print_user_choices(struct arrow_t *arrows, int arrows_nb,
|
void print_user_choices(struct arrow_t *arrows, int max_arrows_nb, int arrows_nb,
|
||||||
int space_size_x, int space_size_y, int space_size_z,
|
int space_size_x, int space_size_y, int space_size_z,
|
||||||
int show_array, int show_space_design);
|
int show_array, int show_space_design);
|
||||||
void print_evolution (struct arrow_t *arrows, int arrows_nb, int modified, int deleted, int show_array);
|
void print_evolution (struct arrow_t *arrows, int arrows_nb, int modified, int deleted, int show_array);
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
// assert : arrows localization within space and sites
|
// assert : arrows localization within space and sites
|
||||||
// assert : no more than one arrow per address
|
// assert : no more than one arrow per address
|
||||||
// notify : weights are replaced, NOT added (could be !)
|
// notify : weights are replaced, NOT added (could be !)
|
||||||
/*
|
*
|
||||||
* Init space and arrows (= initial state)
|
* Init space and arrows (= initial state)
|
||||||
* and allows ulterior creations, suppressions or modifications of the arrows[] array
|
* and allows ulterior creations, suppressions or modifications of the arrows[] array
|
||||||
*
|
*
|
||||||
|
@ -79,6 +79,39 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* I N I T I A L D A T A A R E N O W A L L S P E C I F I E D */
|
||||||
|
|
||||||
|
/* A N D C A N B E D R A W N */
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* N E W D A T A W I L L N O W B E S P E C I F I E D */
|
||||||
|
|
||||||
|
/* A N D T H E N D R A W N E D */
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
/* If load == 0 then erase the arrow at this address v */
|
||||||
|
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 0, 0, 0, 0, console); */
|
||||||
|
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 1, 0, 0, 0, console); */
|
||||||
|
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 2, 0, 0, 0, console); */
|
||||||
|
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 3, 0, 0, 0, console); */
|
||||||
|
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 4, 0, 0, 0, console); */
|
||||||
|
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 5, 0, 0, 0, console); */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
/*--------------------------------------------------------------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
/*--------------------------------------------------------------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------------------------------------------------------------*/
|
||||||
|
@ -117,12 +150,12 @@ void print_arrows_array (struct arrow_t *arrows, int arrows_nb, int invoked_by)
|
||||||
* NB The space may be empty or saturated with arrows or any value in between
|
* NB The space may be empty or saturated with arrows or any value in between
|
||||||
* Only one arrow per possible coordinates with a load max equal to ? TODO
|
* Only one arrow per possible coordinates with a load max equal to ? TODO
|
||||||
*/
|
*/
|
||||||
void print_user_choices(struct arrow_t *arrows, int arrows_nb,
|
void print_user_choices(struct arrow_t *arrows, int max_arrows_nb, int arrows_nb,
|
||||||
int space_size_x, int space_size_y, int space_size_z,
|
int space_size_x, int space_size_y, int space_size_z,
|
||||||
int show_array, int show_space_design)
|
int show_array, int show_space_design)
|
||||||
{
|
{
|
||||||
printf("model + user constraints :\tspace size x,y,z (%3d,%3d,%3d)\t\tarrows nb : %6d\t",\
|
printf("model + user constraints :\tspace size x,y,z (%d,%d,%d)\t\tarrows nb : %d > %d\t",\
|
||||||
space_size_x, space_size_y, space_size_z, arrows_nb);
|
space_size_x, space_size_y, space_size_z, max_arrows_nb, arrows_nb);
|
||||||
|
|
||||||
if (show_space_design) printf(" (grilles alternées)");
|
if (show_space_design) printf(" (grilles alternées)");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
|
@ -658,7 +658,10 @@ static inline int create_arrow (int arrows_nb,
|
||||||
|
|
||||||
write_one_arrow_vertex(space_X, space_Y, space_Z,
|
write_one_arrow_vertex(space_X, space_Y, space_Z,
|
||||||
load, site, x, y, z, console);
|
load, site, x, y, z, console);
|
||||||
buffer_colors_size = buffer_vertex_size;
|
/* L'incrémentation de buffer_colors_size
|
||||||
|
* est faite dans graphics_write_color()
|
||||||
|
* > donc: ligne suivante inutile */
|
||||||
|
/* buffer_colors_size = buffer_vertex_size; */
|
||||||
|
|
||||||
write_one_arrow_line (buffer_vertex_size / 3 - 2, console);
|
write_one_arrow_line (buffer_vertex_size / 3 - 2, console);
|
||||||
|
|
||||||
|
@ -673,14 +676,12 @@ static inline int erase_arrow (int arrows_nb, int address_of_the_arrow_to_erase_
|
||||||
int site, int x, int y, int z,
|
int site, int x, int y, int z,
|
||||||
int console)
|
int console)
|
||||||
{
|
{
|
||||||
|
if (arrows_nb == 0) assert (buffer_lines_size == buffer_lines_0_arrow); // ?
|
||||||
|
if (arrows_nb == 0) {buffer_lines_size = buffer_lines_0_arrow; return 0;}
|
||||||
|
|
||||||
assert (arrows_nb);
|
assert (arrows_nb);
|
||||||
arrows_nb --;
|
arrows_nb --;
|
||||||
|
|
||||||
/* Il ne faut pas réécrire ce qui suit: ces lignes dessinent maintenant à partir d'autres vertex */
|
|
||||||
/* void *new_arrows_lines_ptr = g_realloc(buffer_lines_origin, buffer_lines_size * sizeof(GLfloat)); */
|
|
||||||
/* if (new_arrows_lines_ptr) buffer_lines_origin = new_arrows_lines_ptr; */
|
|
||||||
/* else perror("In graphics.erase_arrow(), can't re_allocate for arrows lines buffer.\n"); */
|
|
||||||
|
|
||||||
void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_size * sizeof(GLfloat));
|
void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_size * sizeof(GLfloat));
|
||||||
if (new_arrows_vertex_ptr) buffer_vertex_origin = new_arrows_vertex_ptr;
|
if (new_arrows_vertex_ptr) buffer_vertex_origin = new_arrows_vertex_ptr;
|
||||||
else perror("In graphics.erase_arrow(), can't re_allocate for arrows vertex buffer.\n");
|
else perror("In graphics.erase_arrow(), can't re_allocate for arrows vertex buffer.\n");
|
||||||
|
@ -693,6 +694,11 @@ static inline int erase_arrow (int arrows_nb, int address_of_the_arrow_to_erase_
|
||||||
buffer_colors_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_colors()
|
buffer_colors_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_colors()
|
||||||
buffer_lines_size -= 2; // <<< l'inverse de ce qui est fait dans : graphics_write_line()
|
buffer_lines_size -= 2; // <<< l'inverse de ce qui est fait dans : graphics_write_line()
|
||||||
|
|
||||||
|
/* Il ne faut pas réécrire ce qui suit: ces lignes dessinent maintenant à partir d'autres vertex */
|
||||||
|
/* void *new_arrows_lines_ptr = g_realloc(buffer_lines_origin, buffer_lines_size * sizeof(GLfloat)); */
|
||||||
|
/* if (new_arrows_lines_ptr) buffer_lines_origin = new_arrows_lines_ptr; */
|
||||||
|
/* else perror("In graphics.erase_arrow(), can't re_allocate for arrows lines buffer.\n"); */
|
||||||
|
|
||||||
if (address_of_the_arrow_to_erase_in_the_arrows_list < arrows_nb)
|
if (address_of_the_arrow_to_erase_in_the_arrows_list < arrows_nb)
|
||||||
{
|
{
|
||||||
int mem = arrows_ptr[address_of_the_arrow_to_erase_in_the_arrows_list].site;
|
int mem = arrows_ptr[address_of_the_arrow_to_erase_in_the_arrows_list].site;
|
||||||
|
@ -759,21 +765,17 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb, int spac
|
||||||
|
|
||||||
void main_test_graphics (void)
|
void main_test_graphics (void)
|
||||||
{
|
{
|
||||||
srand(time(NULL)); int rand(void); void srand(unsigned int seed); int arbitrary = 4, randomize = 0, console = 0;
|
srand(time(NULL)); int rand(void); void srand(unsigned int seed);
|
||||||
int arrows_nb = 0, space_X = 1, space_Y = 1, space_Z = 1, density_max = space_X * space_Y * space_Z;
|
int arbitrary = 3, randomize = 1, console = 0;
|
||||||
if (randomize) {space_X = 1 + rand() % arbitrary; space_Y = 1 + rand() % arbitrary; space_Z = 1 + rand() % arbitrary;}
|
int arrows_nb = 0, space_X = 1, space_Y = 1, space_Z = 1;
|
||||||
|
if (randomize) {
|
||||||
|
space_X = 1 + rand() % arbitrary;
|
||||||
|
space_Y = 1 + rand() % arbitrary;
|
||||||
|
space_Z = 1 + rand() % arbitrary;
|
||||||
|
}
|
||||||
|
int density_max = space_X * space_Y * space_Z, specified_arrows_nb = rand() % density_max;
|
||||||
|
printf("density_max = %d; specified_arrows_nb = %d\n", density_max, specified_arrows_nb);
|
||||||
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
||||||
/* int load = 0, site = 0, x = 0, y = 0, z = 0, specif_arrows_nb = rand() % density_max / 2; */
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* I N I T I A L D A T A A R E N O W A L L S P E C I F I E D */
|
|
||||||
|
|
||||||
/* A N D C A N B E D R A W N */
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
/* S P A C E */
|
/* S P A C E */
|
||||||
|
|
||||||
|
@ -787,10 +789,7 @@ void main_test_graphics (void)
|
||||||
|
|
||||||
/* A R R O W S */
|
/* A R R O W S */
|
||||||
|
|
||||||
if (1) for (int i = 0; i < 6; i++)
|
if (1) for (int i = 0; i < specified_arrows_nb; i++)
|
||||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
|
||||||
1, i % 6, 0, 0, 0, console);
|
|
||||||
if (0) for (int i = 0; i < rand() % density_max; i++)
|
|
||||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
||||||
1, // load
|
1, // load
|
||||||
rand() % 6, // site
|
rand() % 6, // site
|
||||||
|
@ -798,30 +797,18 @@ void main_test_graphics (void)
|
||||||
rand() % space_Y, // y
|
rand() % space_Y, // y
|
||||||
rand() % space_Z, // z
|
rand() % space_Z, // z
|
||||||
console);
|
console);
|
||||||
|
int max_arrows_nb = arrows_nb;
|
||||||
|
|
||||||
if (1) print_user_choices(arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 0);
|
if (1) for (int i = 0; i < specified_arrows_nb * 6; i++)
|
||||||
|
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
||||||
|
0, // load
|
||||||
/*--------------------------------------------------------------------------------*/
|
rand() % 6, // site
|
||||||
|
rand() % space_X, // x
|
||||||
/* N E W D A T A W I L L N O W B E S P E C I F I E D */
|
rand() % space_Y, // y
|
||||||
|
rand() % space_Z, // z
|
||||||
/* A N D T H E N D R A W N E D */
|
console);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
console = 1;
|
|
||||||
|
|
||||||
/* If load == 0 then erase the arrow at this address v */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 0, 0, 0, 0, console); */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 1, 0, 0, 0, console); */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 2, 0, 0, 0, console); */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 3, 0, 0, 0, console); */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 4, 0, 0, 0, console); */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 5, 0, 0, 0, console); */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (1) print_user_choices(arrows_ptr, max_arrows_nb, arrows_nb, space_X, space_Y, space_Z, 1, 0);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue