/* ** Name: record_play_or_record ** Desc: */ void record_play_or_record(record_t *record, char *filename) { record_play(record, filename); if (!record->file) { record_start(record, filename); } }
/** * The goOn function from Gordon's paper. * @param pos The position relative to the current anchor square. * @param L A letter from 'A' to 'Z'. * @param word A possible word being built. * @param rack An integer describing the rack. * @param NewArc The next arc based on the L parameter. * @param OldArc The old arc. */ void go_on(int pos, char L, char* word, uint8_t* rack, ARC* NewArc, ARC* OldArc, int spaces) { #ifdef DEBUG_ print_spaces(spaces); printf("in go_on, %d, Letter: %c, Word: %s,", pos, L, word); print_rack(rack); #endif char word_c[16]; char word_copy[16]; word_c[0] = L; word_c[1] = '\0'; if (pos <= 0) { // word <- L || word #ifdef DEBUG_ print_spaces(spaces); printf("pos <= 0, here\n"); #endif strcat(word_c, word); // word_c now prepends word with L. Can I do this faster? // IF L on oldArc & no letter directly left then RecordPlay if (containsLetter(OldArc->destination, L)) { // TODO - check if no letter directly left, this is also a // required condition. #ifdef DEBUG_ print_spaces(spaces); printf("containsLetter(OldArc->destination, %c)\n", L); #endif record_play(word_c); } if (NewArc) { #ifdef DEBUG_ print_spaces(spaces); printf("New arc\n"); #endif // If there is room to the left, Gen(pos-1, word, rack, NewArc) // TODO, check if there is room to the left. if (1) { gen(pos - 1, word_c, rack, NewArc, spaces + 1); } NewArc = next_arc(NewArc, SEPARATION_TOKEN); // Now shift direction. if (NewArc) { #ifdef DEBUG_ print_spaces(spaces); printf("Switched direction\n"); #endif // TODO check if there is no letter directly left, AND // there is room to the right. if (1) { gen(1, word_c, rack, NewArc, spaces + 1); } } } } else if (pos > 0) { #ifdef DEBUG_ print_spaces(spaces); printf("pos > 0\n"); #endif strcpy(word_copy, word); strcat(word_copy, word_c); if (containsLetter(OldArc->destination, L)) { #ifdef DEBUG_ print_spaces(spaces); printf("containsLetter(OldArc->destination, %c)\n", L); #endif // TODO check if no letter directly right. if (1) { record_play(word_copy); } } if (NewArc) { #ifdef DEBUG_ print_spaces(spaces); printf("NewArc\n"); #endif // TODO check if room to the right. if (1) { gen(pos + 1, word_copy, rack, NewArc, spaces + 1); } } } }