void loadInputPlugin(InputPlugin * inputPlugin) { if(!inputPlugin) return; if(!inputPlugin->name) return; if(inputPlugin->initFunc && inputPlugin->initFunc() < 0) return; insertInList(inputPlugin_list, inputPlugin->name, (void *)inputPlugin); }
void addCommand(char * name, unsigned int reqPermission, int minargs, int maxargs, CommandHandlerFunction handler_func, CommandListHandlerFunction listHandler_func) { CommandEntry * cmd = newCommandEntry(); cmd->cmd = name; cmd->min = minargs; cmd->max = maxargs; cmd->handler = handler_func; cmd->listHandler = listHandler_func; cmd->reqPermission = reqPermission; insertInList(commandList, cmd->cmd, cmd); }
int MutExploratorSeq::isInTheMutationClass(Quiver test, Quiver depart) { int stop=0; int infinite=0; if(resume == 0) { index = 1; modeComparaison = 1; if(test.getN() != depart.getN()) { throw Exception("Les deux quiver n'ont pas le meme nombre de vertexs !"); } c.push_back(test); insertInList(&depart); } else { std::cout << "Resuming at pos: " << index << "\n"; std::cout << "Nb Quivers in queue: " << c.size() << "\n"; if(index == c.size()) { return c.size()-1; } } while(!stop) { while(!stop) { if(c[index].infinite()) { stop=1; infinite=1; throw Exception("The mutation class is infinite"); } generateMutations(c[index]); index++; if(index % 5000 == 0) checkpoint(); if(index == c.size()) stop = 1; } stop = 1; } return c.size()-1; }
int main(int argc, char *argv[]) { struct ListNode* HEAD = NULL; displayList(HEAD); insertInList(&HEAD, 100, 1); insertInList(&HEAD, 200, 2); insertInList(&HEAD, 300, 3); insertInList(&HEAD, 400, 4); insertInList(&HEAD, 350, 3); insertInList(&HEAD, 500, 5); displayList(HEAD); reverseInPair(&HEAD); printf("\n"); displayList(HEAD); return 0; }
void CartBlock::insertInDonorList(int senderid,int index,int meshtagdonor,int remoteid,double cellRes) { DONORLIST *temp1; int ijklmn[6]; int pointid; temp1=(DONORLIST *)malloc(sizeof(DONORLIST)); amr_index_to_ijklmn(pdegree,dims[0],dims[1],dims[2],nf,qstride,index,ijklmn); //pointid=ijklmn[5]*(pdegree+1)*(pdegree+1)*d3+ // ijklmn[4]*(pdegree+1)*d3+ // ijklmn[3]*d3+ // ijklmn[2]*d2+ // ijklmn[1]*d1+ // ijklmn[0]; pointid=(ijklmn[2]*d2+ijklmn[1]*d1+ijklmn[0])*p3+ ijklmn[5]*(pdegree+1)*(pdegree+1)+ ijklmn[4]*(pdegree+1)+ijklmn[3]; if (!(pointid >= 0 && pointid < ndof)) { tracei(index); tracei(nf); tracei(pdegree); tracei(dims[0]); tracei(dims[1]); tracei(dims[2]); tracei(qstride); printf("%d %d %d %d %d %d\n",ijklmn[0],ijklmn[1],ijklmn[2], ijklmn[3],ijklmn[4],ijklmn[5]); } assert((pointid >= 0 && pointid < ndof)); temp1->donorData[0]=senderid; temp1->donorData[1]=meshtagdonor; temp1->donorData[2]=remoteid; temp1->donorRes=cellRes; temp1->cancel=0; insertInList(&(donorList[pointid]),temp1); }
int GreenExplorator::generateMutations(PrincipalExtension &pe) { int i; int ret; int sommet; int create=0; unsigned int size; std::string mutations_str=""; std::string filename = ""; std::vector<int> mutations_v; std::stringstream ss (std::stringstream::in | std::stringstream::out); PrincipalExtension p = pe; strhash::iterator iit; std::map<uint64_t,mpz_class>::iterator mult_it; std::map<uint64_t,mpz_class> *mult; #ifdef DEBUG std::cout << "Travail avec "; pe.printMutationsE(0); #endif sommet = pe.getNextSommetVert(); if(sommet == -1) { return 1; } if(sommet==p.lastMutation()) { // No need to mutate twice on the same vertex return 1; } if(p.getMutationsSize() >= this->max_depth) { return 4; } ret = p.mutate(sommet, this->p); if (ret == 0) { // if mutate returned 0, then infinity was detected return 3; } if (ret == 1) { // a Green quiver was detected ! size = p.getMutationsSize(); mult = p.getMultiplicityMap(); for(mult_it = mult->begin(); mult_it!=mult->end(); mult_it++) { sizes[mult_it->first] += mult_it->second; } if (isomorphTest) { mutations_v = p.getMutations(); gsh.increment(mutations_v,size); } if(size > maxLength) { maxLength = size; std::cerr << "M:"; p.printMutationsE(1); std::cerr << "Q:"; p.printMutationsE(0); } if(size < minLength) { minLength = size; std::cerr << "m:"; p.printMutationsE(1); std::cerr << "Q:"; p.printMutationsE(0); } numGreen+=1; if((numGreen % 1000000) == 0) { std::cerr << "S (" << numGreen << "):"; p.printMutationsE(0); } if(isomorphTest) {insertInList(p,cemetary);} return 0; } if (isomorphTest) { return insertInList(p); } else { c.push_back(p); return 2; } #ifdef DEBUG std::cout << "Fin du travail avec "; p.printMutations(0); #endif }
void GreenExplorator::greenExploration(PrincipalExtension pe) { int index = 0; int ret; std::map<uint64_t,mpz_class>::iterator it; mpz_class total=0; std::list<PrincipalExtension>::iterator pei; std::stringstream ss (std::stringstream::in | std::stringstream::out); std::string filename; uint64_t cutPending = 0; // Initial population of the list insertInList(pe); pei = c.begin(); while(generateMutations(*pei) != 1) {pei=c.begin();}; if (isomorphTest) { insertInList(*pei,cemetary); } c.erase(pei); pei = c.begin(); for(index=c.size();index>=1;index--) { while(generateMutations(*pei) != 1) {pei=c.begin();}; if (isomorphTest) { insertInList(*pei,cemetary); } c.erase(pei); pei = c.begin(); } pei=c.end();pei--; // Main loop while(c.size()!=0) { #ifdef DEBUG std::cout << "C.size: " << c.size() << " Cem.size: " << cemetary.size() << "\t\t"; std::cout << "Travail avec "; (*pei).printMutations(0); (*pei).affiche(); #endif ret = generateMutations(*pei); switch(ret) { case 4: // Branch cut case 3: // Infinity detected on the branch // Cut the branch ! if(dumpTruncated) { ss.clear(); if(ret == 3) { ss << "DInf_" << infCut << ".quiv"; } if(ret == 4) { ss << "DTrunc_" << depthCut << ".quiv"; } ss >> filename; (*pei).toFile(filename.c_str()); } if(ret == 3) { infCut++; } if(ret == 4) { this->truncated = 1; depthCut ++; } if(isomorphTest) { if(((*pei).getMultiplicityMap())->size() > 0) { cutPending++; } } case 1: if (isomorphTest) { insertInList(*pei,cemetary); } c.erase(pei); case 2: pei=c.end();pei--; break; // Nothing to be done for case 0 // a green quiver was detected // and the list is not empty... some //mutations remains to be explored ! } } // Print results for ( it=sizes.begin() ; it != sizes.end(); it++ ) { std::cout << (*it).first << "\t=>\t" << (*it).second << std::endl; total +=(*it).second; } std::cout << "Total: " << total << std::endl; if(this->truncated == 1) { std::cout << "Exploration Truncated at depth: " << max_depth << std::endl; } if(this->infCut > 0) { std::cout << "Num branches cut because of excessive Mul: " << infCut << std::endl; } if(this->depthCut > 0) { std::cout << "Num branches cut because of excessive depth: " << depthCut << std::endl; } if(cutPending > 0) { std::cout << "WARNING: "<< cutPending << " branches were cut with pending isomorphs." << std::endl; std::cout << "All max green suite < "<< max_depth << " may not have been found." << std::endl; } }
/************************************************************************************************ joinCommand() Arguments: myUser - struct with 'my' information saAddr - IP address of SA saPort - port of SA Description: In this function, the join command is handled. Fisrt a new user must send the REG message to SA. SA answers with a DNS message. Case the SNP is myself, the join is done. In case the SNP is other user, then the user must join the rest of the family, starting to sent the REG message to the SNP, receiving the LST message from the SNP and then, send the REG message to every member of the family and wait for their OK. *************************************************************************************************/ int joinCommand(user myUser, char * saAddr, int saPort){ /*struct hostent *h;*/ struct in_addr a; struct sockaddr_in addr; user * dnsUser; int joinSocket; int retval, outSize; int bcast = 1, i,n; socklen_t addrlen; char * output; char outputLarge[1024]; char toParse[1024]; char inbuffer[256]; char userBuff[50]; char answer[4]; struct timeval timeout; timeout.tv_sec = 10; timeout.tv_usec = 0; /*Creates udp Socket to communicate with SA*/ saSocket = socket(AF_INET, SOCK_DGRAM,0); if (setsockopt (saSocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)) < 0) perror("\n>setsockopt failed\n"); dnsUser = (user*) malloc(sizeof(user)); if(dnsUser == NULL){ fprintf(stderr, "Malloc Error on dnsUser"); return -1; } memset((void*)inbuffer, 0, 256); memset((void*)outputLarge, '\0', 1024); inet_pton(AF_INET, saAddr, (void*) &a); memset((void*)&addr, (int)'\0', sizeof(addr)); addr.sin_family=AF_INET; addr.sin_port=htons(saPort); addr.sin_addr = a; outSize = strlen(myUser.contact)*sizeof(char) + sizeof("REG ") -1 + 2; /* -1 porque ele conta com o \0 no size do REG*/ output = (char*) malloc(outSize); /* Create output string */ snprintf(output, outSize, "%s %s", "REG", myUser.contact); /*Sends Register message to SA server*/ retval = sendto(saSocket, output, strlen(output)*sizeof(char), 0, (struct sockaddr*)&addr, sizeof(addr)); if(retval == -1){ perror("\n>Join Error\n"); free(output); return -1; } addrlen = sizeof(addr); /*Retrieves response message from SA server*/ retval = recvfrom(saSocket, inbuffer, 256, 0, (struct sockaddr*)&addr, &addrlen); if(retval == -1){ perror("\n>Join recv Error\n"); free(output); return -1; } inbuffer[retval] = '\0'; retval = sscanf(inbuffer, "%s %[^.].%[^;];%[^;];%d", answer, dnsUser->name, dnsUser->surname, dnsUser->IP, &dnsUser->udpPort); if ((retval != 5) || (strcmp(answer, "DNS") != 0)){ fprintf(stderr, "Error when matching SA's response to register.\n"); free(output); return -1; } myDns = dnsUser; /*If user is authorised dns for username, than completes the user structure with details and then inserts it into surname users list.*/ if (strcmp(dnsUser->name, myUser.name) == 0){ dnsUser->tcpPort = myUser.tcpPort; memset(dnsUser->contact, '\0', 256); strcpy(dnsUser->contact, myUser.contact); initListFromUser(dnsUser); snp = 1; free(output); return 1; } /*If user is not authorized dns then will register with authorized dns and retrive surname users list*/ /*create socket to talk to DNS*/ joinSocket = socket(AF_INET, SOCK_DGRAM, 0); if (setsockopt (joinSocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)) < 0) perror("\n>setsockopt failed\n"); /*Create Addr struct for DNS*/ inet_pton(AF_INET, dnsUser->IP, (void*) &a); /*casts first usable name into in_addr struct form*/ memset((void*)&addr, (int)'\0', sizeof(addr)); addr.sin_family=AF_INET; addr.sin_port=htons(dnsUser->udpPort); addr.sin_addr = a; addrlen = sizeof(addr); retval = sendto(joinSocket, output, strlen(output)*sizeof(char), 0, (struct sockaddr*)&addr, sizeof(addr)); if(retval == -1){ perror("Join recv Error\n"); close(joinSocket); free(output); return -1; } retval = recvfrom(joinSocket, outputLarge, 1024, 0, (struct sockaddr*)&addr, &addrlen); if(retval == -1){ perror("Join recv Error\n"); close(joinSocket); free(output); return -1; } retval = sscanf(outputLarge, "%[^\n]\n%[^ ]", answer, toParse); if(retval != 2){ fprintf(stderr, "Could not Parse LST from SNP\n"); close(joinSocket); free(output); return -1; } answer[3] = '\0'; if(strcmp(answer, "LST") == 0){ bcast = 1; while(bcast){ n=-1; for(i = 0; i < 1023; i++){ n++; if(toParse[i] == '\n'){ insertInList(userBuff); memset(userBuff,'\0', 50); n=-1; if(toParse[i+1] == '\n'){ bcast = 0; toParse[i+1] = '\0'; break; }else{ continue; } } userBuff[n%50] = toParse[i]; } if(bcast){ retval = recvfrom(joinSocket, outputLarge, 1024, 0, (struct sockaddr*)&addr, &addrlen); if(retval == -1){ perror("\n>Join->LST recv Error\n"); close(joinSocket); free(output); return -1; } retval = sscanf(outputLarge, "%[^ ]\n%[^ ]", answer, toParse); answer[3] = '\0'; if (strcmp(answer, "LST") != 0){ fprintf(stderr, "\n>Bad format in Join->LST. Expected LST\n[RemainderUsers], got \"%s\" instead\n", answer); close(joinSocket); free(output); return -1; } } } retval = BcastMyself(joinSocket, addr); if(retval < 0){ fprintf(stderr, "Error uppon Join->BcastMyself"); free(output); close(joinSocket); return -1; } } free(output); close(joinSocket); return 1; }
int GreenExplorator::generateMutations(IceQuiver &pe) { //int i; int ret; int vertex; //int create=0; unsigned int size; std::string mutations_str=""; std::string filename = ""; std::vector<int> mutations_v; std::stringstream ss (std::stringstream::in | std::stringstream::out); IceQuiver p = pe; strhash::iterator iit; std::map<uint64_t,mpz_class>::iterator mult_it; std::map<uint64_t,mpz_class> *mult; vecivect::iterator vi; #ifdef DEBUG std::cout << "genMut: Working on "; pe.printMutationsE(0); #endif vertex = pe.getNextFiniteGreenVertex(); if(vertex == -1) { return 1;//No more finite green vertex } if(vertex==p.lastMutation()) { // No need to mutate twice on the same vertex return 1; } if(p.getMutationsSize() >= this->max_depth) { return 4;//Cut the sequence } ret = p.mutate(vertex); if (ret == 0) { // if mutate returned 0, then non-BHIT violating infinity was detected return 0; } if (ret == 1) { //A maximal green sequence/tail was detected or infinity was detected! size = p.getMutationsSize(); mult = p.getMultiplicityMap(); printVectors(p.getAdmittedCVectors()); if (!p.getAdmittedCVectors().empty()) { for (vi = p.admittedCVectors.begin(); vi != p.admittedCVectors.end(); vi++) { if (!belongsTo(*vi, admissibleCVectors)) admissibleCVectors.push_back(*vi); } } printVectors(p.getAdmittedGVectors()); if (!p.getAdmittedGVectors().empty()) { for (vi = p.admittedGVectors.begin(); vi != p.admittedGVectors.end(); vi++) { if (!belongsTo(*vi, admissibleGVectors)) admissibleGVectors.push_back(*vi); } } printVectors(p.getAdmittedPVectors()); if (!p.getAdmittedPVectors().empty()) { for (vi = p.admittedPVectors.begin(); vi != p.admittedPVectors.end(); vi++) { if (!belongsTo(*vi, admissiblePVectors)) admissiblePVectors.push_back(*vi); } } #ifdef DEBUG printVectors(admissibleCVectors); printVectors(admissibleGVectors); printVectors(admissiblePVectors); std::cout << "MGS found!" << std::endl; p.printMutationsE(0); #endif for(mult_it = mult->begin(); mult_it!=mult->end(); mult_it++) { mgsInfo[mult_it->first] += mult_it->second; #ifdef DEBUG std::cout << mult_it->first << "," << mult_it->second << std::endl; #endif } if (isomorphTest) { mutations_v = p.getMutations(); gsh.increment(mutations_v,size); } if(size > maxLength) { maxLength = size; // std::cerr << "M:"; //p.printMutationsE(1); //std::cerr << "Q:"; //p.printMutationsE(0); } if(size < minLength) { minLength = size; //std::cerr << "m:"; //p.printMutationsE(1); //std::cerr << "Q:"; //p.printMutationsE(0); } numGreen+=1; if((numGreen % 100000) == 0) { //#ifdef DEBUG std::cerr << "S (" << numGreen << "):"; p.printMutationsE(0); //#endif } if(isomorphTest) {insertInCemetary(p,cemetary);} return 0; } if (isomorphTest) { return insertInList(p); } else { c.push_back(p); return 2; } /*#ifdef DEBUG std::cout << "Fin du travail avec "; p.printMutations(0); #endif*/ }
int GreenExplorator::greenExploration(IceQuiver pe) { int index = 0; int ret; int max; std::map<uint64_t,mpz_class>::iterator it; mpz_class total=0; std::list<IceQuiver>::iterator pei; std::list<IceQuiver>::iterator peitest; std::stringstream ss (std::stringstream::in | std::stringstream::out); std::string filename; vecivect::iterator vsi; std::vector<mpz_class>::iterator veci; uint64_t cutPending = 0; // Initial population of the list insertInList(pe); if (pe.getN() == 2) {//When n=1 std::cout << 1 << "\t=>\t" << 1 << std::endl; std::cout << "Total: " << 1 << std::endl; return 1; } pei = c.begin(); //#ifdef DEBUG // for(peitest = c.begin();peitest != c.end();peitest++) { // fprintf(stderr, "Now printing all mutation sequences in the list c.\n"); // peitest->printMutationsE(0); //} //#endif while(generateMutations(*pei) != 1){ //The purpose of this loop is to completely exhaust all initial green sequences starting from a quiver //Then it can be removed from the list of to-be-determined quivers. #ifdef DEBUG fprintf(stderr, "Now pei points to "); pei->printMutationsE(0); #endif pei=c.begin(); #ifdef DEBUG fprintf(stderr, "Now printing all mutation sequences in the list c.\n"); for(peitest = c.begin();peitest != c.end();peitest++) { peitest->printMutationsE(0); } #endif }; //#ifdef DEBUG // fprintf(stderr, "Now this weird process is finally over.\nNow pei points to "); //pei->printMutationsE(0); //fprintf(stderr, "Now printing all mutation sequences in the list c.\n"); //for(peitest = c.begin();peitest != c.end();peitest++) { // peitest->printMutationsE(0); //} //#endif if (isomorphTest) { insertInCemetary(*pei,cemetary); } c.erase(pei); pei = c.begin(); for(index=c.size();index>=1;index--) { while(generateMutations(*pei) != 1){ pei=c.begin(); //#ifdef DEBUG // fprintf(stderr, "Now pei points to "); // pei->printMutationsE(0); // fprintf(stderr, "Now printing all mutation sequences in the list c.\n"); // for(peitest = c.begin();peitest != c.end();peitest++) { // peitest->printMutationsE(0); // } //#endif }; if (isomorphTest) { insertInCemetary(*pei,cemetary); } c.erase(pei); pei = c.begin(); //#ifdef DEBUG // fprintf(stderr, "Now pei points to "); // pei->printMutationsE(0); // fprintf(stderr, "Now printing all mutation sequences in the list c.\n"); //for(peitest = c.begin();peitest != c.end();peitest++) { // peitest->printMutationsE(0); // } //#endif } pei=c.end(); pei--; // Main loop while(c.size()!=0) { #ifdef DEBUG std::cout << "C.size: " << c.size() << " Cemetary.size: " << cemetary.size() << "\t\t"; std::cout << "Working on "; (*pei).printMutations(0); (*pei).print(); #endif ret = generateMutations(*pei); switch(ret) { case 4: // Branch cut case 3: // Infinity detected on the branch // Cut the branch ! if(dumpTruncated) { ss.clear(); if(ret == 3) { ss << "DInf_" << infCut << ".quiv"; } if(ret == 4) { ss << "DTrunc_" << depthCut << ".quiv"; } ss >> filename; (*pei).toFile(filename.c_str()); } if(ret == 3) { infCut++; } if(ret == 4) { this->truncated = 1; //std::cout << "Cut sequence: " << std::endl; //pei->printMutationsE(0); depthCut ++; } if(isomorphTest) { if(((*pei).getMultiplicityMap())->size() > 0) { cutPending++; } } case 1: if (isomorphTest) { insertInCemetary(*pei,cemetary); } c.erase(pei); case 2: pei=c.end();pei--; break; // Nothing to be done for case 0 // a green quiver was detected // and the list is not empty... some //mutations remains to be explored ! } } // Print results for ( it=mgsInfo.begin() ; it != mgsInfo.end(); it++ ) { std::cout << (*it).first << "\t=>\t" << (*it).second << std::endl; total +=(*it).second; } std::cout << "Total: " << total << std::endl; if(this->truncated == 1) { std::cout << "Exploration Truncated at depth: " << max_depth << std::endl; } if(this->infCut > 0) { std::cout << "Num branches cut because of BHIT violations: " << infCut << std::endl; } if(this->depthCut > 0) { std::cout << "Num branches cut because of excessive depth: " << depthCut << std::endl; } if(cutPending > 0) { std::cout << "WARNING: "<< cutPending << " branches were cut with pending isomorphs." << std::endl; std::cout << "All max green sequences < "<< max_depth << " may not have been found." << std::endl; } //Print admissible c-vectors std::cout << "Final CVec list:" << std::endl; printVectors(admissibleCVectors); //vecProcs(pe, admissibleCVectors); std::cout << "Final GVec list:" << std::endl; printVectors(admissibleGVectors); std::cout << "Final PVec list:" << std::endl; printVectors(admissiblePVectors); std::cout << "CProc" << std::endl; pe.vecProcs(admissibleCVectors); std::cout << "PProc" << std::endl; pe.vecProcs(admissiblePVectors); if(total) return mgsInfo.rbegin()->first; else return 0; }
int lsPlaylists(FILE * fp, char * utf8path) { DIR * dir; struct stat st; struct dirent * ent; char * dup; char * utf8; char s[MAXPATHLEN+1]; List * list = NULL; ListNode * node = NULL; char * path = strdup(utf8ToFsCharset(utf8path)); char * actualPath = rpp2app(path); int actlen = strlen(actualPath)+1; int maxlen = MAXPATHLEN-actlen; int suflen = strlen(PLAYLIST_FILE_SUFFIX)+1; int suff; if(actlen>MAXPATHLEN-1 || (dir = opendir(actualPath))==NULL) { free(path); return 0; } s[MAXPATHLEN] = '\0'; /* this is safe, notice actlen > MAXPATHLEN-1 above */ strcpy(s,actualPath); strcat(s,"/"); while((ent = readdir(dir))) { dup = ent->d_name; if(dup[0]!='.' && (suff=strlen(dup)-suflen)>0 && dup[suff]=='.' && strcmp(dup+suff+1,PLAYLIST_FILE_SUFFIX)==0) { strncpy(s+actlen,ent->d_name,maxlen); if(stat(s,&st)==0) { if(S_ISREG(st.st_mode)) { if(list==NULL) list = makeList(NULL, 1); dup = strdup(ent->d_name); dup[suff] = '\0'; if((utf8 = fsCharsetToUtf8(dup))) { insertInList(list,utf8,NULL); } free(dup); } } } } closedir(dir); free(path); if(list) { int i; sortList(list); dup = malloc(strlen(utf8path)+2); strcpy(dup,utf8path); for(i = strlen(dup)-1; i >= 0 && dup[i]=='/'; i--) { dup[i] = '\0'; } if(strlen(dup)) strcat(dup,"/"); node = list->firstNode; while(node!=NULL) { if(!strchr(node->key, '\n')) { myfprintf(fp,"playlist: %s%s\n",dup,node->key); } node = node->nextNode; } freeList(list); free(dup); } return 0; }
/* Calls relevant functions to play the game and allows user to guess letter after letter * and checks if the user has won or lost after each guess.*/ void userLoop(){ createLists(); // This reads the dictionary and generates an array of all lists of all word lengths char guess; // This is the variable where the current letter being guessed is kept int next=0; // Prevents duplication of code on first pass. int won=0; // Keeps track of whether the game has been won or lost int hard= difficulty(); //User chosen difficulty level int numberOfLetter=numberOfLetters(); //number of wrong guesses left before game is over int guessNumber=numberOfGuesses(); printf("To play, type in a single letter as a guess.\n"); printf("You have %i guesses remaining.\n", guessNumber); // game plays while the user still has some guesses left and has not won guess = obtainGuess(); //Gets first guess from user insertInList(&head, guess );//Puts guessed letter in list of guessed letters //All word families of user defined length are created generateDescriptions(&lists[numberOfLetter],numberOfLetter,guess); currentStatus(); // The status of game is shown to the user getNewList(hard); /*Finds the biggest members list from current *families and makes it the new main list of possible words*/ //This is the loop that allows the game to proceed. The first part of the loop is similar to above. while ((guessNumber)>0 && won==0) { if (next==1) {// prevents and initial duplication printf("You have %i guesses remaining.", guessNumber); // prints the status of the uncovered letters guess = obtainGuess(); //Gets first guess from user insertInList(&head, guess ); //Adds the guessed letter to the list containing all guessed letters currentFamily=NULL; //Resets list of current families //All word families of user defined length are created generateDescriptions(¤tWordList,numberOfLetter,guess); //All word families of user defined length are created /*Finds the biggest members list from current *families and makes it the new main list*/ getNewList(hard); currentStatus(); } // Allows the first part of the loop to be run on all subsequent guesses. next=1; // Lets the use know if they uncovered a letter. if (checkIfFound(guess,numberOfLetter)) { printf("\n \n \n Wrong!\n"); } else { printf("\n \n \n Correct.\n"); } // The number of guesses remaining decreases after each guess guessNumber--; // Checks to see if the user has uncovered all letters if (checkWin(numberOfLetter)) { printf("You Win!!"); won=1; } } printf("Game over. You uncovered:"); //Shows final game state currentStatus(); //Shows user a word that fits the currently visible letter pattern. printf("The word was: %s\n",currentFamily->members->word); }