Library tutorials & articles
AI 1 - Problem Solving (Artificial intelligence)
- Introduction
- Methods Theory
- Coding
- Linked List
- Main Loop
- Final bit of code
- Conclusion
Final bit of code
OKAY, the main cpp file, “EightPuzz.cpp”
Here’s the code that kicks the thing off ! Its very simple. #include"Eightpuzz.h"
int main() {
char Choice=0;
cout << "Choose Search Method...\n"
<< " [1] Blind Breadth First
Search\n"
<< " [2] Blind Depth First Search\n"
<< " [3] A*(Tiles in the wrong
position)\n"
<< " [4] A*(Manhattan Distance)\n"
<< endl;
cin >> Choice;
switch(Choice) {
case '1':
// call Blind Breadth First Search
GeneralSearch(BREADTH_FIRST, NOT_USED);
break;
case '2':
// call Blind Depth First Search
GeneralSearch(DEPTH_FIRST, NOT_USED);
break;
case '3':
// call A* with wrong tiles heuristic
GeneralSearch(DEPTH_FIRST, WRONG_TILES);
break;
case '4':
// call A* with manhatten heuristic
GeneralSearch(DEPTH_FIRST, MANHATTAN_DISTANCE);
break;
}
return 0;
}
Related articles
Related discussion
-
Convert C++ code to VB6
by mawcot (4 replies)
-
How to create a games like FIFA08
by mawcot (0 replies)
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
Seeking developers for Montreal Office
by mazen_kt (1 replies)
-
Is there anyone here willing to be interviewed regarding their career in IT?
by krizs (1 replies)
i need help with an error im recieving.
i have a template linked list class
template <class LT>
class LList
{
private:
class LNode
{
public:
LNode ();
LT data;
LNode * next;
};
public:
LList();
LList( const LList & other);
~LList ();
LList & operator = (const LList & other);
bool operator == (const LList & other);
int Size() const;
friend ostream & operator << <> (ostream & outs, const LList<LT> & L);
bool InsertFirst (const LT & value);
bool InsertLast (const LT & value);
bool DeleteFirst ();
bool DeleteLast ();
private:
LNode * first;
int size;
};
and the friend function is giving me an error:
template <class LT>
ostream & operator << (ostream & outs, const LList<LT> & L)
{
if (L.first == NULL)
return outs;
outs << L.first -> data;
for (LList<LT>::LNode * n = L.first -> next; n != NULL; n = n -> next)
{
outs << ' ' << n -> data;
}
return outs;
}
i get an error at the for loop... the error is :
LLIST.tmp: In function
std:<img src="images/smilies/redface.gif" width=15>stream& operator<<(std:<img src="images/smilies/redface.gif" width=15>stream&, const LList<LT>&)': <br> LLIST.tmp:111: error:n' undeclared (first use this function)LLIST.tmp:111: error: (Each undeclared identifier is reported only once for each function it appears in.)
LLIST.tmp:33: error:
LList<int>::LNode*LList<int>::first' is private <br> LLIST.tmp:106: error: within this context <br> LLIST.tmp:33: error:LList<int>::LNode*LList<int>::first' is privateLLIST.tmp:109: error: within this context
application.cpp:19: instantiated from here
LLIST.tmp:33: error:
LList<int>::LNode*LList<int>::first' is private <br> LLIST.tmp:111: error: within this context <br> LLIST.tmp:111: error: dependent-nameLList<LT>::LNode' is parsed as a non-type, but instantiation yields a typeLLIST.tmp:111: note: say `typename LList<LT>::LNode' if a type is meant
i know these all have to do with friend and being private, what do i do?!?!
This thread is for discussions of AI 1 - Problem Solving (Artificial intelligence).