Library tutorials & articles
AI 1 - Problem Solving (Artificial intelligence)
Introduction
Hello. I’m writing this tutorial shortly after finishing a module in AI at university. I’m basically gonna show u all the interesting bits I learned, I’m sure none of you have any interest in hearing the long debate about what intelligence actually is.
Before reading on, I would recommend that you make sure you are comfortable using the following…
- Pointers to object, functions, and classes
- Classes
- Linked Lists.
- Creating objects using the ‘new’ keyword.
After you read through this, I would recommend you download the Zip that comes with the tutorial, as copying and pasting code almost never works with programs this large. In this tutorial, I’m going to use the single player game “eight puzzle” as an example. The rules of this game are as follows.
There is a 3 by 3 grid containing numbers 1 to 8 (with 1 blank square). Initially the numbers are arranged in no particular order. e.g.
| 6 | 1 | 7 |
| 3 | 4 | |
| 5 | 8 | 2 |
The player can move the blank 1 space in the directions North, East South, or West. On moving the blank, the space that the blank moves into moves into the blanks old position. e.g. moving the blank north would result in the game state looking like this.
| 6 | 1 | |
| 3 | 4 | 7 |
| 5 | 8 | 2 |
The game is complete when the numbers are in the following arrangement.
| 1 | 2 | 3 |
| 8 | 4 | |
| 7 | 6 | 5 |
This concludes the introduction. On the next page I will get into the different ways in which this problem can be solved, and each methods advantage, and dissadvantage.
Related articles
Related discussion
-
conting repeated words
by Slicksim (2 replies)
-
Can somebody help: CAsyncSOcket class (Client-server networking)
by Mohammad Rastkar (3 replies)
-
custom progress bar in a datagridview with threading
by konikula (1 replies)
-
Calling C++ DLL from C#
by Thushan Fernando (1 replies)
Events coming up
-
Dec
6
Developing AJAX Web Applications with Castle Monorail
London, United Kingdom
Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!
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).