Example #1
0
        public CD(string str)
        {   // Wei Chen -- old code from str
            string[] words = str.Split(' ');

            if (words.Length != 3)
            {
                head     = (concept)concept.all_concepts["find"];
                PropList = new Hashtable();
                return;
            }

            head = (concept)concept.all_concepts["find_object"];
            if (head == null)
            {
                throw (new System.Exception("New CD: attempt to create from unkown concept: " + str));
            }
            PropList = new Hashtable();

            CD obj = new CD();

            obj.head = (concept)concept.all_concepts[concept.all_nouns[words[2]]];
            obj.PropList.Add(concept.all_modifiers[words[1]], words[1]);
            PropList.Add("object:", obj);
        }
Example #2
0
        public void find_object()
        {
            CD target_CD = (CD)taskArgs.PropList["object:"];

            if (target_CD == null)
            {
                //            myMind.mySynth.SpeakAsync("No target specified");
                return;
            }
            AliveObject target;
            float       conf;
            int         fx, fy; //frontier point coordinates

            Console.WriteLine("Looking for: " + target_CD.ToSexp());
            bool new_objects_flag = true;

            for (int i = 0; i < 10; i++)
            {
                if (new_objects_flag)
                {
                    conf = dogTricks.selectKnowObject(myMind, target_CD, out target);
                    if (conf == 0 || target == null)
                    {
                        Console.WriteLine("Known objects do not match the description");
                    }
                    else
                    {
                        Console.WriteLine(target.name + " matches with conf " + conf.ToString());
                    }
                    if (conf > .3)
                    {
                        Console.WriteLine(target.name + " is the best target with conf " + conf.ToString());
                        dogTricks.walk_to_point(myMind, target);
                        myMind.myDog.TurnTo(target.X, target.Y);
                        myMind.myContext.last_focus = target;
                        Console.WriteLine("At the target");

                        // Wei Chen 2010-04-21
                        if (myMind.myDog.PickupObject(target))
                        {
                            Console.WriteLine("Carried the target");
                        }

                        // Wei Chen 2010-04-21
                        dogTricks.walk_to_point(myMind, Convert.ToSingle(128), Convert.ToSingle(128));
                        myMind.myDog.DropObject(target);

                        return;
                    }
                }
                Console.WriteLine("Explore new ground");
                if (dogTricks.find_unexplored(myMind, target_CD, out fx, out fy, 25) == false)
                {
                    break;
                }
                dogTricks.walkTo(myMind, fx, fy, 10);
                myMind.update_explored();
                if (myMind.myContext.new_objects == null || myMind.myContext.new_objects.Count == 0)
                {
                    new_objects_flag = false;
                }
            }
            //      myMind.mySynth.SpeakAsync("I can't find the right target");
            Console.WriteLine("Gave up on finding the target");
        }