Пример #1
0
    // Use this for initialization
    void Start()
    {
        agents = new List <NEEDSIMNode> ();
        agent1 = null;
        agent2 = null;

        state = State.NoConversation;


        worldEngine = new WorldEngine();
        worldEngine.loadWorldFile();

        dialogueGenerator = new DialogueGenerator(worldEngine);

        cParams = new ConversationalParamaters(ConversationalParamaters.conversationType.helloOnly, "<agent1>", "<agent2>");
        cParams.greetingMode         = ConversationalParamaters.GreetingMode.fourTurn;
        cParams.farewellMode         = ConversationalParamaters.FarewellMode.simple;
        cParams.conversationLocation = worldEngine.world.findByProperNoun("Germany");

        QUDitem q = new QUDitem(QUDitem.ExchangeTypeEnum.where);

        q.subject = worldEngine.world.findByProperNoun("Westerberg Campus");

        cParams.addQUDitem(q);
    }
Пример #2
0
        /*this is the entry point for the dialogue manager*/
        private void CreateConvoButton_Click(object sender, EventArgs e)
        {
            ConversationalParamaters cParams =
                new ConversationalParamaters(ConversationalParamaters.ConversationType.helloOnly, worldManager.world.findAgentByName("John Snow"), worldManager.world.findAgentByName("Mary Jane"), worldManager.world);

            cParams.greetingMode = ConversationalParamaters.GreetingMode.fourTurn;
            cParams.farewellMode = ConversationalParamaters.FarewellMode.simple;//by default conversation type helloOnly doesnt have a farewell

            Topic t = new Topic(Topic.ExchangeTypeEnum.where);

            t.subject = worldManager.world.findByProperNoun("Westerberg Campus");

            cParams.addTopic(t);



            if (dialogueGenerator.conversation == null)
            {
                dialogueGenerator.newConversation(cParams);
            }

            //get everything off the output buffer
            while (dialogueGenerator.hasNextOutput())
            {
                updateOutput(dialogueGenerator.getOutput());
            }

            EndConvoButton.Enabled = true;
        }
        public AdjacencyPairPrefab_greeting(AdjacencyPair parent, ConversationalParamaters conversationalParamaters, PairParamaters q)
        {
            //init preset paramaters, then pass them up to the base class

            /*describe purpose of paramaters
             * if 2-stroke greeting
             * 1. initiating part: hi
             * 2. response: hi
             *
             * if 4-stroke greeting
             * 1. initiating part: PAIR(hi, hi) (recursive)
             * 2. responding part: PAIR(how are you exchange, how are you exchange)
             * etc.
             */

            /*1. initiating options*/
            //initiation 1: if its a two stroke just say hi
            Action initiation;
            Action response;

            Type    typepoo = parent.GetType();
            Boolean poo     = parent.GetType() == typeof(AdjacencyPairPrefab_greeting);
            Boolean poo2    = parent.Equals(typeof(AdjacencyPairPrefab_greeting));
            Boolean poo3    = parent.GetType().Equals(typeof(AdjacencyPairPrefab_greeting));

            if (conversationalParamaters.greetingMode == ConversationalParamaters.GreetingMode.twoTurn || parent is AdjacencyPairPrefab_greeting)
            {
                initiation = new Action(new Conversation.MovesQueueItem("senseGreeting", new object[2] {
                    q, conversationalParamaters
                }));                                                                                                                     //hi
                response = new Action(new Conversation.MovesQueueItem("senseGreeting", new object[2] {
                    q.cloneAndSwapSpeakers(), conversationalParamaters
                }));                                                                                                                                          //hi
            }
            else //assume we're doing a four-stroke greeting. initation is a new normal greeting pair (recursive), response is a pair of howAreYou exchanges
            {
                initiation = new Action(new AdjacencyPairPrefab_greeting(this, conversationalParamaters, q));
                response   = new Action(new AdjacencyPairPrefab_greeting_questionExchange(this, conversationalParamaters, q.cloneAndSwapSpeakers()));
            }

            //now put all the parts into arrays
            Action[] initiatingActionArray = { initiation };
            Action[] respondingActionArray = { response };

            /*
             * END MAKING OPTIONS
             *
             * PUSH ALL TO BASE
             *
             */

            //send these presets to the base
            base.init("greeting",
                      parent,
                      conversationalParamaters,
                      initiatingActionArray,
                      respondingActionArray
                      );
        }
Пример #4
0
        public AdjacencyPairPrefab_greeting_questionExchange(AdjacencyPair parent, ConversationalParamaters conversationalParamaters, PairParamaters q)
        {
            //init preset paramaters, then pass them up to the base class

            /*describe purpose of paramaters
             * nothing special
             *
             * 1. initiating part: MOVE how are you
             * 2. responding part: MOVE i'm fine
             */

            /*1. initiating options*/
            //initiation 1: how are you
            Action initiation;
            Action response;

            //TODO determine if it should be a reciprocating question or not

            //if its parent is of type greeting_exchange then make moves. otherwise enqueue two more, one for each person to ask the other how they are
            if (parent is AdjacencyPairPrefab_greeting_questionExchange)
            {
                initiation = new Action(new Conversation.MovesQueueItem("senseGreetingQuestion", new object[2] {
                    q, conversationalParamaters
                }));                                                                                                                             //hi
                response = new Action(new Conversation.MovesQueueItem("senseGreetingAnswer", new object[2] {
                    q.cloneAndSwapSpeakers(), conversationalParamaters
                }));                                                                                                                                                //hi
            }
            else //make one new pair for each person to ask the other how they are
            {
                initiation = new Action(new AdjacencyPairPrefab_greeting_questionExchange(this, conversationalParamaters, q));
                response   = new Action(new AdjacencyPairPrefab_greeting_questionExchange(this, conversationalParamaters, q.cloneAndSwapSpeakers()));
            }



            //now put all the actions in arrays
            Action[] respondingActionArray = { response };
            Action[] initiatingActionArray = { initiation };

            /*
             * END MAKING RESPONDING OPTIONS
             *
             * PUSH ALL TO BASE
             *
             */

            //send these presets to the base
            base.init("greeting question",
                      parent,
                      conversationalParamaters,
                      initiatingActionArray,
                      respondingActionArray
                      );
        }
        //this is effectively the constructors' body
        //it is here so that the constructors can be arbitrarily overloaded and then every constructor just calls this function
        //NOTE: when using the default constructor e.g. from a derived class, this function must be called manually
        virtual protected void init(String descriptionForDebugging, AdjacencyPair parent, ConversationalParamaters conversationalParamaters, Action[] initiatingAction, Action[] respondingAction)
        {
            //TODO error checking, make sure input arrays are non-empty
            this.descriptionForDebugging = descriptionForDebugging;

            this.parent = parent;
            this.conversationalParamaters = conversationalParamaters;

            this.initiatingActionArray = initiatingAction;
            this.respondingActionArray = respondingAction;
        }
Пример #6
0
        public AdjacencyPairPrefab_restaraunt_placeOrder(AdjacencyPair parent, ConversationalParamaters conversationalParamaters, PairParamaters q, TypeDefinition thingToOrder, Boolean isThatOrderPossible)
        {
            //init preset paramaters, then pass them up to the base class

            /*describe function
             * check that customer is the initiator, else swap
             *
             * initiating part
             * can i have... please
             * I would like... please
             * a ... please
             *
             * respondong part
             * yes (preferred)
             * no (disprefferred)
             */

            /*1. initiating options*/
            Action initiation;
            Action response;

            //make the verb for the modal request
            Verb canIHaveX = new Verb(q.initiatingSpeaker, "have");

            canIHaveX.setMonoTransitive("", thingToOrder);

            initiation = new Action(new Conversation.MovesQueueItem("sense_modal_request", new object[2] {
                q, canIHaveX
            }));
            response = new Action(new Conversation.MovesQueueItem("sense_response_yesNo", new object[3] {
                q.cloneAndSwapSpeakers(), conversationalParamaters, isThatOrderPossible
            }));                                                                                                                                                                          //hi


            //now put all the parts into arrays
            Action[] initiatingActionArray = { initiation };
            Action[] respondingActionArray = { response };

            /*
             * END MAKING OPTIONS
             *
             * PUSH ALL TO BASE
             *
             */

            //send these presets to the base
            base.init("restaraunt place an order",
                      parent,
                      conversationalParamaters,
                      initiatingActionArray,
                      respondingActionArray
                      );
        }
        public AdjacencyPairPrefab_compliment(AdjacencyPair parent, ConversationalParamaters conversationalParamaters, PairParamaters q, TypeDefinition thingToCompliment)
        {
            //init preset paramaters, then pass them up to the base class

            /*describe function
             * give a compliment on either
             * a person: you look good
             * a thing: your cake is really good
             * TODO an ability: you can cook really well
             *
             * initiating part
             * compliment
             *
             * respondong part
             * thanks
             */

            /*1. initiating options*/
            Action initiation;
            Action response;

            Verb itsreallygood = new Verb(thingToCompliment, "is");

            itsreallygood.adverb = "really good";//TODO definitely doesnt work

            initiation = new Action(new Conversation.MovesQueueItem("sense_compliment_give", new object[2] {
                q, itsreallygood
            }));
            response = new Action(new Conversation.MovesQueueItem("senseThanks", new object[2] {
                q.cloneAndSwapSpeakers(), conversationalParamaters
            }));


            //now put all the parts into arrays
            Action[] initiatingActionArray = { initiation };
            Action[] respondingActionArray = { response };

            /*
             * END MAKING OPTIONS
             *
             * PUSH ALL TO BASE
             *
             */

            //send these presets to the base
            base.init("compliment",
                      parent,
                      conversationalParamaters,
                      initiatingActionArray,
                      respondingActionArray
                      );
        }
Пример #8
0
        public AdjacencyPairPrefab_restaraunt_takeOrder(AdjacencyPair parent, ConversationalParamaters conversationalParamaters, PairParamaters q, TypeDefinition thingToOrder, Boolean isThatOrderPossible)
        {
            //init preset paramaters, then pass them up to the base class

            /*describe function
             * check that waiter is the initiator, else swap
             *
             *
             * initiating part
             * can i take your order
             *
             * respondong part
             * PAIR(place order...)
             * TODO "no, i need more time to decide" "ok ill come back soon"
             */

            /*1. initiating options*/
            Action initiation;
            Action response;

            //make the verb for the modal request
            Verb canITakeOrder = new Verb(q.initiatingSpeaker, "take");

            canITakeOrder.setMonoTransitive("", "your order");//the verb renderer should automatically render it as 'your X'

            initiation = new Action(new Conversation.MovesQueueItem("sense_modal_request", new object[2] {
                q, canITakeOrder
            }));
            response = new Action(new AdjacencyPairPrefab_restaraunt_placeOrder(this, conversationalParamaters, q.cloneAndSwapSpeakers(), thingToOrder));//hi


            //now put all the parts into arrays
            Action[] initiatingActionArray = { initiation };
            Action[] respondingActionArray = { response };

            /*
             * END MAKING OPTIONS
             *
             * PUSH ALL TO BASE
             *
             */

            //send these presets to the base
            base.init("restaraunt take an order (different to place an order)",
                      parent,
                      conversationalParamaters,
                      initiatingActionArray,
                      respondingActionArray
                      );
        }
        public AdjacencyPairPrefab_farewell(AdjacencyPair parent, ConversationalParamaters conversationalParamaters, PairParamaters q)
        {
            //init preset paramaters, then pass them up to the base class

            /*describe purpose of paramaters
             * if farewell mode simple
             * 1. initiating part: MOVE(bye)
             * 2. response: MOVE(bye)
             *
             * TODO other farewell modes. e.g. none. thanks.
             */

            /*1. initiating options*/
            //initiation 1: bye
            Action initiation;
            Action response;


            initiation = new Action(new Conversation.MovesQueueItem("senseFarewell", new object[2] {
                q, conversationalParamaters
            }));

            response = new Action(new Conversation.MovesQueueItem("senseFarewell", new object[2] {
                q.cloneAndSwapSpeakers(), conversationalParamaters
            }));

            //now put all the parts into arrays
            Action[] initiatingActionArray = { initiation };
            Action[] respondingActionArray = { response };

            /*
             * END MAKING OPTIONS
             *
             * PUSH ALL TO BASE
             *
             */

            //send these presets to the base
            base.init("farewell",
                      parent,
                      conversationalParamaters,
                      initiatingActionArray,
                      respondingActionArray
                      );
        }
Пример #10
0
 //overloaded constructor default booleans
 public AdjacencyPairPrefab_restaraunt_takeOrder(AdjacencyPair parent, ConversationalParamaters conversationalParamaters, PairParamaters q, TypeDefinition thingToOrder)
     : this(parent, conversationalParamaters, q, thingToOrder, true /*default value TRUE*/)
 {
 }
        }                          //only for use as parent node and as default constructor for calling from derived classes

        /*Adjacency pair always has conversational paramaters + a first and a second part*/
        public AdjacencyPair(String descriptionForDebugging, AdjacencyPair parent, ConversationalParamaters conversationalParamaters, Action[] initiatingAction, Action[] respondingAction)
        {
            init(descriptionForDebugging, parent, conversationalParamaters, initiatingAction, respondingAction);
        }
        public AdjacencyPairPrefab_discuss_short(AdjacencyPair parent, ConversationalParamaters conversationalParamaters, PairParamaters q, object thingToDiscuss)
        {
            //init preset paramaters, then pass them up to the base class

            /*describe function
             * EITHER ask the other person a question about a thing/type and they respond
             * OR offer a comment about a thing/type and they agree/disagree
             *
             * ASK-OPINE
             * initiating part
             * PAIR(whats your feeling on x)
             *
             * respondong part
             * PAIR(give feeling about x)
             *
             *
             * OPINE-AGREE/DISAGREE
             * initiating part
             * PAIR(give feeling about x)
             *
             * responding part
             * PAIR(agree/disagree)
             */

            /*1. initiating options*/
            Action initiation;
            Action response;

            //get each persons opinion
            Opinion opinion = conversationalParamaters.world.getOpinion(q.initiatingSpeaker, thingToDiscuss);
            Opinion answer  = conversationalParamaters.world.getOpinion(q.respondingSpeaker, thingToDiscuss);


            if (conversationalParamaters.r.NextDouble() >= 0.5)
            {
                //Do you like x? Is X good?
                initiation = new Action(new Conversation.MovesQueueItem("sense_discuss_askFeelings", new object[3] {
                    q, conversationalParamaters, opinion
                }));

                //I love X. X is great because its so tasty.
                response = new Action(new Conversation.MovesQueueItem("sense_discuss_giveFeelings", new object[4] {
                    q.cloneAndSwapSpeakers(), conversationalParamaters, answer, opinion
                }));
            }
            else
            {
                initiation = new Action(new Conversation.MovesQueueItem("sense_discuss_giveFeelings", new object[3] {
                    q, conversationalParamaters, answer
                }));

                /*see if the interlocutor agrees or not*/
                //do stuff

                //pass result to the sense
                response = new Action(new Conversation.MovesQueueItem("sense_discuss_agreeDisagree", new object[3] {
                    q.cloneAndSwapSpeakers(), opinion, answer
                }));
            }

            //now put all the parts into arrays
            Action[] initiatingActionArray = { initiation };
            Action[] respondingActionArray = { response };

            /*
             * END MAKING OPTIONS
             *
             * PUSH ALL TO BASE
             *
             */

            //send these presets to the base
            base.init("compliment",
                      parent,
                      conversationalParamaters,
                      initiatingActionArray,
                      respondingActionArray
                      );
        }
        public AdjacencyPairPrefab_request(AdjacencyPair parent, ConversationalParamaters conversationalParamaters, PairParamaters q, Verb verb)
        {
            //init preset paramaters, then pass them up to the base class

            /*describe purpose of paramaters
             * 1. initiating part: request
             * 2. prefered response: grant request
             * 3. disprefered response: deny request
             * 4. default response: noncomittal
             * conditions:
             */

            /*1. initiating options*/
            //initiation 1: get straight to the point and request
            Action initiationDirect = new Action(new Conversation.MovesQueueItem("sense_request", new object[2] {
                q, verb
            }));

            //initation 2: first ask if its ok to make a request, then make the request (nests another request inside this request)
            //more polite, more long-winded, less direct
            Action[] initiatingActionArray;

            //if (not already a nested request) AND (random chance that increases with politeness)
            if ((this.parent.GetType() != typeof(AdjacencyPairPrefab_request)) && (conversationalParamaters.r.Next(4, 10) <= q.politeness))//becomes linearly more likely the higher the politeness is. minimum politeness 4
            {
                //make the adjacency pair then insert in action
                Verb askAQuestion = new Verb(q.initiatingSpeaker, "ask");
                askAQuestion.setMonoTransitive("", "a question");
                //put that into a moveItem
                Conversation.MovesQueueItem m = new Conversation.MovesQueueItem("sense_permission", new object[2] {
                    1, askAQuestion
                });

                //make that verb into an action which will consist of requesting to make a request, and it being either granted or denied

                Action initiationNestedRequest =
                    new Action(
                        new AdjacencyPair("request", this, conversationalParamaters,
                                          new Action[1] {
                    new Action(m)
                },                                           //initiating move
                                          new Action[2] {    //responding moves
                    new Action(new Conversation.MovesQueueItem("sense_request_grantRequest", new object[2] {
                        q, Preferredness.preferred
                    })),
                    new Action(new Conversation.MovesQueueItem("sense_request_denyRequest", new object[2] {
                        q, Preferredness.dispreferred
                    }))
                }
                                          )
                        );

                //put actions in the array
                initiatingActionArray = new Action[] { initiationDirect, initiationNestedRequest };
            }    //end making the second option

            else //only one initiating action
            {
                initiatingActionArray = new Action[] { initiationDirect };
            }

            /*
             * END MAKING INITIATING OPTIONS
             *
             * START MAKING THE RESPONDING OPTIONS
             *
             */

            /*prefered response: grant request*/
            Action preferredResponse = new Action(new Conversation.MovesQueueItem("sense_request_grantRequest", new object[] { q, Preferredness.preferred }));

            preferredResponse.preferredness = Preferredness.preferred;

            /*disprefered response: deny request*/
            Action dispreferredResponse = new Action(new Conversation.MovesQueueItem("sense_request_denyRequest", new object[] { q, Preferredness.dispreferred }));

            preferredResponse.preferredness = Preferredness.dispreferred;

            //now put all the responding actions in an array
            Action[] respondingActionArray = { preferredResponse, dispreferredResponse };

            /*
             * END MAKING RESPONDING OPTIONS
             *
             * PUSH ALL TO BASE
             *
             */

            //send these presets to the base
            base.init("request",
                      parent,
                      conversationalParamaters,
                      initiatingActionArray,
                      respondingActionArray
                      );
        }