Beispiel #1
0
        public void CloneTest()
        {
            var exp   = new LCM(Variable.X, new Number(0));
            var clone = exp.Clone();

            Assert.Equal(exp, clone);
        }
Beispiel #2
0
            public void MessageReceived(LCM.LCM lcm, string channel, LCM.LCMDataInputStream dins)
            {
                Console.WriteLine("RECV: " + channel);

                if (channel == "EXAMPLE")
                {
                    exlcm.example_t msg = new exlcm.example_t(dins);

                    Console.WriteLine("Received message of the type example_t:");
                    Console.WriteLine("  timestamp   = {0:D}", msg.timestamp);
                    Console.WriteLine("  position    = ({0:N}, {1:N}, {2:N})",
                            msg.position[0], msg.position[1], msg.position[2]);
                    Console.WriteLine("  orientation = ({0:N}, {1:N}, {2:N}, {3:N})",
                            msg.orientation[0], msg.orientation[1], msg.orientation[2],
                            msg.orientation[3]);
                    Console.Write("  ranges      = [ ");
                    for (int i = 0; i < msg.num_ranges; i++)
                    {
                        Console.Write(" {0:D}", msg.ranges[i]);
                        if (i < msg.num_ranges-1)
                            Console.Write(", ");
                    }
                    Console.WriteLine(" ]");
                    Console.WriteLine("  name         = '" + msg.name + "'");
                    Console.WriteLine("  enabled      = '" + msg.enabled + "'");
                }
            }
Beispiel #3
0
 private static void LaneClearMenu()
 {
     LCM = Menu.AddSubMenu("Laneclear Menu", "PreMenu");
     LCM.AddLabel("Spell Settings");
     LCM.Add("useQ", new CheckBox("Use Q"));
     LCM.Add("useW", new CheckBox("Use W"));
     LCM.Add("sliderQ", new Slider("Use Q if Kill {0} Minions", 3, 1, 5));
     LCM.Add("sliderW", new Slider("Use W if Kill {0} Minions", 3, 1, 5));
 }
Beispiel #4
0
        public void Test_Calculate()
        {
            Assert.AreEqual(1, LCM.Calculate(1, 1));
            Assert.AreEqual(2, LCM.Calculate(1, 2));
            Assert.AreEqual(37 * 39, LCM.Calculate(37, 39));
            Assert.AreEqual(60, LCM.Calculate(60, 15));
            Assert.AreEqual(37 * 3 * 5, LCM.Calculate(111, 15));
            Assert.AreEqual(1 * 3 * 5 * 7 * 11 * 13 * 17 * 23, LCM.Calculate(1 * 3 * 5 * 7 * 11 * 13 * 17, 5 * 7 * 13 * 23));

            Assert.AreEqual(1, LCM.Calculate(new int[] { 1, 1, 1 }));
            Assert.AreEqual(6, LCM.Calculate(new int[] { 1, 2, 3 }));
            Assert.AreEqual(5 * 7 * 8 * 9, LCM.Calculate(new int[] { 1, 2, 3, 5, 6, 7, 8, 9 }));
        }
        private static void LaneClearMenu()
        {
            LCM = Menu.AddSubMenu("Laneclear", "laneclear");
            LCM.Add("Q", new CheckBox("Kullan Q", false));
            LCM.Add("QMana", new Slider("en az mana yüzde Q", 20, 0, 100));
            LCM.Add("W", new CheckBox("Kullan W"));
            LCM.Add("WMana", new Slider("en az mana yüzde W", 20, 0, 100));
            LCM.Add("W2", new CheckBox("Otomatik W2"));
            LCM.Add("WMin", new Slider("en az mana yüzde W", 4, 1, 10));
            LCM.AddSeparator();
            LCM.Add("R", new CheckBox("Kullan R (W)", false));
            LCM.Add("RMin", new Slider("en az mana yüzde R (W)", 6, 1, 10));

            //Who uses E in laneclear -.-
        }
Beispiel #6
0
        private static void LaneClearMenu()
        {
            LCM = Menu.AddSubMenu("Laneclear", "laneclear");
            LCM.Add("Q", new CheckBox("Use Q", false));
            LCM.Add("QMana", new Slider("Min % mana to Q", 20, 0, 100));
            LCM.Add("W", new CheckBox("Use W"));
            LCM.Add("WMana", new Slider("Min % mana to W", 20, 0, 100));
            LCM.Add("W2", new CheckBox("Auto W2"));
            LCM.Add("WMin", new Slider("Min minions to W", 4, 1, 10));
            LCM.AddSeparator();
            LCM.Add("R", new CheckBox("Use R (W)", false));
            LCM.Add("RMin", new Slider("Min minions to R (W)", 6, 1, 10));

            //Who uses E in laneclear -.-
        }
        private static void LaneClearMenu()
        {
            LCM = Menu.AddSubMenu("清线", "laneclear");
            LCM.Add("Q", new CheckBox("使用 Q", false));
            LCM.Add("QMana", new Slider("最低 % 蓝量Q", 20, 0, 100));
            LCM.Add("W", new CheckBox("使用 W"));
            LCM.Add("WMana", new Slider("最低 % 蓝量W", 20, 0, 100));
            LCM.Add("W2", new CheckBox("自动 W2"));
            LCM.Add("WMin", new Slider("最低小兵数量 W", 4, 1, 10));
            LCM.AddSeparator();
            LCM.Add("R", new CheckBox("使用 R (W)", false));
            LCM.Add("RMin", new Slider("最低小兵数量 R (W)", 6, 1, 10));

            //Who uses E in laneclear -.-
        }
		public void MessageReceived(LCM.LCM.LCM lcm, string channel, LCM.LCM.LCMDataInputStream dins)
		{
			Debug.Log ("RECV: " + channel);
			if (channel == "EXAMPLE")
			{
//				forseti2.health msg = new forseti2.health(dins);
//				String output = "CLCM received message of the type forseti2_health:\n";
//				output+="msg.header.seq=\t" + msg.header.seq + "\n";
//				output+="msg.header.time=\t" + msg.header.time + "\n";
//				output+="msg.uptime=\t"+msg.uptime+"\n";
//				Debug.Log (output);
//
//				forseti2.health response = new forseti2.health();
//				response.header = new forseti2.header();
//				response.header.seq = seq++;
//				TimeSpan span = DateTime.Now - new DateTime(1970, 1, 1);
//				response.header.time = span.Ticks*100;
//				response.uptime = Time.realtimeSinceStartup;
//				lcm.Publish("unity/health", response);


				exlcm.example_t msg = new exlcm.example_t(dins);
				String message = "CLCM Received message of the type example_t:\n ";
				message+=String.Format("  timestamp   = {0:D}", msg.timestamp);
				message+=String.Format("  position    = ({0:N}, {1:N}, {2:N})\n ",
				                       msg.position[0], msg.position[1], msg.position[2]);
				message+=String.Format("  orientation = ({0:N}, {1:N}, {2:N}, {3:N})\n",
				                       msg.orientation[0], msg.orientation[1], msg.orientation[2],
				                       msg.orientation[3]);
				message+=("  ranges      = [ ");
				for (int i = 0; i < msg.num_ranges; i++){
					Console.Write(" {0:D}", msg.ranges[i]);
					if (i < msg.num_ranges-1)
						Console.Write(", ");
				}
				message+=(" ]\n");
				message+=("  name         = '" + msg.name + "'\n");
				message+=("  enabled      = '" + msg.enabled + "'\n");
				Debug.Log (message);
			}
		}
Beispiel #9
0
    static public void Main(String[] args)
    {
        int a, b;

        Console.WriteLine("Enter the no. to determine the LCM: ");

        Console.Write("a: ");
        a = Int32.Parse(Console.ReadLine());
        Console.Write("b: ");
        b = Int32.Parse(Console.ReadLine());

        Console.Write("a: {0}  b: {1}\n", a, b);

        LCM obj = new LCM();
        int lcm = obj.FindLCM(a, b);

        Console.WriteLine("\nLCM of {0} and {1} = {2}\n", a, b, lcm);


        Console.ReadKey();
    }
Beispiel #10
0
 /// <summary>
 /// Analyzes the specified expression.
 /// </summary>
 /// <param name="exp">The expression.</param>
 /// <returns>The result of analysis.</returns>
 public string Analyze(LCM exp)
 {
     return(ToString(exp, "lcm"));
 }
Beispiel #11
0
        /// <summary>
        /// Creates an expression object from <see cref="FunctionToken"/>.
        /// </summary>
        /// <param name="token">The function token.</param>
        /// <returns>An expression.</returns>
        protected virtual IExpression CreateFunction(FunctionToken token)
        {
            IExpression exp;

            switch (token.Function)
            {
            case Functions.Add:
                exp = new Add(); break;

            case Functions.Sub:
                exp = new Sub(); break;

            case Functions.Mul:
                exp = new Mul(); break;

            case Functions.Div:
                exp = new Div(); break;

            case Functions.Pow:
                exp = new Pow(); break;

            case Functions.Absolute:
                exp = new Abs(); break;

            case Functions.Sine:
                exp = new Sin(); break;

            case Functions.Cosine:
                exp = new Cos(); break;

            case Functions.Tangent:
                exp = new Tan(); break;

            case Functions.Cotangent:
                exp = new Cot(); break;

            case Functions.Secant:
                exp = new Sec(); break;

            case Functions.Cosecant:
                exp = new Csc(); break;

            case Functions.Arcsine:
                exp = new Arcsin(); break;

            case Functions.Arccosine:
                exp = new Arccos(); break;

            case Functions.Arctangent:
                exp = new Arctan(); break;

            case Functions.Arccotangent:
                exp = new Arccot(); break;

            case Functions.Arcsecant:
                exp = new Arcsec(); break;

            case Functions.Arccosecant:
                exp = new Arccsc(); break;

            case Functions.Sqrt:
                exp = new Sqrt(); break;

            case Functions.Root:
                exp = new Root(); break;

            case Functions.Ln:
                exp = new Ln(); break;

            case Functions.Lg:
                exp = new Lg(); break;

            case Functions.Lb:
                exp = new Lb(); break;

            case Functions.Log:
                exp = new Log(); break;

            case Functions.Sineh:
                exp = new Sinh(); break;

            case Functions.Cosineh:
                exp = new Cosh(); break;

            case Functions.Tangenth:
                exp = new Tanh(); break;

            case Functions.Cotangenth:
                exp = new Coth(); break;

            case Functions.Secanth:
                exp = new Sech(); break;

            case Functions.Cosecanth:
                exp = new Csch(); break;

            case Functions.Arsineh:
                exp = new Arsinh(); break;

            case Functions.Arcosineh:
                exp = new Arcosh(); break;

            case Functions.Artangenth:
                exp = new Artanh(); break;

            case Functions.Arcotangenth:
                exp = new Arcoth(); break;

            case Functions.Arsecanth:
                exp = new Arsech(); break;

            case Functions.Arcosecanth:
                exp = new Arcsch(); break;

            case Functions.Exp:
                exp = new Exp(); break;

            case Functions.GCD:
                exp = new GCD(); break;

            case Functions.LCM:
                exp = new LCM(); break;

            case Functions.Factorial:
                exp = new Fact(); break;

            case Functions.Sum:
                exp = new Sum(); break;

            case Functions.Product:
                exp = new Product(); break;

            case Functions.Round:
                exp = new Round(); break;

            case Functions.Floor:
                exp = new Floor(); break;

            case Functions.Ceil:
                exp = new Ceil(); break;

            case Functions.Derivative:
                exp = new Derivative(); break;

            case Functions.Simplify:
                exp = new Simplify(); break;

            case Functions.Del:
                exp = new Del(); break;

            case Functions.Define:
                exp = new Define(); break;

            case Functions.Vector:
                exp = new Vector(); break;

            case Functions.Matrix:
                exp = new Matrix(); break;

            case Functions.Transpose:
                exp = new Transpose(); break;

            case Functions.Determinant:
                exp = new Determinant(); break;

            case Functions.Inverse:
                exp = new Inverse(); break;

            case Functions.If:
                exp = new If(); break;

            case Functions.For:
                exp = new For(); break;

            case Functions.While:
                exp = new While(); break;

            case Functions.Undefine:
                exp = new Undefine(); break;

            case Functions.Im:
                exp = new Im(); break;

            case Functions.Re:
                exp = new Re(); break;

            case Functions.Phase:
                exp = new Phase(); break;

            case Functions.Conjugate:
                exp = new Conjugate(); break;

            case Functions.Reciprocal:
                exp = new Reciprocal(); break;

            case Functions.Min:
                exp = new Min(); break;

            case Functions.Max:
                exp = new Max(); break;

            case Functions.Avg:
                exp = new Avg(); break;

            case Functions.Count:
                exp = new Count(); break;

            case Functions.Var:
                exp = new Var(); break;

            case Functions.Varp:
                exp = new Varp(); break;

            case Functions.Stdev:
                exp = new Stdev(); break;

            case Functions.Stdevp:
                exp = new Stdevp(); break;

            default:
                exp = null; break;
            }

            if (exp is DifferentParametersExpression diff)
            {
                diff.ParametersCount = token.CountOfParams;
            }

            return(exp);
        }
Beispiel #12
0
        public void LCMToStringTest()
        {
            var exp = new LCM(new Number(5), new Number(0));

            Assert.Equal("lcm(5, 0)", exp.ToString(commoonFormatter));
        }
        public override object Update()
        {
            health--;
            if (health == 0)
            {
                return(true);
            }
            if (vel[0] != 0)
            {
                //Entity.Game.DebugBreakPoint();

                float[] raw = { ((chunkX * 8) + X), ((chunkY * 8) + Y) };
                float[] dir = new float[2];
                dir[1] = 0;
                if (vel[0] > 0)
                {
                    vel[1] /= (1.25F);
                    dir[0]  = Math.Max(-0.01F + vel[0], 0);
                    vel[0]  = dir[0];
                }
                else if (vel[0] < 0)
                {
                    vel[1] /= (1.25F);
                    dir[0]  = Math.Min(0.01F + vel[0], 0);
                    vel[0]  = dir[0];
                }

                if (LCM.IsBlocking(raw))
                {
                    Entity.Game.DebugBreakPoint();

                    vel[0] = 0;
                }
                else
                {
                    LCM.MoveDir(this, dir);
                }
            }
            if (vel[1] != 0)
            {
                //Entity.Game.DebugBreakPoint();

                float[] raw = { ((chunkX * 8) + X), ((chunkY * 8) + Y) };
                float[] dir = new float[2];
                dir[0] = 0;
                if (vel[1] > 0)
                {
                    vel[1] /= (1.25F);
                    dir[1]  = Math.Max(-0.1F + vel[1], 0);
                    vel[1]  = dir[1];
                }
                else if (vel[1] < 0)
                {
                    vel[1] /= (1.25F);
                    dir[1]  = Math.Min(0.1F + vel[1], 0);
                    vel[1]  = dir[1];
                }

                if (LCM.IsBlocking(raw))
                {
                    Entity.Game.DebugBreakPoint();

                    vel[1] = 0;
                }
                else
                {
                    LCM.MoveDir(this, dir);
                }
            }
            if (bounce > 0)
            {
                Z += vel[2];
                if (Z < 0)
                {
                    Z = 0;
                    bounce--;
                    vel[2] = (bounce * 0.1F) + 0.03F;
                }
                if (vel[2] > -0.5F)
                {
                    vel[2] -= 0.08F;
                }
            }

            return(null);
        }
Beispiel #14
0
            public void MessageReceived(LCM.LCM.LCM lcm, string channel, LCM.LCM.LCMDataInputStream dins)
            {
                // 2. Ignore ENHANCED Channel message
                if (channel == "PROCESS")
                {
                    imageReady_t listen = new imageReady_t(dins);

                    //                    MessageBox.Show(listen.imageFilename);
                    lock (LockingVar)
                    {
                        // 2. pass filename, get JointX, JointY, Radius
                        //MainForm.ProcSubmit(listen.imageFilename);
                        // Publish <cx, cy, r>
                        InputFileName = listen.imageFilename;
                    }
                }
            }
Beispiel #15
0
        public void TestLCMnumber()
        {
            var exp = new LCM(new[] { new Number(10), new Number(10), new Number(10) }, 3);

            Test(exp, ResultType.Number);
        }
Beispiel #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStart_Click(object sender, EventArgs e)
        {
            //Test for
            //List<List<double>> c;
            //List<double> main = new List<double>();
            //main.Add(0); main.Add(1); main.Add(2); main.Add(3); main.Add(4);
            //CCombinationGenerator comb = new CCombinationGenerator();
            //c = comb.GenerateCombinations(main, 3);
            //return;


            double            maxLCM, LCM;
            int               noOfTasks;
            List <CPeriodSet> periods;

            if (textTasksToGen.Text.Trim() != "")
            {
                noOfTasks = Convert.ToInt32(textTasksToGen.Text);
            }
            else
            {
                noOfTasks = 100;
            }



            CConfiguration oConfig = CConfiguration.GetObject(noOfTasks,
                                                              Convert.ToInt32(textTasksPerSet.Text),
                                                              Convert.ToDouble(textMinTaskPeriod.Text),
                                                              Convert.ToDouble(textMaximumTaskPeriod.Text),
                                                              1, 10, 0, 0);
            IPeriodGenerator oPeriodGen = null;

            //Select Period Generator
            switch (comboPeriodMethod.SelectedIndex)
            {
            case 0:
                oPeriodGen = new CBoundedPeriods();
                break;

            case 1:
                oPeriodGen = new CRandomPeriods();
                break;

            case 2:
                oPeriodGen = new CAllPeriods();
                break;

            default:
                break;
            }



            //Determine maximum possible periods
            UpdateStatus("Computing Number of Period Sets ...");
            textNumberOfTaskSets.Text = oPeriodGen.GetMaximumUniquePeriodSets(oConfig).ToString();

            textNumberOfPossibleTaskSets.Text = GetMaximumPossibleSets(oConfig).ToString();

            UpdateStatus("Generating Period Sets ...");

            periods = oPeriodGen.GetPeriods(oConfig, new CSieveOfEratosthenes());

            listMain.Items.Clear();
            listMain.Items.Add("<Periods>, LCM");

            UpdateStatus("Displaying Period Sets ...");
            maxLCM = 0;

            foreach (CPeriodSet period in periods)
            {
                Application.DoEvents();
                LCM = period.GetLCM();

                if (LCM > maxLCM)
                {
                    maxLCM = LCM;
                }
                //listMain.Items.Add(period.GetPeriodString() + "," + LCM.ToString());
                listMain.Items.Add(LCM.ToString());
                if (listMain.Items.Count == oConfig.NumberOfTaskSets)
                {
                    break;
                }
            }
            textLCM.Text = maxLCM.ToString();


            UpdateStatus("Ready");
        }
Beispiel #17
0
        public void ExecuteTest2()
        {
            var exp = new LCM(new IExpression[] { new Number(4), new Number(16), new Number(8) });

            Assert.Equal(16.0, exp.Execute());
        }
Beispiel #18
0
        public void Update(Action a)
        {
            if (a == Action.move_down || a == Action.move_up || a == Action.move_left || a == Action.move_right)
            {
                moveClock = (byte)((moveClock + 1) % 64);
                if (a == Action.move_down)
                {
                    facing = EdgedAdventure.Directions.down;
                    float[] raw = new float[2];
                    raw[0] = (chunkX * 8) + X;
                    raw[1] = (chunkY * 8) + Y + movementSpeed;
                    if (!LCM.IsBlocking(raw))
                    {
                        if (Y + movementSpeed >= 8)
                        {
                            { }

                            chunkY++;
                            Y = ((Y - (8 - movementSpeed)) % 8);
                        }
                        else
                        {
                            Y += movementSpeed;
                        }
                    }
                }
                else if (a == Action.move_up)
                {
                    facing = EdgedAdventure.Directions.up;
                    float[] raw = new float[2];
                    raw[0] = (chunkX * 8) + X;
                    raw[1] = (chunkY * 8) + Y - movementSpeed;


                    if (!LCM.IsBlocking(raw))
                    {
                        if (Y - movementSpeed < 0)
                        {
                            { }

                            chunkY--;
                            Y = ((Y + (8 - movementSpeed)) % 8);
                        }
                        else
                        {
                            Y -= movementSpeed;
                        }
                    }
                }
                else if (a == Action.move_left)
                {
                    facing = EdgedAdventure.Directions.left;
                    float[] raw = new float[2];
                    raw[0] = (chunkX * 8) + X - movementSpeed;
                    raw[1] = (chunkY * 8) + Y;
                    if (!LCM.IsBlocking(raw))
                    {
                        if (X - movementSpeed < 0)
                        {
                            { }

                            chunkX--;
                            X = ((X + (8 - movementSpeed)) % 8);
                        }
                        else
                        {
                            X -= movementSpeed;
                        }
                    }
                }
                else if (a == Action.move_right)
                {
                    facing = EdgedAdventure.Directions.right;
                    float[] raw = new float[2];
                    raw[0] = (chunkX * 8) + X + movementSpeed;
                    raw[1] = (chunkY * 8) + Y;
                    if (!LCM.IsBlocking(raw))
                    {
                        if (X + movementSpeed >= 8)
                        {
                            { }

                            chunkX++;
                            X = ((X - (8 - movementSpeed)) % 8);
                        }
                        else
                        {
                            X += movementSpeed;
                        }
                    }
                }
            }
            else if (a == Action.attack)
            {
                if (energy > 0 && sel == -1)
                {
                    energy -= 40;
                    if ((0 <= moveClock && moveClock < 16) || (32 <= moveClock && moveClock < 48))
                    {
                        moveClock += 16;
                        moveClock %= 64;
                    }
                    else
                    {
                        moveClock += 32;
                        moveClock %= 64;
                    }

                    Game.DebugBreakPoint();

                    Effect slash = (Effect)Entity.GetEntity(1);
                    slash.chunkX = this.chunkX;
                    slash.chunkY = this.chunkY;
                    slash.layer  = this.layer;
                    int[] dir = DirVector(facing);
                    slash.X      = this.X + (dir[0] * 0.8F);
                    slash.Y      = this.Y + (dir[1] * 0.8F);
                    slash.health = 1;
                    slash.tile   = @"particles\slash_" + DirString(facing);
                    int[] index = LCM.GetIndices(new float[] { ((slash.chunkX * 8) + slash.X), ((slash.chunkY * 8) + slash.Y) });
                    LCM.world[index[0], index[1]].ents.Add(slash);

                    float[] raw      = { ((chunkX * 8) + slash.X), ((chunkY * 8) + slash.Y) };
                    Entity  attacked = LCM.GetAttackableEntityInRadius(raw, 0.8F);
                    if (attacked != null)
                    {
                        uint attackDamage = 1;
                        if (selItem != -1)
                        {
                            attackDamage += inv[selItem].attackBonus;
                        }
                        if (attacked.Attack(attackDamage))
                        {
                            LCM.RemoveEntity(attacked);
                        }
                    }
                    else
                    {
                        Item use = null;
                        if (selItem != -1)
                        {
                            use = inv[selItem];
                        }
                        LCM.MineAt(raw, use);
                    }
                }
            }
            else if (a == Action.test)
            {
                //Game.DebugBreakPoint();

                energy = 500;
            }

            X %= 8;
            Y %= 8;
        }
Beispiel #19
0
        public void TestLCMException()
        {
            var exp = new LCM(new ComplexNumber(10), new Number(10));

            TestDiffParamException(exp);
        }
Beispiel #20
0
        public void TestLCMEmpty()
        {
            var exp = new LCM(new IExpression[0], 0);

            Test(exp, ResultType.Undefined);
        }
Beispiel #21
0
 /// <summary>
 /// Analyzes the specified expression.
 /// </summary>
 /// <param name="exp">The expression.</param>
 /// <returns>
 /// The result of analysis.
 /// </returns>
 /// <exception cref="System.NotSupportedException">Always.</exception>
 public virtual TResult Analyze(LCM exp)
 {
     throw new NotSupportedException();
 }
Beispiel #22
0
 public void MessageReceived(LCM.LCM lcm, string channel, LCM.LCMDataInputStream dins)
 {
     Console.WriteLine("RECV: " + channel);
 }
Beispiel #23
0
        public void ExecuteTest1()
        {
            var exp = new LCM(new Number(12), new Number(16));

            Assert.Equal(48.0, exp.Execute());
        }
Beispiel #24
0
        public void TestLCMUndefined()
        {
            var exp = new LCM(new Number(10), Variable.X);

            Test(exp, ResultType.Undefined);
        }