/*********************************************************** synopsis: walk the linked list of answers checking for our guess. If the guess exists, mark it as found and guessed. if it's the longest word play the foundbig if it has found all of the words play foundall sound otherwise play the got word sound. If the word has already been found, play the duplicate sound. If it cannot be found, play the badword sound inputs: answer - the string that we're checking head - pointer to the linked list of answers outputs: n/a ***********************************************************/ static void checkGuess(char* answer, struct node* head) { /* check the guess against the answers */ struct node* current = head; int i, len; int foundWord = 0; char test[8]; memset(test, 0, sizeof(test)); len = nextBlank(answer) - 1; if (len == -1) len = sizeof(test); for (i = 0; i < len; i++) { assert(i < sizeof(test)); test[i] = answer[i]; } #ifdef DEBUG Debug("check guess len:%d answer:'%s' test:'%s'", len, answer, test); #endif while (current != NULL) { if (!strcmp(current->anagram, test)) { foundWord = 1; if (!current->found) { score += current->length; totalScore += current->length; answersGot++; if (len-1 == bigWordLen) { gotBigWord = 1; Mix_PlayChannel(-1, getSound("foundbig"), 0); } else { /* just a normal word */ Mix_PlayChannel(-1, getSound("found"),0); } if (answersSought == answersGot) { Mix_PlayChannel(-1, getSound("foundall"),0); /* getting all answers gives us the game score again!!*/ totalScore += score; winGame = 1; } current->found = 1; current->guessed = 1; updateTheScore = 1; } else { foundDuplicate = 1; Mix_PlayChannel(-1, getSound("duplicate"),0); } updateAnswers = 1; break; } current = current->next; } if (!foundWord) { Mix_PlayChannel(-1, getSound("badword"),0); } }
void Sudoku::solve() { int i, result = 0; int test = nextBlank(-1); if(initial_check()==false) test=sudokuSize; else if(test==sudokuSize){ result = 1; for(i=0; i<sudokuSize; ++i) ans[i] = map[i]; } while(test>=0 && test<sudokuSize && result<2){ map[test]++; if(map[test]>9){ map[test] = 0; test = pop(); } else{ if(check(test)==true){ blankNum[fillPoint++] = test; test=nextBlank(test); if(test==sudokuSize){ result++; for(i=0; i<sudokuSize; ++i) ans[i] = map[i]; test = pop(); } } } } if(result==1){ cout << "1" << endl; printOut(true); } else if(result>1) cout << "2"; else cout << "0"; }