summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
63a7db7)
Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
{
return random() % count;
}
{
return random() % count;
}
int random_code(int ref)
{
int nb = 6 - count_set_bits(ref);
int random_code(int ref)
{
int nb = 6 - count_set_bits(ref);
int iter = 1;
int result = 0;
while (nb) {
int iter = 1;
int result = 0;
while (nb) {
int i;
result = check_ptr(calloc(count, sizeof(struct label)));
for (i = 0; i < count; i++) {
int i;
result = check_ptr(calloc(count, sizeof(struct label)));
for (i = 0; i < count; i++) {
- int len = lenmin + (lenmin == lenmax ? 0 : r(lenmax-lenmin));
+ int len = lenmin + (lenmin == lenmax ? 0 : alea(lenmax-lenmin));
result[i].label = check_ptr(calloc(1+len, 1));
while (len)
result[i].label = check_ptr(calloc(1+len, 1));
while (len)
- result[i].label[--len] = 'A' + (char)(r(26));
+ result[i].label[--len] = 'A' + (char)(alea(26));
result[i].rules = check_ptr(calloc(count, sizeof(char)));
}
result[i].rules = check_ptr(calloc(count, sizeof(char)));
}
for (i = 0; i < count; i++) {
int allow = random_code(0);
int len = code_to_string(allow, buffer);
for (i = 0; i < count; i++) {
int allow = random_code(0);
int len = code_to_string(allow, buffer);
buffer[len++] = ' ';
len += code_to_string(random_code(allow), buffer + len);
}
buffer[len++] = ' ';
len += code_to_string(random_code(allow), buffer + len);
}
int pick_subj_label(struct label *labels, int nlab, int max_reoccurance)
{
int pick_subj_label(struct label *labels, int nlab, int max_reoccurance)
{
- int startidx = r(nlab);
+ int startidx = alea(nlab);
int repeat = 0;
int idx = startidx;
while (labels[idx].counter >= max_reoccurance) {
int repeat = 0;
int idx = startidx;
while (labels[idx].counter >= max_reoccurance) {
int pick_obj_label(struct label *labels, int nlab, int max_reoccurance, int *subj)
{
int pick_obj_label(struct label *labels, int nlab, int max_reoccurance, int *subj)
{
- int startidx = r(nlab);
+ int startidx = alea(nlab);
int repeat = 0;
int repeat_subj = 0;
int idx = startidx;
int repeat = 0;
int repeat_subj = 0;
int idx = startidx;
int obj = pick_obj_label(labels, lab_cnt, lab_max, &sub);
int i;
for (i = 0; i <= mer_cnt; i++)
int obj = pick_obj_label(labels, lab_cnt, lab_max, &sub);
int i;
for (i = 0; i <= mer_cnt; i++)
- printf("%s %s %s\n", labels[sub].label, labels[obj].label, rights[r(rig_cnt)]);
+ printf("%s %s %s\n", labels[sub].label, labels[obj].label, rights[alea(rig_cnt)]);