I've gotten handed this assignment to do but I'm not sure how to do it. The purpose is to make a Best-First search algorithm in the provided space under Main.c. I've copied the code under this, and if...

1 answer below »

I've gotten handed this assignment to do but I'm not sure how to do it. The purpose is to make a Best-First search algorithm in the provided space under Main.c.

I've copied the code under this, and if there's anything else needed to help do let me know please.








THIS FALLS UNDER main.c
=====================









/*

* File: main.cpp

* Author: j4-smith

*N-Queens example in C

* First Created on 25 April 2014, 18:42

* Modified in light of student progress


* Rewritten Oct 2015 to use more generic solution structures

* and functions with Password-specific names that call the functions that modify the

*/









#include

#include

#include "StructureDefinitions.h"

#include "SolutionListOperations.h"

#include "PasswordChecker.h"





#pragma warning(disable:4996)





typedef int bool;

#define true 1

#define false 0





//Variables workingCandidate, openList, closedList

candidateSolution workingCandidate;// this one will hold the soltion we arecurrently considering

candidateList openList; // this list will store all the soltion we;ve created but not examined yet

candidateList closedList; // this is where we will store all the ones we're done with





char validChars[NUM_VALID_CHARACTERS] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};





//************************ don't edit anything above this line***********************//













int main(int argc, const char * argv[])

{




/* the next set of variables get used within our main function


* but aren't declared globally becuase we don't want the other functions to change them inadvertently *///


int indexOfSolutionWeAreLookingAt=0; //index in list of current solution being examined


bool goalReached = false; // used to indicate when to stop searching for new candidates


int bestval=0, bestindex=0; //used to find best thing in openList


char oldval;


oldval = '0';


indexOfSolutionWeAreLookingAt = bestindex=bestval=0;


//start off by emptying the lists of candidate solutions


CleanListsOfSolutionsToStart();


CleanWorkingCandidate();






SetNewChallenge();




/* So now let's start by creating our first solution


* which we do by filling the values into the variable we declared as the workingCandidate


* We'll begin by putting in the string aaaaaaaa


*/


for (int pos=0; pos

THIS FALLS UNDER PasswordChecker.c

===================================







/* file Passwordchecker.c

*

* Author Jim Smith 16-10-14

*/













#include "PasswordChecker.h"

#include "PasswordDefinitions.h"

#include





int numberOfCallsMade =0;









char challenge[N];





void SetNewChallenge()

{


int position, randindex;


extern char validChars[NUM_VALID_CHARACTERS];


srand((unsigned int)time(NULL));


for(position=0;position < n;="">


{


randindex = rand() % NUM_VALID_CHARACTERS;


challenge[position] = validChars[randindex];


}




printf("Challenge is:\t %s\n",challenge );

}





/*

* void CalculateNumberOfVulnerableQueensForWorkingCandidate()

* this functions tells us how many vulnerable queens there are in the current working candidate

* no return value as the number is written into the structure that holds our candidae solution

*/





void ScoreWorkingCandidate()

{


int position=0,matches=0;





extern candidateSolution workingCandidate;


#ifdef ONDEWIS


extern void markingChecks1(void);


markingChecks1();

#endif






for (position=0;position


Answered Same DayAug 20, 2022

Answer To: I've gotten handed this assignment to do but I'm not sure how to do it. The purpose is to make a...

Aditi answered on Aug 21 2022
80 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here