void Start () {
		COMMANDS = new Dictionary<string[], Action> () {
			{ new []{ "hey", "hello", "hi", "sup", "yo", "cooldog" }, SayHello },
            { new []{ "who are you", "your name" }, Introduce },
			{ new []{ "batman" }, BecomeBatman },
			{ new []{ "email" }, OpenEmail },
			{ new []{ "note", "memo" }, TakeNotes },
			{ new []{ "remember", "remind" }, RememberThing },
			{ new []{ "trivia", "fact", "facts", "wiki" }, TellFact },
			{ new []{ "housekeeping", "poop", "pooping", "clean", "cleaning", "smell", "smelly" }, SuggestCleaning },
            { new []{ "bye", "cya", "quit", "exit"}, Quit }
        };

		inputField.onEndEdit.AddListener (val => {
			if (Input.GetKeyDown (KeyCode.Return) || Input.GetKeyDown (KeyCode.KeypadEnter)) {
				Parse (inputField.text.ToLower ());
				inputField.text = "";
				inputField.DeactivateInputField ();
				inputField.interactable = false;
			}
		});

		cooldog = GameObject.Find ("Cooldog").GetComponent<Cooldog>();
		typer = cooldog.GetComponent<TextTyper>();
		Facts = new Facts ();
	}
예제 #2
0
 public Factoid(Facts.Fact f)
 {
     FactType = f.GetTvarType();
     Relationship = f.Relationship;
     Arg1 = Util.ArgToString(f.Arg1);
     Arg2 = Util.ArgToString(f.Arg2);
     Arg3 = Util.ArgToString(f.Arg3);
     QuestionText = f.QuestionText();
 }
예제 #3
0
        /// <summary>
        /// Adds the assertion relationship to the .akk unit test text.
        /// </summary>
        public static string AddUnitTestAssertRel(Facts.Fact theF, Question theQ)
        {
            string result = "- " + theQ.relationship + "(" + ((Thing)theF.Arg1).Id;

            if (theF.Arg2 == null)
            {
                // e.g. Rel(p) =
                result += ") = ";
            }
            else
            {
                // e.g. Rel(p,q) =
                result += "," + ((Thing)theF.Arg2).Id + ") = ";
            }

            return result;
        }
예제 #4
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     Facts ds = new Facts();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
예제 #5
0
 /// <summary>
 /// 武者修行の研究を行います。
 /// </summary>
 public ResearchSquires() : base(ri.squires)
 {
     Facts.Add(
         new unit_type_count_total(unit.spearman_line, relop.ge, 5)
         );
 }
예제 #6
0
 public byte GetWorldState(Facts fact)
 {
     return(this.GetWorldState((byte)fact));
 }
예제 #7
0
        /// <summary>
        /// Build the scene
        /// </summary>
        private void BuildScene()
        {
            tree = null;
            Facts facts = DataContext as Facts;

            dimensionSize = (facts != null)
                ? Math.Max(Math.Max(facts.What.Count, facts.Where.Count), facts.When.Count)
                : 8;

            double scale = (1d / (dimensionSize - 1)) * 0.9;

            Matrix3D scaleMatrix = new Matrix3D();

            scaleMatrix.Scale(new Vector3D(scale, scale, scale));

            Random         rand     = new Random();
            MeshGeometry3D cubeMesh = Resources["cubeMesh"] as MeshGeometry3D;

            List <IBSPItem> items = new List <IBSPItem>();

            for (int whatIndex = 0; whatIndex < dimensionSize; ++whatIndex)
            {
                double x = ((double)whatIndex / (dimensionSize - 1)) - 0.5d;

                for (int whereIndex = 0; whereIndex < dimensionSize; ++whereIndex)
                {
                    double y = ((double)whereIndex / (dimensionSize - 1)) - 0.5d;

                    for (int whenIndex = 0; whenIndex < dimensionSize; ++whenIndex)
                    {
                        double        z     = ((double)whenIndex / (dimensionSize - 1)) - 0.5d;
                        bool          valid = true;
                        double        materialOffset;
                        Facts.FactRow fact = null;

                        if (facts != null)
                        {
                            valid = (whatIndex < facts.What.Count) &&
                                    (whereIndex < facts.Where.Count)
                                    & (whenIndex < facts.When.Count);

                            if (valid)
                            {
                                fact = facts.Fact.FindByWhatWhereWhen(
                                    facts.What[whatIndex].ID,
                                    facts.Where[whereIndex].ID,
                                    facts.When[whenIndex].ID);

                                valid = (fact != null);
                            }

                            materialOffset = valid ? 0.4 : 0.55;
                        }
                        else
                        {
                            double alpha = (0.4 + (rand.NextDouble() * 0.6));

                            // Negative for red, positive for blue
                            materialOffset = ((rand.Next(5) == 2) ? -alpha : alpha) * 0.5 + 0.5;
                        }

                        Matrix3D matrix = scaleMatrix;
                        matrix.Translate(new Vector3D(x, y, z));

                        string uri = (fact != null) ? fact.ThumbnailUrl : null;

                        items.Add(new BSPCube(matrix, materialOffset, cubeMesh, uri));
                    }
                }
            }

            tree = new BSPTree(items, new BSPTree.PartitionHandler(TreePartition));
        }
예제 #8
0
 public void PushFactChangeDuringPlanning(Facts fact, FirearmOrders value, bool temporary)
 {
     this.PushFactChangeDuringPlanning((byte)fact, (byte)value, temporary);
 }
예제 #9
0
 public void PopFactChangeDuringPlanning(Facts fact)
 {
     this.PopFactChangeDuringPlanning((byte)fact);
 }
예제 #10
0
 public void WriteProcessNameInContext()
 {
     ExecutePolicy();
     Facts.Verify(Context.Property(TrackingProperties.ProcessName).WithValue(Factory.Areas.Batch.Processes.Release).HasBeenWritten());
 }
예제 #11
0
 public byte GetPreviousFact(Facts fact)
 {
     return(this._previousWorldState[(int)fact]);
 }
        private static Condition ReadCondition(YamlNode node)
        {
            // Read condition
            var yamlCondition = GetYamlString(node);

            if (yamlCondition == null)
            {
                throw new RulesException($"Expected a condition (string) but found: {node}");
            }

            Condition.Oper?oper      = null;
            var            condition = new Condition();

            // Parse condition (allow 3rd token to contain spaces)
            var tokens = yamlCondition.Split(" ", 3);

            if (tokens.Length == 1)
            {
                // Special prefixes & (IsDefined) and ! (NotDefined)
                if (tokens[0][0] == '&' || tokens[0][0] == '!')
                {
                    oper         = tokens[0][0] == '&' ? Condition.Oper.IsDefined : Condition.Oper.NotDefined;
                    condition.Id = tokens[0].Substring(1);

                    // Validate id (must be defined in Facts.cs)
                    Facts.GetType(condition.Id);
                }
                else
                {
                    // Boolean Combiners (And/Or)
                    var boolOp = tokens[0].ToLower();
                    if (boolOp == "and")
                    {
                        oper = Condition.Oper.And;
                    }
                    else if (boolOp == "or")
                    {
                        oper = Condition.Oper.Or;
                    }
                }
            }
            else if (tokens.Length == 3)
            {
                switch (tokens[1])
                {
                case "==":
                    oper = Condition.Oper.Equal;
                    break;

                case "!=":
                    oper = Condition.Oper.NotEqual;
                    break;

                case "<":
                    oper = Condition.Oper.LessThan;
                    break;

                case ">":
                    oper = Condition.Oper.GreaterThan;
                    break;

                case "<=":
                    oper = Condition.Oper.LessThanOrEqual;
                    break;

                case ">=":
                    oper = Condition.Oper.GreaterThanOrEqual;
                    break;

                default:
                    break;
                }

                try
                {
                    var fact = ParseFact(tokens[0], tokens[2]);
                    condition.Id    = fact.Id;
                    condition.Value = fact.Value;
                }
                catch (RulesException ex)
                {
                    throw new RulesException($"{ex.Message} in condition: {yamlCondition}");
                }
            }

            if (oper == null)
            {
                throw new RulesException($"Expected condition in format: 'AND', 'OR', '!id', 'id [==|!=|<|>|<=|>=] value' but found: {yamlCondition}");
            }

            condition.Op = oper ?? Condition.Oper.Equal;

            return(condition);
        }
예제 #13
0
 public void Maximum_9()
 {
     Facts.Clear();
     Assert.AreEqual(2, Max(1, 2).Out);
 }
예제 #14
0
 /// <summary>
 /// 塔があれば防御塔の研究を行います。
 /// </summary>
 public ResearchKeep() : base(ri.keep)
 {
     Facts.Add(
         new building_type_count_total(building.watch_tower_line, relop.ge, 1)
         );
 }
예제 #15
0
 /// <summary>
 /// 騎兵育成所を指定の数になるまで建設します。
 /// </summary>
 /// <param name="count">戦士育成所の最大数</param>
 public BuildStable(short count) : base(building.stable, count)
 {
     Facts.Add(new ResourceAmount(building.house, building.stable));
 }
예제 #16
0
        public static void Stat01()
        {
            Dictionary <string, int> user2factcnt = new Dictionary <string, int>();
            int           factcnt  = 0;
            int           eventcnt = 0;
            List <double> facttime = new List <double>();
            DateTime      mint     = DateTime.Now;
            DateTime      maxt     = DateTime.Now.AddYears(-20);

            HashSet <string> fidset = new HashSet <string>();

            string infile = @"\\mlsdata\e$\Users\v-lianji\others\CIKM16\data-train-dca\facts.json";

            using (StreamReader rd = new StreamReader(infile))
            {
                factcnt = 0;
                string content = null;
                while ((content = rd.ReadLine()) != null)
                {
                    if (factcnt++ % 10000 == 0)
                    {
                        Console.WriteLine(factcnt);
                    }

                    Facts    ss = JsonConvert.DeserializeObject <Facts>(content);
                    DateTime t1 = DateTime.Now;
                    DateTime t2 = DateTime.Now.AddYears(-20);
                    if (!user2factcnt.ContainsKey(ss.uid))
                    {
                        user2factcnt.Add(ss.uid, 1);
                    }
                    else
                    {
                        user2factcnt[ss.uid]++;
                    }


                    foreach (var re in ss.facts)
                    {
                        var curt = UserProfileInfer.Utils.Common.ParseTimeStampMillisecond(re.ts);
                        if (curt.CompareTo(t1) < 0)
                        {
                            t1 = curt;
                        }
                        if (curt.CompareTo(t2) > 0)
                        {
                            t2 = curt;
                        }
                        if (curt.CompareTo(mint) < 0)
                        {
                            mint = curt;
                        }
                        if (curt.CompareTo(maxt) > 0)
                        {
                            maxt = curt;
                        }
                    }


                    if (ss.facts.Count > 1)
                    {
                        facttime.Add(t2.Subtract(t1).TotalMinutes);
                    }
                    eventcnt += ss.facts.Count;
                }
            }

            Console.WriteLine("Facts cnt : {0}", factcnt);
            Console.WriteLine("Event cnt : {0}", eventcnt);
            Console.WriteLine("Facts avg : {0}", eventcnt * 1.0 / factcnt);
            Console.WriteLine("user cnt : {0}", user2factcnt.Count);
            Console.WriteLine("user max fact cnt : {0}", user2factcnt.Max(a => a.Value));
            Console.WriteLine("Single Event max length : {0}", facttime.Max());
            Console.WriteLine("Single Event avg length : {0}", facttime.Average());
            Console.WriteLine("min time   : {0}", mint);
            Console.WriteLine("max time   : {0}", maxt);
        }
예제 #17
0
 /// <summary>
 /// 石の切り出しの研究を行います。
 /// </summary>
 public ResearchStoneMining() : base(ri.stone_mining)
 {
     Facts.Add(new food_amount(relop.ge, 500));
 }
예제 #18
0
 public FirstViewModel(Facts.Domain.Service.IFactService factService)
 {
     _factService = factService;
     NextFactCommand = new MvxCommand(NextFactEvent);
     NextFactEvent();
 }
예제 #19
0
 public void Maximum_8()
 {
     Facts.Clear();
     Assert.AreEqual("Stub", Max(new Tnum(Hstate.Unstated), new Tnum(Hstate.Uncertain), new Tnum(Hstate.Stub)).Out);
 }
예제 #20
0
 /// <summary>
 /// 追跡術の研究を行います。
 /// </summary>
 public ResearchTracking() : base(ri.tracking)
 {
     Facts.Add(
         new unit_type_count_total(unit.spearman_line, relop.ge, 5)
         );
 }
예제 #21
0
 public byte GetFact(Facts fact)
 {
     return(this._worldState[(int)fact]);
 }
예제 #22
0
 /// <summary>
 /// 隊商の研究を行います。
 /// </summary>
 public ResearchCaravan() : base(ri.caravan)
 {
     Facts.Add(new unit_type_count_total(unit.trade_cart, relop.ge, 2));
 }
예제 #23
0
 public bool IsFact(Facts fact)
 {
     return(this.GetFact(fact) > (byte)0);
 }
예제 #24
0
 public override bool Evaluate(Facts facts)
 {
     return(true);
 }
예제 #25
0
 public void PushFactChangeDuringPlanning(Facts fact, byte value, bool temporary)
 {
     this.PushFactChangeDuringPlanning((byte)fact, value, temporary);
 }
예제 #26
0
        /// <summary>
        /// Displays the engine's results of the interview session.
        /// </summary>
        private static void DisplayResults(Facts.Fact goal)
        {
            Console.WriteLine("\n");

            // Indent and format results
            string tline = "\t" + goal.ValueAsString().Replace("\n","\n\t");

            // For eternal values, only show value
            if (goal.Value().IsEternal)
            {
                tline = tline.Replace("DawnOfTime   ","");
            }

            // Concatenate question and answer
            string result = "\t" + goal.QuestionText() + "\n\n" + tline + "\n";

            // Add result to test case
            Tvar testResult = goal.GetFunction().Invoke();
            AkkTest.CloseUnitTest(testResult, goal.Relationship);

            Console.WriteLine(result);
        }
예제 #27
0
 public byte PeekFactChangeDuringPlanning(Facts fact)
 {
     return(this.PeekFactChangeDuringPlanning((byte)fact));
 }
예제 #28
0
 /// <summary>
 /// 石の掘削の研究を行います。
 /// </summary>
 public ResearchStoneShaftMining() : base(ri.stone_shaft_mining)
 {
     //金の掘削の研究が終わってから
     Facts.Add(!new research_available(ri.gold_shaft_mining));
 }
            public override void Binary(BinaryOperator binaryOperator, BoxedExpression left, BoxedExpression right, BoxedExpression parent)
            {
                left.Dispatch(this);
                if (this.Overflow)
                {
                    return;
                }
                right.Dispatch(this);
                if (this.Overflow)
                {
                    return;
                }

                switch (binaryOperator)
                {
                case BinaryOperator.Add:
                case BinaryOperator.Add_Ovf:
                case BinaryOperator.Add_Ovf_Un:
                {
                    // different signs, or both positive ==> no overflow
                    int leftSign, rightSign;
                    if (Facts.TrySign(pc, left, out leftSign) && Facts.TrySign(pc, right, out rightSign))
                    {
                        if (leftSign >= 0 || rightSign >= 0)
                        {
                            this.Overflow = false;
                            return;
                        }
                    }

                    // TODO: improve using upper bounds
                    this.Overflow = true;
                    return;
                }

                case BinaryOperator.Div:
                case BinaryOperator.Div_Un:
                case BinaryOperator.Rem:
                case BinaryOperator.Rem_Un:
                {
                    // TODO: improve using upper bounds

                    if (Facts.IsNonZero(pc, right) == ProofOutcome.True)
                    {
                        this.Overflow = false;
                    }

                    this.Overflow = true;
                    return;
                }

                case BinaryOperator.Mul:
                case BinaryOperator.Mul_Ovf:
                case BinaryOperator.Mul_Ovf_Un:
                {
                    // TODO: improve using upper bounds

                    this.Overflow = true;
                    return;
                }

                case BinaryOperator.Sub:
                case BinaryOperator.Sub_Ovf:
                case BinaryOperator.Sub_Ovf_Un:
                {
                    int leftSign, rightSign;
                    // if left is non-negative or right is non-positive ==> no undeflow
                    if (Facts.TrySign(pc, left, out leftSign) && Facts.TrySign(pc, right, out rightSign))
                    {
                        if (leftSign >= 0 || rightSign <= 0)
                        {
                            this.Overflow = false;
                            return;
                        }
                    }

                    this.Overflow = true;
                    return;
                }

                case BinaryOperator.And:
                case BinaryOperator.Ceq:
                case BinaryOperator.Cge:
                case BinaryOperator.Cge_Un:
                case BinaryOperator.Cgt:
                case BinaryOperator.Cgt_Un:
                case BinaryOperator.Cle:
                case BinaryOperator.Cle_Un:
                case BinaryOperator.Clt:
                case BinaryOperator.Clt_Un:
                case BinaryOperator.Cne_Un:
                case BinaryOperator.Cobjeq:
                case BinaryOperator.LogicalAnd:
                case BinaryOperator.LogicalOr:
                case BinaryOperator.Or:
                case BinaryOperator.Shl:
                case BinaryOperator.Shr:
                case BinaryOperator.Shr_Un:
                case BinaryOperator.Xor:
                {
                    this.Overflow = false;
                    return;
                }

                default:
                {
                    this.Overflow = true;
                    return;
                }
                }
            }
예제 #30
0
 /**
  * @return Returns all facts of the given type.
  */
 public IEnumerable <Fact> GetFacts(string factType)
 {
     return(Facts.Where(f => f.FactType == factType));
 }
예제 #31
0
 public Fact AddFact(Context context, string metric, string unitRef, string decimals, string value)
 => Facts.Add(context, metric, unitRef, decimals, value);
예제 #32
0
 /// <summary>
 /// 町の人が指定人数以上になったら手押し車の研究を行います。
 /// </summary>
 public ResearchWheelBarrow(short villagerCount) : base(ri.wheel_barrow)
 {
     Facts.Add(
         new unit_type_count_total(unit.villager, relop.ge, villagerCount)
         );
 }
예제 #33
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     Facts ds = new Facts();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "WhatDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
 public void IncrementFact(Facts fact, byte value, bool invokeChangedEvent = true, bool setAsDirty = true, bool checkValueDiff = true)
 {
     this.SetFact(fact, (int)(this.GetFact(fact) + value), invokeChangedEvent, setAsDirty, checkValueDiff);
 }
예제 #35
0
        public Facts CloneFact(Facts Fact)
        {
            Facts NewFact = new Facts();

            NewFact.Topic = Fact.Topic;
            NewFact.Knowledge = Fact.Knowledge;

            return NewFact;
        }
 public void SetFact(Facts fact, int value, bool invokeChangedEvent = true, bool setAsDirty = true, bool checkValueDiff = true)
 {
     this.SetFact(fact, (byte)value, invokeChangedEvent, setAsDirty, checkValueDiff);
 }
예제 #37
0
 public void DoNotWriteProcessNameInContext()
 {
     Facts.Assert(Context.Property(TrackingProperties.ProcessName).WithValue("some-process-name"));
     ExecutePolicy();
     Facts.Verify(Context.Property(TrackingProperties.ProcessName).WithAnyValue().HasNotBeenWritten());
 }
예제 #38
0
 public void Maximum_7()
 {
     Facts.Clear();
     Assert.AreEqual("Stub", Max(0, new Tnum(Hstate.Stub)).Out);
 }