Library tutorials & articles

AI 1 - Problem Solving (Artificial intelligence)

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!

Comments

  1. 27 Jul 2005 at 20:11

    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&lt;&lt;(std:<img src="images/smilies/redface.gif" width=15>stream&, const LList&lt;LT&gt;&)': <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&lt;int&gt;::LNode*LList&lt;int&gt;::first' is private <br> LLIST.tmp:106: error: within this context <br> LLIST.tmp:33: error: LList<int>::LNode*LList<int>::first' is private
    LLIST.tmp:109: error: within this context
    application.cpp:19:   instantiated from here
    LLIST.tmp:33: error: LList&lt;int&gt;::LNode*LList&lt;int&gt;::first' is private <br> LLIST.tmp:111: error: within this context <br> LLIST.tmp:111: error: dependent-name LList<LT>::LNode' is parsed as a non-type, but instantiation yields a type
    LLIST.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?!?!

  2. 01 Jan 1999 at 00:00

    This thread is for discussions of AI 1 - Problem Solving (Artificial intelligence).

Leave a comment

Sign in or Join us (it's free).

AddThis

Related discussion

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!