Library tutorials & articles
AI 1 - Problem Solving (Artificial intelligence)
By Chris Stones, published on 09 May 2003
Conclusion
As I said earlier, I would recommend you read through the source code in this tutorial, then download the zip file, open it with Visual c++, and see the thing in action.
Because of the size of the example program, I'm guessing that you havent followed it 100%. And it looks much much more complicated that it atually is.
To code your own ai program all you need is:
- A method of storeing States
- A method for expanding states
- A way of tracing back to the initial state
- A way of sorting the states
- A function for scoreing a state.
- And a main loop that removes 1 state from a list, and puts its children onto the list.
Each of the above very easy for a comfortable c++ programmer. The difficult part is putting it all together and making it readable and understandable to others!
Related articles
Related discussion
-
VS2005 app's won't run on another machine
by ted4444 (0 replies)
-
VB.NET: Hide and show table using radio buttons
by converter2009 (1 replies)
-
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)
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).