コード例 #1
0
        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
                      );
        }
コード例 #2
0
 public Action(AdjacencyPair pair)
 {
     this.move              = new Conversation.MovesQueueItem();//make empty move item to keep compiler happy
     this.pair              = pair;
     this.condition         = true;
     this.preferredness     = Preferredness.neutral;
     this.discourseFunction = ConversationalParamaters.DiscourseType.none;
 }
コード例 #3
0
 public Action(Conversation.MovesQueueItem move)
 {
     this.move          = move;
     this.pair          = null;
     this.condition     = true;
     this.preferredness = Preferredness.neutral;
     discourseFunction  = ConversationalParamaters.DiscourseType.none;
 }
コード例 #4
0
        //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;
        }
コード例 #5
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
                      );
        }
コード例 #7
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
                      );
        }
コード例 #8
0
        private Queue <Turn> outputQueue;//queue of utterances


        public Conversation(World w, LinguisticDictionary.LinguisticDictionary v, ConversationalParamaters paramaters)
        {
            world                    = w;
            vocabDictionary          = v;
            conversationalParamaters = paramaters;

            r                  = new Random();
            topicQueue         = new Queue <Topic>();
            adjacencyPairRoot  = new ProductionLayers.AdjacencyPairs.AdjacencyPair();
            adjacencyPairQueue = new Queue <ProductionLayers.AdjacencyPairs.AdjacencyPair>();
            MovesQueue         = new Queue <MovesQueueItem>();
            outputQueue        = new Queue <Turn>();

            initQUD(); //place greeting sequence, if appropriate
            go();      //immediately begin processing
        }
コード例 #9
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*/)
 {
 }
コード例 #10
0
        }                          //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
                      );
        }
コード例 #12
0
        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
                      );
        }