public void TestMultiplyThrowsOverflowException() { var operation = new Multiply(); var result1 = operation.Operate(int.MaxValue, int.MaxValue); long resultExpected1 = 4611686014132420609; Assert.Equals(resultExpected1, result1); var result2 = operation.Operate(int.MaxValue, 3); long resultExpected2 = 6442450941; Assert.Equals(resultExpected2, result2); }
public override void Generate() { if (Find.Map.Biome != Util_CaveBiome.CaveBiomeDef) { // Nothing to do in other biomes. return; } NoiseRenderer.renderSize = new IntVec2(Find.Map.Size.x, Find.Map.Size.z); ModuleBase moduleBase = new Perlin(ElevationFreq, 1.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High); moduleBase = new ScaleBias(0.5, 0.5, moduleBase); NoiseDebugUI.StoreNoiseRender(moduleBase, "Cave: elev base"); moduleBase = new Multiply(moduleBase, new Const((double)ElevationFactorCave)); NoiseDebugUI.StoreNoiseRender(moduleBase, "Cave: elev cave-factored"); // Override base elevation grid so the GenStep_Terrain.Generate function uses this one. MapGenFloatGrid mapGenFloatGrid = MapGenerator.FloatGridNamed("Elevation"); foreach (IntVec3 current in Find.Map.AllCells) { mapGenFloatGrid[current] = moduleBase.GetValue(current); } }
public void Multiply_PopsTwoOperandsMultiplyEncodeAndPushBackToStack() { // Arrange var instruction = new Instruction { Type = InstructionType.Mult }; var stack = new Mock<IStack>(); stack.Setup(s => s.Pop()) .Returns(Operand); var encoder = new Mock<IEncoder>(); encoder.Setup(e => e.Encode(It.Is<Instruction>(i => i.Operand == Result && i.Type == InstructionType.Data))) .Returns(EncodedValue); var decoder = new Mock<IDecoder>(); decoder.Setup(d => d.Decode(Operand)) .Returns(new Instruction { Operand = Operand }); var alu = new Mock<IArithmeticLogicUnit>(); alu.Setup(a => a.Multiply(Operand, Operand)) .Returns(Result); var context = new ExecutionContext { Stack = stack.Object, Encoder = encoder.Object, Decoder = decoder.Object, Alu = alu.Object }; var multiplier = new Multiply(); // Act multiplier.Execute(context, instruction); // Assert stack.Verify(s => s.Pop(), Times.Exactly(2)); decoder.Verify(d => d.Decode(Operand), Times.Exactly(2)); alu.Verify(a => a.Multiply(Operand, Operand), Times.Once); encoder.Verify(e => e.Encode(It.Is<Instruction>(i => i.Operand == Result && i.Type == InstructionType.Data))); stack.Verify(s => s.Push(EncodedValue), Times.Once); }
public RandomIsland(SceneNode node, Vector2 size, Biome islandBiome, API.Geo.World currentWorld) : base(node, size, currentWorld) { this.mBiome = islandBiome; ELEVATION.setFrequency(0.2); ELEVATION.setLacunarity(1); ELEVATION.setNoiseQuality(NoiseQuality.STANDARD); ELEVATION.setPersistence(0.7); ELEVATION.setOctaveCount(1); DETAIL.setFrequency(0.7); DETAIL.setLacunarity(1); DETAIL.setNoiseQuality(NoiseQuality.STANDARD); DETAIL.setPersistence(0.7); DETAIL.setOctaveCount(1); Multiply multiply = new Multiply(); multiply.SetSourceModule(0, ROUGHNESS); multiply.SetSourceModule(1, DETAIL); Add add = new Add(); add.SetSourceModule(0, multiply); add.SetSourceModule(1, ELEVATION); SCALE.SetSourceModule(0, add); SCALE.setxScale(0.03); SCALE.setyScale(0.06); SCALE.setzScale(0.03); TURBULENCE.SetSourceModule(0, SCALE); TURBULENCE.setFrequency(0.01); TURBULENCE.setPower(6); TURBULENCE.setRoughness(1); FINAL.SetSourceModule(0, SCALE); FINAL.setLowerBound(-1); FINAL.setUpperBound(1); this.generate(42); }
public void Multiply_GENDATA_Test1() { var tileSize = 30; var blockMatrix1 = MatrixHelpers.Tile(Matrix<double>.CreateNewRandomDoubleMatrix(200, 200), tileSize); var blockMatrix2 = MatrixHelpers.Tile(Matrix<double>.CreateNewRandomDoubleMatrix(200, 200), tileSize); var clonedBlockMatrix1 = blockMatrix1.Clone(); var clonedBlockMatrix2 = blockMatrix2.Clone(); var opData1 = new OperationResult<double>(blockMatrix1); var opData2 = new OperationResult<double>(blockMatrix2); Matrix<Matrix<double>> expected = clonedBlockMatrix1 * clonedBlockMatrix2; OperationResult<double> actual; var mProducer = new Multiply<double>(opData1, opData2, out actual); var pm = new Manager(mProducer); pm.Start(); pm.Join(); MatrixHelpers.IsDone(actual); MatrixHelpers.Diff(expected, actual.Data); MatrixHelpers.Compare(expected, actual.Data); }
public bool Equals(ValueAdjustment other) { return(Add.Equals(other.Add) && Multiply.Equals(other.Multiply)); }
protected override IEnumerable <BaseStatement> Visit(Multiply mul) => Binary(mul, (a, b) => new Multiply(a, b));
public IXEP_EmdElement CreateEmdElement() { IXEP_EmdElement elemEmd = XEP_EmdFactrory.CreateEmdElement(); elemEmd.Name = XEP_EmdNames.s_KeyStirrup; // elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyStirrupDX, DX.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyStirrupD, D.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyStirrupMultiply, Multiply.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyStirrupDsL, DsL.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyStirrupDsR, DsR.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyStirrupDss, Dss.ToString())); return(elemEmd); }
[NotNull] protected virtual BaseExpression Visit([NotNull] Multiply mul) { return(new Multiply(Visit(mul.Left), Visit(mul.Right))); }
public override void Generate(Map map, GenStepParams parms) { NoiseRenderer.renderSize = new IntVec2(map.Size.x, map.Size.z); ModuleBase moduleBase = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High); moduleBase = new ScaleBias(0.5, 0.5, moduleBase); NoiseDebugUI.StoreNoiseRender(moduleBase, "elev base"); float num = 1f; switch (map.TileInfo.hilliness) { case Hilliness.Flat: num = MapGenTuning.ElevationFactorFlat; break; case Hilliness.SmallHills: num = MapGenTuning.ElevationFactorSmallHills; break; case Hilliness.LargeHills: num = MapGenTuning.ElevationFactorLargeHills; break; case Hilliness.Mountainous: num = MapGenTuning.ElevationFactorMountains; break; case Hilliness.Impassable: num = MapGenTuning.ElevationFactorImpassableMountains; break; } moduleBase = new Multiply(moduleBase, new Const((double)num)); NoiseDebugUI.StoreNoiseRender(moduleBase, "elev world-factored"); if (map.TileInfo.hilliness == Hilliness.Mountainous || map.TileInfo.hilliness == Hilliness.Impassable) { ModuleBase moduleBase2 = new DistFromAxis((float)map.Size.x * 0.42f); moduleBase2 = new Clamp(0.0, 1.0, moduleBase2); moduleBase2 = new Invert(moduleBase2); moduleBase2 = new ScaleBias(1.0, 1.0, moduleBase2); Rot4 random; do { random = Rot4.Random; }while (random == Find.World.CoastDirectionAt(map.Tile)); if (random == Rot4.North) { moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2); moduleBase2 = new Translate(0.0, 0.0, (double)(-(double)map.Size.z), moduleBase2); } else if (random == Rot4.East) { moduleBase2 = new Translate((double)(-(double)map.Size.x), 0.0, 0.0, moduleBase2); } else if (random == Rot4.South) { moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2); } else if (random == Rot4.West) { } NoiseDebugUI.StoreNoiseRender(moduleBase2, "mountain"); moduleBase = new Add(moduleBase, moduleBase2); NoiseDebugUI.StoreNoiseRender(moduleBase, "elev + mountain"); } float b = (!map.TileInfo.WaterCovered) ? 3.40282347E+38f : 0f; MapGenFloatGrid elevation = MapGenerator.Elevation; foreach (IntVec3 current in map.AllCells) { elevation[current] = Mathf.Min(moduleBase.GetValue(current), b); } ModuleBase moduleBase3 = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High); moduleBase3 = new ScaleBias(0.5, 0.5, moduleBase3); NoiseDebugUI.StoreNoiseRender(moduleBase3, "noiseFert base"); MapGenFloatGrid fertility = MapGenerator.Fertility; foreach (IntVec3 current2 in map.AllCells) { fertility[current2] = moduleBase3.GetValue(current2); } }
private IEnumerable <IElement> EvaluateSingleGroupExpression(string input) { var singleGroupExpression = input; var resultSets = new List <IElement>(); var pPattern = @"\([\d\sa-z\+\*]+\)"; var parenthesisExpressions = new Regex(pPattern).Matches(singleGroupExpression); // (.. + ..) detection to cross-multiply them each other. var prevSets = new List <IElement>(); foreach (Match parenthesisExpression in parenthesisExpressions) { var currentSets = new List <IElement>(); if (parenthesisExpression.ToString().Contains("+")) { currentSets.AddRange(parenthesisExpression.ToString() .Trim(new char[] { '(', ')' }) .Split("+") .Select(x => new Element(x))); } if (prevSets.Count > 0) { // only for two sets for (var i = 0; i < prevSets.Count; i++) { for (var j = 0; j < currentSets.Count; j++) { var calSets = new List <IElement> { prevSets[i], currentSets[j] }; // resultSets.Add(new Element(new Multiply(new IElement[] {prevSets[i], prevSets[j]}))); var multiply = new Multiply(calSets); resultSets.Add(new Element(multiply.Evaluate())); } } } else { // prevSets = currentSets.Select(x => new Element(x.Evaluate())); foreach (var currentSet in currentSets) { prevSets.Add(new Element(currentSet.Evaluate())); } } } // do cross-multiplying if '*' connected with ()s var withoutParenthesesExpression = singleGroupExpression; foreach (Match parenthesisExpression in parenthesisExpressions) { withoutParenthesesExpression = withoutParenthesesExpression.Replace(parenthesisExpression.ToString(), ""); } // '*' connection with ()s and do multiply them if (withoutParenthesesExpression.Contains("*")) { var elements = withoutParenthesesExpression .Split("*") .Select(x => new Element(x)); var otherMultiply = new Multiply(elements); var simplifiedMultiply = otherMultiply.Evaluate(); if (simplifiedMultiply != string.Empty && prevSets.Count > 0) { // only for two sets for (var i = 0; i < prevSets.Count; i++) { var calSets = new List <IElement> { prevSets[i], new Element(simplifiedMultiply) }; // resultSets.Add(new Element(new Multiply(new IElement[] {prevSets[i], prevSets[j]}))); var multiply = new Multiply(calSets); resultSets.Add(new Element(multiply.Evaluate())); } } else { resultSets.Add(new Element(simplifiedMultiply)); } } else // it's single parentheses { // (.. + ..) single case resultSets = prevSets; // (.. * ..) all multyply case if (resultSets.Count == 0) { var elements = singleGroupExpression.Trim(new char[] { '(', ')' }) .Split("*") .Select(x => new Element(x)); var multiply = new Multiply(elements); resultSets.Add(new Element(multiply.Evaluate())); } } return(resultSets); }
public object CalculateParam(ParleyEnviromentInfo info) { if (paramaters==null || paramaters.Length==0){ return null; } if (paramaters.Length==1 && paramaters[0].StartsWith("\"")){ return paramaters[0].Substring(1,paramaters[0].Length-2); } Stack<float> values=new Stack<float>(); Stack<Operator> operators=new Stack<Operator>(); bool lastWasTerm=false; bool nextTermFlip=false; foreach (string p in paramaters){ bool term="+-*/".IndexOf(p)==-1; if (term){ float v=0; if ("0123456789".IndexOf(p.Substring(0,1))!=-1){ v=float.Parse(p); }else{ object o=info.GetEnviromentInfo(p); if (o==null){ Debug.LogWarning("Parley could not find the term <"+term+"> from the Enviroment. Substituting 0"); v=0; }else{ v=float.Parse(o.ToString()); } } if (nextTermFlip){ values.Push(-v); }else{ values.Push(v); } nextTermFlip=false; lastWasTerm=true; }else{ if (lastWasTerm){ Operator o=null; if ("+".Equals(p)){ o=new Add(); } else if ("-".Equals(p)){ o=new Subtract(); } else if ("*".Equals(p)){ o=new Multiply(); } else if ("/".Equals(p)){ o=new Divide(); } while (operators.Count>0 && o.weight>operators.Peek().weight){ operators.Pop().Execute(values); } operators.Push(o); }else{ // Change sign on next term if ("-".Equals(p)){ nextTermFlip=true; } } lastWasTerm=false; } } while (operators.Count>0){ operators.Pop().Execute(values); } return values.Pop(); }
// Generates references to each type of powerup object public static void GenerateAllPowerups () { if (PowerUps == null) { //initializes the array PowerUps = new PowerUp[GlobalVars.POWERUP_COUNT]; //the array of all possible PowerUps the spawned PowerUp could be PowerUps[0] = new LaneConversion(durationLaneConversion); PowerUps[1] = new SlowFall(fallSpeedModifierSlowFall,timeBonusSlowFall,durationSlowFall); PowerUps[2] = new Fuel(timeBonusAddTime) ; PowerUps[3] = new Multiply(multiplierElementMultiply); PowerUps[4] = new BucketShield(bucketShieldHitPoints); PowerUps[5] = new TapToCollect(durationTapToCollect); PowerUps[6] = new Invincible(durationInvincible, spawnRateModifierInvincible); PowerUps[7] = new TotalConversion(durationTotalConversion); PowerUps[8] = new CollectAll(); } }
protected override BaseExpression Visit(Multiply mul) { using (AppendLine("*")) return(base.Visit(mul)); }
public static IEnumerable<Measurement> Multiply() { foreach (int threadCount in ThreadCountGenerator()) foreach (int tileSize in TileSizeGenerator) yield return new TwoBlockMatrixMeasurement { TileSize = tileSize, ThreadCount = threadCount, Execute = (a, b, tc) => { var opRes1 = new OperationResult<double>(a); var opRes2 = new OperationResult<double>(b); OperationResult<double> actual; var producer = new Multiply<double>(opRes1, opRes2, out actual); Runner(producer, tc); } }; }
public OverworldNoise(int seed) { generatorSettings = new OverworldTerrainSettings() { Seed = seed }; generator = new OverworldTerrainGenerator(generatorSettings); generatorModule = generator.CreateModule(); cavePerlin = new Simplex { Frequency = 1.14, Lacunarity = 2.0, OctaveCount = 2, Persistence = 1.53 }; coalNoise = new Multiply { Source0 = new Checkerboard(), Source1 = new Perlin { Frequency = 1.14, Lacunarity = 2.222, Seed = generatorSettings.Seed } }; BiomeNoise = new Turbulence() { Frequency = 43.25, Power = 0.01, Roughness = 6, Seed = generatorSettings.Seed + 100, Source0 = new Add() { Source0 = new Clamp() { UpperBound = 2, LowerBound = -0.1, Source0 = new Billow() { Seed = generatorSettings.Seed + 101, Frequency = 43.25, Lacunarity = generatorSettings.ContinentLacunarity, OctaveCount = 1, Quality = NoiseQuality.Fast, } }, Source1 = new Clamp() { UpperBound = 0.1, LowerBound = -2, Source0 = new Invert() { Source0 = new Billow() { Seed = generatorSettings.Seed + 102, Frequency = 43.25, Lacunarity = generatorSettings.ContinentLacunarity, OctaveCount = 1, Quality = NoiseQuality.Fast, } } } } }; BiomeHumidity = new Turbulence() { Frequency = 47.25, Power = 0.01, Roughness = 6, Seed = generatorSettings.Seed + 103, Source0 = new Add() { Source0 = new Clamp() { UpperBound = 2, LowerBound = -0.1, Source0 = new Billow() { Seed = generatorSettings.Seed + 104, Frequency = 47.25, Lacunarity = generatorSettings.ContinentLacunarity, OctaveCount = 1, Quality = NoiseQuality.Fast, } }, Source1 = new Clamp() { UpperBound = 0.1, LowerBound = -2, Source0 = new Invert() { Source0 = new Billow() { Seed = generatorSettings.Seed + 105, Frequency = 47.25, Lacunarity = generatorSettings.ContinentLacunarity, OctaveCount = 1, Quality = NoiseQuality.Fast, } } } } }; }
public void GivenAMultiplyExpression_WhenInspectIsCalled_ThenTheOperandsAreReturnedInQuotes() { var multiply = new Multiply(new Number(2), new Number(14)); multiply.Inspect().Should().Be("«2 * 14»"); }
protected MultiplyTests() { TestedInstruction = new Multiply(); }
private void MultiplyButtonClick(object sender, EventArgs e) { InitializeNumbers(); Multiply.Invoke(sender, e); }
public void Multiply_1500x1500() { var tileSize = 40; // prepare data var data1 = MatrixHelpers.Tile(Matrix<double>.DeSerializeFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\m1500x1500-a.mat"), tileSize); var data2 = MatrixHelpers.Tile(Matrix<double>.DeSerializeFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\m1500x1500-b.mat"), tileSize); Matrix<Matrix<double>> expected = MatrixHelpers.Tile(Matrix<double>.DeSerializeFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\m1500x1500-a_b-Multiply-result.mat"), tileSize); var opData1 = new OperationResult<double>(data1); var opData2 = new OperationResult<double>(data2); OperationResult<double> actual; var mProducer = new Multiply<double>(opData1, opData2, out actual); var pm = new Manager(mProducer); pm.Start(); pm.Join(); MatrixHelpers.IsDone(actual); MatrixHelpers.Diff(expected, actual.Data); MatrixHelpers.Compare(expected, actual.Data); }
DEFINE_STANDARD_OP(Multiply, MULTIPLY)
// Token: 0x0600003D RID: 61 RVA: 0x000033A0 File Offset: 0x000015A0 public override void Generate(Map map, GenStepParams parms) { NoiseRenderer.renderSize = new IntVec2(map.Size.x, map.Size.z); ModuleBase moduleBase = new Perlin(0.0209999997168779, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High); moduleBase = new ScaleBias(0.5, 0.5, moduleBase); NoiseDebugUI.StoreNoiseRender(moduleBase, "elev base"); float num = 1.8f; moduleBase = new Multiply(moduleBase, new Const((double)num)); NoiseDebugUI.StoreNoiseRender(moduleBase, "elev world-factored"); ModuleBase moduleBase2 = new DistFromAxis((float)map.Size.x * 0.42f); moduleBase2 = new Clamp(0.0, 1.0, moduleBase2); moduleBase2 = new Invert(moduleBase2); moduleBase2 = new ScaleBias(1.0, 1.0, moduleBase2); Rot4 random; do { random = Rot4.Random; }while (random == Find.World.CoastDirectionAt(map.Tile)); bool flag = random == Rot4.North; if (flag) { moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2); moduleBase2 = new Translate(0.0, 0.0, -(double)map.Size.z, moduleBase2); } else { bool flag2 = random == Rot4.East; if (flag2) { moduleBase2 = new Translate(-(double)map.Size.x, 0.0, 0.0, moduleBase2); } else { bool flag3 = random == Rot4.South; if (flag3) { moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2); } else { bool flag4 = random == Rot4.West; if (flag4) { } } } } NoiseDebugUI.StoreNoiseRender(moduleBase2, "mountain"); moduleBase = new Add(moduleBase, moduleBase2); NoiseDebugUI.StoreNoiseRender(moduleBase, "elev + mountain"); float num2 = (!map.TileInfo.WaterCovered) ? 3.402823E+38f : 0f; MapGenFloatGrid elevation = MapGenerator.Elevation; foreach (IntVec3 intVec in map.AllCells) { elevation[intVec] = Mathf.Min(moduleBase.GetValue(intVec), num2); } MapGenFloatGrid fertility = MapGenerator.Fertility; foreach (IntVec3 c in map.AllCells) { fertility[c] = 0f; } }
public void TestMultiplyExpects32() { var operation = new Multiply(); var result = operation.Operate(-4, -8); Assert.AreEqual(result, 32); }
public static ParamLessInstruction GetInstructionForOperator( string operatorVal, bool twoArg = true, DatSymbolType leftSideType = DatSymbolType.Void) { ParamLessInstruction instruction = new ParamLessInstruction(); switch (operatorVal) { case "=": instruction = GetAssignInstructionForDatSymbolType(leftSideType); break; case "+=": instruction = new AssignAdd(); break; case "-=": instruction = new AssignSubtract(); break; case "*=": instruction = new AssignMultiply(); break; case "/=": instruction = new AssignDivide(); break; case "+": if (twoArg) { instruction = new Add(); } else { instruction = new Plus(); } break; case "-": if (twoArg) { instruction = new Subtract(); } else { instruction = new Minus(); } break; case "<<": instruction = new ShiftLeft(); break; case ">>": instruction = new ShiftRight(); break; case ">": instruction = new Greater(); break; case ">=": instruction = new GreaterOrEqual(); break; case "<": instruction = new Less(); break; case "<=": instruction = new LessOrEqual(); break; case "==": instruction = new Equal(); break; case "!=": instruction = new NotEqual(); break; case "!": instruction = new Not(); break; case "~": instruction = new Negate(); break; case "*": instruction = new Multiply(); break; case "/": instruction = new Divide(); break; case "%": instruction = new Modulo(); break; case "&": instruction = new BitAnd(); break; case "|": instruction = new BitOr(); break; case "&&": instruction = new LogAnd(); break; case "||": instruction = new LogOr(); break; } if (instruction == null) { throw new Exception($"'{operatorVal}' does't have insctruction"); } return(instruction); }
/// <summary> /// Creates an Multiply command if one has not been allocated. /// </summary> /// <returns> /// Returns an allocated Multiply command. /// </returns> public override Multiply createMultiplyCommand() { if (multiply == null) { multiply = new Multiply(); }// end if return new Multiply(); }
// Create Tree from file. private TreeElement CreateTreeFromFile (System.IO.StreamReader file, TreeElement treeElement) { int value = 0; TreeElement left = null; TreeElement right = null; if (file.EndOfStream) return treeElement; int ch = file.Read(); // '(' или цифра или ' ' if (ch == ' ') ch = file.Read(); // '(' или цифра if (ch == '(') { ch = file.Read(); // ' ' if (ch != ' ') throw new ExceptionTree("Waiting ' '."); ch = file.Read(); // sign if (ch != '+' && ch != '-' && ch != '*' && ch != '/') throw new ExceptionTree("Waiting sign."); value = ch; ch = file.Read(); // ' ' if (ch != ' ') throw new ExceptionTree("Waiting ' '."); left = CreateTreeFromFile(file, left); right = CreateTreeFromFile(file, right); if (value == '+') treeElement = new Add(value, left, right); if (value == '-') treeElement = new Subtract(value, left, right); if (value == '*') treeElement = new Multiply(value, left, right); if (value == '/') treeElement = new Divide(value, left, right); ch = file.Read(); // ')' или ' ' if (ch == ' ') ch = file.Read(); // ')' if (ch != ')') throw new ExceptionTree("Waiting )."); /* ch = file.Read(); // ' ' if (ch != ' ') throw new ExceptionTree("Waiting ' '."); */ } else if (ch <= '9' && ch >= '0') { int number = 0; while (ch <= '9' && ch >= '0') { number = number * 10 + ch - '0'; ch = file.Read(); } if (ch != ' ') throw new ExceptionTree("Waiting ' '."); value = number; treeElement = new Value(value); } else throw new ExceptionTree("Waiting '(' or number."); return treeElement; }
protected override IDataFlowGraphExpressionNode Visit(Multiply mul) => VisitBinary(mul, YololBinaryOp.Multiply);
public void Execute(Multiply cmd) { _file.WriteLine($"{_indents}Multiply\tOp1:{cmd.Op1.Name},Op2:{cmd.Op2.Name},Result:{cmd.Result.Name}"); }
public void Visit(Multiply n) { Globals.Builder.Start($"multiply (*) [{n.Location.StartLine}, {n.Location.StartColumn}]"); WriteBinaryExpression("imul", n.LeftExpression, n.RightExpression); Globals.Builder.End($"multiply (*) [{n.Location.EndLine}, {n.Location.EndColumn}]"); }
public override void Generate(Map map) { IntVec3 size = map.Size; int x = size.x; IntVec3 size2 = map.Size; NoiseRenderer.renderSize = new IntVec2(x, size2.z); ModuleBase input = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High); input = new ScaleBias(0.5, 0.5, input); NoiseDebugUI.StoreNoiseRender(input, "elev base"); float num = 1f; switch (map.TileInfo.hilliness) { case Hilliness.Flat: num = MapGenTuning.ElevationFactorFlat; break; case Hilliness.SmallHills: num = MapGenTuning.ElevationFactorSmallHills; break; case Hilliness.LargeHills: num = MapGenTuning.ElevationFactorLargeHills; break; case Hilliness.Mountainous: num = MapGenTuning.ElevationFactorMountains; break; case Hilliness.Impassable: num = MapGenTuning.ElevationFactorImpassableMountains; break; } input = new Multiply(input, new Const((double)num)); NoiseDebugUI.StoreNoiseRender(input, "elev world-factored"); if (map.TileInfo.hilliness != Hilliness.Mountainous && map.TileInfo.hilliness != Hilliness.Impassable) { goto IL_02b1; } IntVec3 size3 = map.Size; ModuleBase input2 = new DistFromAxis((float)((float)size3.x * 0.41999998688697815)); input2 = new Clamp(0.0, 1.0, input2); input2 = new Invert(input2); input2 = new ScaleBias(1.0, 1.0, input2); Rot4 random; while (true) { random = Rot4.Random; if (!(random == Find.World.CoastDirectionAt(map.Tile))) { break; } } if (random == Rot4.North) { input2 = new Rotate(0.0, 90.0, 0.0, input2); IntVec3 size4 = map.Size; input2 = new Translate(0.0, 0.0, (double)(-size4.z), input2); } else if (random == Rot4.East) { IntVec3 size5 = map.Size; input2 = new Translate((double)(-size5.x), 0.0, 0.0, input2); } else if (random == Rot4.South) { input2 = new Rotate(0.0, 90.0, 0.0, input2); } else if (!(random == Rot4.West)) { goto IL_0291; } goto IL_0291; IL_0291: NoiseDebugUI.StoreNoiseRender(input2, "mountain"); input = new Add(input, input2); NoiseDebugUI.StoreNoiseRender(input, "elev + mountain"); goto IL_02b1; IL_02b1: float b = (float)((!map.TileInfo.WaterCovered) ? 3.4028234663852886E+38 : 0.0); MapGenFloatGrid elevation = MapGenerator.Elevation; foreach (IntVec3 allCell in map.AllCells) { elevation[allCell] = Mathf.Min(input.GetValue(allCell), b); } ModuleBase input3 = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High); input3 = new ScaleBias(0.5, 0.5, input3); NoiseDebugUI.StoreNoiseRender(input3, "noiseFert base"); MapGenFloatGrid fertility = MapGenerator.Fertility; foreach (IntVec3 allCell2 in map.AllCells) { fertility[allCell2] = input3.GetValue(allCell2); } }
public virtual bool Visit(Multiply multiply) { return(true); }
public virtual T Visit(Multiply multiply) { return(VisitBinaryExpression(multiply)); }
public static InstructionCollection Parse(Stream input, long instructionsPosition) { var instructions = new SortedList <int, InstructionBase>(); using (var helper = new InstructionParseHelper(input, instructionsPosition)) { var reader = helper.GetReader(); while (helper.CanParse(instructions)) { //now reader the instructions var instructionPosition = helper.CurrentPosition; var type = reader.ReadByteAsEnum <InstructionType>(); var requireAlignment = InstructionAlignment.IsAligned(type); if (requireAlignment) { reader.Align(4); } InstructionBase instruction = null; var parameters = new List <Value>(); switch (type) { case InstructionType.ToNumber: instruction = new ToNumber(); break; case InstructionType.NextFrame: instruction = new NextFrame(); break; case InstructionType.Play: instruction = new Play(); break; case InstructionType.Stop: instruction = new Stop(); break; case InstructionType.Add: instruction = new Add(); break; case InstructionType.Subtract: instruction = new Subtract(); break; case InstructionType.Multiply: instruction = new Multiply(); break; case InstructionType.Divide: instruction = new Divide(); break; case InstructionType.Not: instruction = new Not(); break; case InstructionType.StringEquals: instruction = new StringEquals(); break; case InstructionType.Pop: instruction = new Pop(); break; case InstructionType.ToInteger: instruction = new ToInteger(); break; case InstructionType.GetVariable: instruction = new GetVariable(); break; case InstructionType.SetVariable: instruction = new SetVariable(); break; case InstructionType.StringConcat: instruction = new StringConcat(); break; case InstructionType.GetProperty: instruction = new GetProperty(); break; case InstructionType.SetProperty: instruction = new SetProperty(); break; case InstructionType.Trace: instruction = new Trace(); break; case InstructionType.Random: instruction = new RandomNumber(); break; case InstructionType.Delete: instruction = new Delete(); break; case InstructionType.Delete2: instruction = new Delete2(); break; case InstructionType.DefineLocal: instruction = new DefineLocal(); break; case InstructionType.CallFunction: instruction = new CallFunction(); break; case InstructionType.Return: instruction = new Return(); break; case InstructionType.Modulo: instruction = new Modulo(); break; case InstructionType.NewObject: instruction = new NewObject(); break; case InstructionType.InitArray: instruction = new InitArray(); break; case InstructionType.InitObject: instruction = new InitObject(); break; case InstructionType.TypeOf: instruction = new TypeOf(); break; case InstructionType.Add2: instruction = new Add2(); break; case InstructionType.LessThan2: instruction = new LessThan2(); break; case InstructionType.Equals2: instruction = new Equals2(); break; case InstructionType.ToString: instruction = new ToString(); break; case InstructionType.PushDuplicate: instruction = new PushDuplicate(); break; case InstructionType.GetMember: instruction = new GetMember(); break; case InstructionType.SetMember: instruction = new SetMember(); break; case InstructionType.Increment: instruction = new Increment(); break; case InstructionType.Decrement: instruction = new Decrement(); break; case InstructionType.CallMethod: instruction = new CallMethod(); break; case InstructionType.Enumerate2: instruction = new Enumerate2(); break; case InstructionType.EA_PushThis: instruction = new PushThis(); break; case InstructionType.EA_PushZero: instruction = new PushZero(); break; case InstructionType.EA_PushOne: instruction = new PushOne(); break; case InstructionType.EA_CallFunc: instruction = new CallFunc(); break; case InstructionType.EA_CallMethodPop: instruction = new CallMethodPop(); break; case InstructionType.BitwiseXOr: instruction = new BitwiseXOr(); break; case InstructionType.Greater: instruction = new Greater(); break; case InstructionType.EA_PushThisVar: instruction = new PushThisVar(); break; case InstructionType.EA_PushGlobalVar: instruction = new PushGlobalVar(); break; case InstructionType.EA_ZeroVar: instruction = new ZeroVar(); break; case InstructionType.EA_PushTrue: instruction = new PushTrue(); break; case InstructionType.EA_PushFalse: instruction = new PushFalse(); break; case InstructionType.EA_PushNull: instruction = new PushNull(); break; case InstructionType.EA_PushUndefined: instruction = new PushUndefined(); break; case InstructionType.GotoFrame: instruction = new GotoFrame(); parameters.Add(Value.FromInteger(reader.ReadInt32())); break; case InstructionType.GetURL: instruction = new GetUrl(); parameters.Add(Value.FromString(reader.ReadStringAtOffset())); parameters.Add(Value.FromString(reader.ReadStringAtOffset())); break; case InstructionType.SetRegister: instruction = new SetRegister(); parameters.Add(Value.FromInteger(reader.ReadInt32())); break; case InstructionType.ConstantPool: { instruction = new ConstantPool(); var count = reader.ReadUInt32(); var constants = reader.ReadFixedSizeArrayAtOffset <uint>(() => reader.ReadUInt32(), count); foreach (var constant in constants) { parameters.Add(Value.FromConstant(constant)); } } break; case InstructionType.GotoLabel: instruction = new GotoLabel(); parameters.Add(Value.FromString(reader.ReadStringAtOffset())); break; case InstructionType.DefineFunction2: { instruction = new DefineFunction2(); var name = reader.ReadStringAtOffset(); var nParams = reader.ReadUInt32(); var nRegisters = reader.ReadByte(); var flags = reader.ReadUInt24(); //list of parameter strings var paramList = reader.ReadFixedSizeListAtOffset <FunctionArgument>(() => new FunctionArgument() { Register = reader.ReadInt32(), Parameter = reader.ReadStringAtOffset(), }, nParams); parameters.Add(Value.FromString(name)); parameters.Add(Value.FromInteger((int)nParams)); parameters.Add(Value.FromInteger((int)nRegisters)); parameters.Add(Value.FromInteger((int)flags)); foreach (var param in paramList) { parameters.Add(Value.FromInteger(param.Register)); parameters.Add(Value.FromString(param.Parameter)); } //body size of the function parameters.Add(Value.FromInteger(reader.ReadInt32())); //skip 8 bytes reader.ReadUInt64(); } break; case InstructionType.PushData: { instruction = new PushData(); var count = reader.ReadUInt32(); var constants = reader.ReadFixedSizeArrayAtOffset <uint>(() => reader.ReadUInt32(), count); foreach (var constant in constants) { parameters.Add(Value.FromConstant(constant)); } } break; case InstructionType.BranchAlways: { instruction = new BranchAlways(); var offset = reader.ReadInt32(); parameters.Add(Value.FromInteger(offset)); helper.ReportBranchOffset(offset); } break; case InstructionType.GetURL2: instruction = new GetUrl2(); break; case InstructionType.DefineFunction: { instruction = new DefineFunction(); var name = reader.ReadStringAtOffset(); //list of parameter strings var paramList = reader.ReadListAtOffset <string>(() => reader.ReadStringAtOffset()); parameters.Add(Value.FromString(name)); parameters.Add(Value.FromInteger(paramList.Count)); foreach (var param in paramList) { parameters.Add(Value.FromString(param)); } //body size of the function parameters.Add(Value.FromInteger(reader.ReadInt32())); //skip 8 bytes reader.ReadUInt64(); } break; case InstructionType.BranchIfTrue: { instruction = new BranchIfTrue(); var offset = reader.ReadInt32(); parameters.Add(Value.FromInteger(offset)); helper.ReportBranchOffset(offset); } break; case InstructionType.GotoFrame2: instruction = new GotoFrame2(); parameters.Add(Value.FromInteger(reader.ReadInt32())); break; case InstructionType.EA_PushString: instruction = new PushString(); //the constant id that should be pushed parameters.Add(Value.FromString(reader.ReadStringAtOffset())); break; case InstructionType.EA_PushConstantByte: instruction = new PushConstantByte(); //the constant id that should be pushed parameters.Add(Value.FromConstant(reader.ReadByte())); break; case InstructionType.EA_GetStringVar: instruction = new GetStringVar(); parameters.Add(Value.FromString(reader.ReadStringAtOffset())); break; case InstructionType.EA_SetStringVar: instruction = new SetStringVar(); parameters.Add(Value.FromString(reader.ReadStringAtOffset())); break; case InstructionType.EA_GetStringMember: instruction = new GetStringMember(); parameters.Add(Value.FromString(reader.ReadStringAtOffset())); break; case InstructionType.EA_SetStringMember: instruction = new SetStringMember(); parameters.Add(Value.FromString(reader.ReadStringAtOffset())); break; case InstructionType.EA_PushValueOfVar: instruction = new PushValueOfVar(); //the constant id that should be pushed parameters.Add(Value.FromConstant(reader.ReadByte())); break; case InstructionType.EA_GetNamedMember: instruction = new GetNamedMember(); parameters.Add(Value.FromConstant(reader.ReadByte())); break; case InstructionType.EA_CallNamedFuncPop: instruction = new CallNamedFuncPop(); parameters.Add(Value.FromConstant(reader.ReadByte())); break; case InstructionType.EA_CallNamedFunc: instruction = new CallNamedFunc(); parameters.Add(Value.FromConstant(reader.ReadByte())); break; case InstructionType.EA_CallNamedMethodPop: instruction = new CallNamedMethodPop(); parameters.Add(Value.FromConstant(reader.ReadByte())); break; case InstructionType.EA_PushFloat: instruction = new PushFloat(); parameters.Add(Value.FromFloat(reader.ReadSingle())); break; case InstructionType.EA_PushByte: instruction = new PushByte(); parameters.Add(Value.FromInteger(reader.ReadByte())); break; case InstructionType.EA_PushShort: instruction = new PushShort(); parameters.Add(Value.FromInteger(reader.ReadUInt16())); break; case InstructionType.End: instruction = new End(); break; case InstructionType.EA_CallNamedMethod: instruction = new CallNamedMethod(); parameters.Add(Value.FromConstant(reader.ReadByte())); break; case InstructionType.Var: instruction = new Var(); break; case InstructionType.EA_PushRegister: instruction = new PushRegister(); parameters.Add(Value.FromInteger(reader.ReadByte())); break; case InstructionType.EA_PushConstantWord: instruction = new PushConstantWord(); parameters.Add(Value.FromConstant(reader.ReadUInt16())); break; case InstructionType.EA_CallFuncPop: instruction = new CallFunctionPop(); break; case InstructionType.StrictEqual: instruction = new StrictEquals(); break; default: throw new InvalidDataException("Unimplemented bytecode instruction:" + type.ToString()); } if (instruction != null) { instruction.Parameters = parameters; instructions.Add(instructionPosition, instruction); } } } return(new InstructionCollection(instructions)); }
void Generate() { // { Perlin, Billow, RidgedMultifractal, Voronoi, Checker, Const, Cylinders, Spheres }; for (int n = 0; n <= 1; n++) { switch ((NoiseType)selectionGridInt[n]) { case NoiseType.Perlin: moduleBases[n] = new Perlin(n_freq[n], n_lacun[n], n_persist[n], n_octaves[n], n, QualityMode.Medium); break; case NoiseType.Billow: moduleBases[n] = new Billow(n_freq[n], n_lacun[n], n_persist[n], n_octaves[n], n, QualityMode.Medium); break; case NoiseType.RidgedMultifractal: moduleBases[n] = new RidgedMultifractal(n_freq[n], n_lacun[n], n_octaves[n], n, QualityMode.Medium); break; case NoiseType.Voronoi: moduleBases[n] = new Voronoi(n_freq[n], n_displaces[n], n, n_distance[n]); break; case NoiseType.Checker: moduleBases[n] = new Checker(); break; case NoiseType.Const: moduleBases[n] = new Const(n_freq[n]); break; case NoiseType.Cylinders: moduleBases[n] = new Cylinders(n_freq[n]); break; case NoiseType.Spheres: moduleBases[n] = new Spheres(n_freq[n]); break; } } ModuleBase moduleBase = new Const(); // { "Add", "Blend", "Max", "Min", "Multiply", "Power", "Select", "Subtract", "Terrace"}; switch (operatorGridInt) { case 0: moduleBase = new Add(moduleBases[0], moduleBases[1]); break; case 1: moduleBase = new Blend(moduleBases[0], moduleBases[1], new Perlin()); break; case 2: moduleBase = new Max(moduleBases[0], moduleBases[1]); break; case 3: moduleBase = new Min(moduleBases[0], moduleBases[1]); break; case 4: moduleBase = new Multiply(moduleBases[0], moduleBases[1]); break; case 5: moduleBase = new Power(moduleBases[0], moduleBases[1]); break; case 6: moduleBase = new Subtract(moduleBases[0], moduleBases[1]); break; case 7: moduleBase = new Terrace(false, moduleBases[0]); break; case 8: moduleBase = moduleBases[0]; break; } //case NoiseType.Mix: // Perlin perlin = new Perlin(freq, lacun, persist, octvs, seed, QualityMode.High); // RidgedMultifractal rigged = new RidgedMultifractal(freq, lacun, octvs, seed, QualityMode.High); // Cylinders cyls = new Cylinders(freq); // //moduleBase = new Add(perlin, rigged); // moduleBase = new Blend(perlin, rigged, new Billow()); // break; // Initialize the noise map //moduleBase = new Scale(2, 2, 2, moduleBase); //moduleBase = new Translate(-1, -1, -1, moduleBase); this.m_noiseMap = new Noise2D(resolution, resolution, moduleBase); this.m_noiseMap.GeneratePlanar( offset + -1 * 1 / zoom, offset + offset + 1 * 1 / zoom, offset + -1 * 1 / zoom, offset + 1 * 1 / zoom); // Generate the textures this.m_textures[0] = this.m_noiseMap.GetTexture(GradientPresets.Grayscale); this.m_textures[0].filterMode = FilterMode.Point; //this.m_textures[0] = this.m_noiseMap.GetTexture(LibNoise.Unity.Gradient.Terrain); this.m_textures[0].Apply(); this.m_textures[1] = this.m_noiseMap.GetTexture(GradientPresets.Terrain); this.m_textures[1].Apply(); this.m_textures[2] = this.m_noiseMap.GetNormalMap(3.0f); this.m_textures[2].Apply(); //display on plane GetComponent <Renderer>().material.mainTexture = m_textures[0]; //write images to disk //File.WriteAllBytes(Application.dataPath + "/../Gray.png", m_textures[0].EncodeToPNG()); //File.WriteAllBytes(Application.dataPath + "/../Terrain.png", m_textures[1].EncodeToPNG()); //File.WriteAllBytes(Application.dataPath + "/../Normal.png", m_textures[2].EncodeToPNG()); }
static void Main(string[] args) { Multiply MultiplyNumber = n => n * 3; Console.WriteLine(MultiplyNumber(20)); }
public void getNameTest() { Multiply mul = new Multiply(); Assert.AreEqual("Multiply", mul.getName()); }
public override int GetHashCode() { unchecked { return((Add.GetHashCode() * 397) ^ Multiply.GetHashCode()); } }
public void getOperatorTest() { Multiply mul = new Multiply(); Assert.AreEqual("*", mul.getOperator()); }
/// <summary> /// Mountain amount /// Natural hill distribution /// </summary> /// <param name="map"></param> /// <param name="parms"></param> static void Postfix(Map map, GenStepParams parms) { // Map Reroll uses a map stub to generate previews, which is missing this info. // Checking map.info.parent.def filters Map Reroll previews and categorizes them as "player home" maps bool isPlayerHome = false; if (map.info.parent.def == null) { isPlayerHome = true; } else if (map.IsPlayerHome) { isPlayerHome = true; } if (MapDesignerSettings.flagHomeMapOnly && !isPlayerHome) { return; } MapDesignerSettings settings = MapDesignerMod.mod.settings; MapGenFloatGrid elevation = MapGenerator.Elevation; // pushes hills away from center if (MapDesignerMod.mod.settings.flagHillRadial) { IntVec3 center = map.Center; int size = map.Size.x / 2; float centerSize = settings.hillRadialSize * size; foreach (IntVec3 current in map.AllCells) { float distance = (float)Math.Sqrt(Math.Pow(current.x - center.x, 2) + Math.Pow(current.z - center.z, 2)); elevation[current] += (settings.hillRadialAmt * (distance - centerSize) / size); } } // hills to both sides if (MapDesignerMod.mod.settings.flagHillSplit) { float angle = settings.hillSplitDir; int mapSize = map.Size.x; float gapSize = 0.5f * mapSize * settings.hillSplitSize; float skew = settings.hillSplitAmt; ModuleBase slope = new AxisAsValueX(); slope = new Rotate(0.0, 180.0 - angle, 0.0, slope); slope = new Translate(0.0 - map.Center.x, 0.0, 0.0 - map.Center.z, slope); float multiplier = skew / mapSize; foreach (IntVec3 current in map.AllCells) { float value = slope.GetValue(current); //float num = size - Math.Abs(value); float num = Math.Abs(value) - gapSize; //num = 1 + (skew * num / mapSize); //num = 1 + num * multiplier; elevation[current] += num * multiplier; //elevation[current] *= num; //elevation[current] += num - 1; } } // hills to one side if (MapDesignerMod.mod.settings.flagHillSide) { float angle = settings.hillSideDir; float skew = settings.hillSideAmt; ModuleBase slope = new AxisAsValueX(); slope = new Rotate(0.0, 180.0 - angle, 0.0, slope); slope = new Translate(0.0 - map.Center.x, 0.0, 0.0 - map.Center.z, slope); float multiplier = skew / map.Size.x; foreach (IntVec3 current in map.AllCells) { //elevation[current] *= (1 + slope.GetValue(current) * multiplier); //elevation[current] += 0.5f * slope.GetValue(current) * multiplier; elevation[current] += slope.GetValue(current) * multiplier; } } // hill amount float hillAmount = settings.hillAmount; foreach (IntVec3 current in map.AllCells) { elevation[current] += settings.hillAmount - 1f; } // natural distribution if (MapDesignerMod.mod.settings.flagHillClumping) { float hillSize = MapDesignerMod.mod.settings.hillSize; if (hillSize > 0.022f) // smaller than vanilla only, else skip this step { float clumpSize = Rand.Range(0.01f, Math.Min(0.04f, hillSize)); float clumpStrength = Rand.Range(0.3f, 0.7f); ModuleBase hillClumping = new Perlin(clumpSize, 0.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.Low); foreach (IntVec3 current in map.AllCells) { elevation[current] += clumpStrength * hillClumping.GetValue(current); } } } // exit path if (MapDesignerMod.mod.settings.flagMtnExit) { ModuleBase exitPath = new AxisAsValueX(); ModuleBase crossways = new AxisAsValueZ(); double exitDir = Rand.Range(0, 360); //ModuleBase noise = new Perlin(0.021, 3.5, 0.5, 3, Rand.Range(0, 2147483647), QualityMode.Medium); //ModuleBase noise = new Perlin(Rand.Range(0.015f, 0.035f), 2.0, 0.5, 3, Rand.Range(0, 2147483647), QualityMode.Medium); ModuleBase noise = new Perlin(Rand.Range(0.015f, 0.03f), Math.Min(3.5, settings.hillSmoothness), 0.5, 3, Rand.Range(0, 2147483647), QualityMode.Medium); noise = new Multiply(noise, new Const(25.0)); exitPath = new Displace(exitPath, noise, new Const(0.0), new Const(0.0)); exitPath = new Rotate(0.0, exitDir, 0.0, exitPath); crossways = new Rotate(0.0, exitDir, 0.0, crossways); exitPath = new Translate((double)(-(double)map.Center.x), 0.0, (double)(-(double)map.Center.z), exitPath); crossways = new Translate((double)(-(double)map.Center.x), 0.0, (double)(-(double)map.Center.z), crossways); exitPath = new Abs(exitPath); foreach (IntVec3 current in map.AllCells) { if (crossways.GetValue(current) > 0f) { elevation[current] *= Math.Min(1, 0.1f * exitPath.GetValue(current) - 0.5f); } } } if (isPlayerHome) { GenerateFeatureGrids(map, parms); } }
public void getNumberOfValuesTest() { Multiply mul = new Multiply(); Assert.AreEqual(2, mul.getNumberOfValues()); }
// Use this for initialization void Start() { //make PowerUpScreen active since Content is referenced powerScreen = GameObject.Find ("Canvas/PowerUpScreen"); powerScreen.SetActive (true); contentList = GameObject.Find ("Canvas/PowerUpScreen/ScrollView/Content"); powerScreen.SetActive (false); buttonScale = new Vector3 (buttonSize, buttonSize, buttonSize); upgradeBarImages = new Sprite[]{upgradeBar0,upgradeBar1,upgradeBar2,upgradeBar3}; upgradeCardImages = new Sprite[]{upgradeCard0,upgradeCard1,upgradeCard2,upgradeCard3}; PowerUps = new PowerUp[GlobalVars.POWERUP_COUNT]; //the array of all possible PowerUps the spawned PowerUp could be PowerUps[0] = new LaneConversion(DEFAULT_NUMBER); PowerUps[1] = new SlowFall(DEFAULT_NUMBER,DEFAULT_NUMBER,DEFAULT_NUMBER); PowerUps[2] = new Fuel(DEFAULT_NUMBER) ; PowerUps[3] = new Multiply(DEFAULT_NUMBER,DEFAULT_NUMBER); PowerUps[4] = new BucketShield(DEFAULT_NUMBER); PowerUps[5] = new TapToCollect(DEFAULT_NUMBER); PowerUps[6] = new Invincible(DEFAULT_NUMBER, DEFAULT_NUMBER); PowerUps[7] = new TotalConversion(DEFAULT_NUMBER); PowerUps[8] = new CollectAll(); powerDescriptions = new string[TOTAL_BASE_POWERUPS*UPGRADE_LEVELS]{ "Tap or drag this ability into a specific lane to convert the elements contained to the lane’s elemental type.",//power 1, level 1 "Tap or drag this ability into a specific lane to convert the elements contained, and an adjacent lane, to each lane’s elemental type.",//power 1, level 2 "Tap or drag this ability to convert the elements contained within each lane to the lane’s elemental type.",//power 1, level 3 "Tap or drag this ability into a specific lane to slow down the fall of elements contained.",//power 2, level 1 "Tap or drag this ability into a specific lane to significantly slow down the fall of elements contained.",//power 2, level 2 "Tap or drag this ability to significantly slow down the fall all elements.",//power 2, level 3 "Your fuel does not deplete for a certain duration.",//power 3, level 1 "You gain additional fuel and it does not deplete for a certain duration.",//power 3, level 2 "You gain a significant amount of additional fuel and it does not deplete for a certain duration.",//power 3, level 3 "Tap or drag this ability into a specific lane to receive a score multiplier for the elements collected of that lane’s elemental type.",//power 4, level 1 "Tap or drag this ability into a specific lane to receive a score multiplier for the elements collected of that lane’s elemental type, and an adjacent lane’s elemental type.",//power 4, level 2 "Tap or drag this ability to receive a score multiplier for elements collected of all elemental types.",//power 4, level 3 "Tap or drag this ability into a specific lane to give that lane no miss penalty for the next 2 incorrect elements that fall into it.",//power 5, level 1 "Tap or drag this ability into a specific lane to give that lane no miss penalty for the next 4 incorrect elements that fall into it.",//power 5, level 2 "Tap or drag this ability to give all lanes no miss penalty for the next 4 incorrect elements that fall into them, for each lane.",//power 5, level 3 "Simply tap elements to automatically collect them.",//power 6, level 1 "Simply tap elements to automatically collect them.",//power 6, level 2 "Simply tap elements to automatically collect them.",//power 6, level 3 "Tap or drag this ability into a specific lane to give that lane no miss penalty for a small amount of time.",//power 7, level 1 "Tap or drag this ability into a specific lane to give that lane no miss penalty for a decent amount of time.",//power 7, level 2 "Tap or drag this ability to give all lanes no miss penalty for a decent amount of time.",//power 7, level 3 "Tap or drag this ability into a specific lane to convert all spawned elements to the lane’s elemental type for a small amount of time.",//power 8, level 1 "Tap or drag this ability into a specific lane to convert all spawned elements to the lane’s elemental type for a decent amount of time.",//power 8, level 2 "Tap or drag this ability into a specific lane to convert all spawned elements to the lane’s elemental type and gain invincibility for a decent amount of time.",//power 8, level 3 "Tap or drag this ability into a specific lane to automatically collect all elements in that lane.",//power 9, level 1 "Tap or drag this ability into a specific lane to automatically collect all elements in that lane and an adjacent lane.",//power 9, level 2 "Tap or drag this ability to automatically collect all elements in all lanes."};//power 9, level 3 bonusTexts = new string[TOTAL_BASE_POWERUPS*UPGRADE_LEVELS]{ "1 Lane",//power 1, level 1 "2 Lanes",//power 1, level 2 "All Lanes",//power 1, level 3 "Slow",//power 2, level 1 "Slower",//power 2, level 2 "Slower & All Lanes",//power 2, level 3 "Fuel",//power 3, level 1 "Fuel+",//power 3, level 2 "Fuel++",//power 3, level 3 "1 Element",//power 4, level 1 "2 Elements",//power 4, level 2 "4 Element",//power 4, level 3 "2 Saves & 1 Lane",//power 5, level 1 "4 Saves & 1 Lane",//power 5, level 2 "4 Saves & All Lanes",//power 5, level 3 "Tap Time",//power 6, level 1 "Tap Time+",//power 6, level 2 "Tap Time++",//power 6, level 3 "Invincible Time & 1 Lane",//power 7, level 1 "Invincible Time+ & 1 Lane",//power 7, level 2 "Invincible Time+ & All Lanes",//power 7, level 3 "Conversion Time",//power 8, level 1 "Conversion Time+",//power 8, level 2 "Conversion Time+ & Invincible",//power 8, level 3 "1 Lane",//power 9, level 1 "2 Lanes",//power 9, level 2 "All Lanes"};//power 9, level 3 elem = new string[TOTAL_BASE_POWERUPS*TIMES_UPGRADED,TYPES_OF_ELEMENTS_PER_UNLOCK]{ {FirstPowerUpElements[0], FirstPowerUpElements[1], FirstPowerUpElements[2], FirstPowerUpElements[3]},//power 1, upgrade 1 {"magma","cloud","mud","energy"},//power 1, upgrade 2 {"desert","earthquake","blizzard","mountain"},//power 2, upgrade 1 {"storm","glass","clay","brick"},//power 2, upgrade 2 {"coal","volcano","tornado","glacier"},//power 3, upgrade 1 {"ion","fission","ceramics","monsoon"},//power 3, upgrade 2 {"diamond","aurora","smoke","flood"},//power 4, upgrade 1 {"metal","grass","radiation","tsunami"},//power 4, upgrade 2 {"meteoroid","supernova","archipelago","rust"},//power 5, upgrade 1 {"wasteland","voltage","tide","edifice"},//power 5, upgrade 2 {"algae","pulsar","dynamo","windmill"},//power 6, upgrade 1 {"aliens","fusion","whirlpool","resistance"},//power 6, upgrade 2 {"forest","crater","maze","apocalypse"},//power 7, upgrade 1 {"dreams","balance","coincidence","fate"},//power 7, upgrade 2 {"valley","fruit","sorcery","prophecy"},//power 8, upgrade 1 {"inertia","morality","method","insight"},//power 8, upgrade 2 {"emotion","chaos","deception","reason"},//power 9, upgrade 1 {"information","chronology","absurd","motivation"}};//power 9, upgrade 2 cost = new int[TOTAL_BASE_POWERUPS*TIMES_UPGRADED,TYPES_OF_ELEMENTS_PER_UNLOCK]{ {50, 50, 50, 50},//power 1, upgrade 1 {99,99,99,99},//power 1, upgrade 2 {50,50,50,50},//power 2, upgrade 1 {99,99,99,99},//power 2, upgrade 2 {50,50,50,50},//power 3, upgrade 1 {99,99,99,99},//power 3, upgrade 2 {50,50,50,50},//power 4, upgrade 1 {99,99,99,99},//power 4, upgrade 2 {50,50,50,50},//power 5, upgrade 1 {99,99,99,99},//power 5, upgrade 2 {50,50,50,50},//power 6, upgrade 1 {99,99,99,99},//power 6, upgrade 2 {50,50,50,50},//power 7, upgrade 1 {99,99,99,99},//power 7, upgrade 2 {50,50,50,50},//power 8, upgrade 1 {99,99,99,99},//power 8, upgrade 2 {50,50,50,50},//power 9, upgrade 1 {99,99,99,99}};//power 9, upgrade 2 notEnoughColor = new Color(255.0f/255.0f,135.0f/255.0f,126.0f/255.0f); }
protected override bool Visit(Multiply mul) => VisitBinary(mul);
public void TestSimpleAddition() { var add = new Multiply(new Property("Left"), new Property("Right")); Assert.That(add.Evaluate(new Reflection(this)), Is.EqualTo(84)); }
public void MultiplyTest() { var calculator = new Multiply(); Assert.AreEqual(3, calculator.Calculate(3, 1)); }
public void TestMultiplyExpectsMinus210() { var operation = new Multiply(); var result = operation.Operate(5, -42); Assert.AreEqual(result, -210); }
private static Activity HandleBinaryExpression <TLeft, TRight, TResult>(BinaryOperator op, TestExpression left, TestExpression right) { Activity we = null; InArgument <TLeft> leftArgument = (InArgument <TLeft>)TestExpression.GetInArgumentFromExpectedNode <TLeft>(left); leftArgument.EvaluationOrder = 0; InArgument <TRight> rightArgument = (InArgument <TRight>)TestExpression.GetInArgumentFromExpectedNode <TRight>(right); rightArgument.EvaluationOrder = 1; switch (op) { case BinaryOperator.Add: we = new Add <TLeft, TRight, TResult>() { Checked = false, Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.And: we = new And <TLeft, TRight, TResult>() { Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.AndAlso: we = new AndAlso() { Left = TestExpression.GetWorkflowElementFromExpectedNode <bool>(left), Right = TestExpression.GetWorkflowElementFromExpectedNode <bool>(right) }; break; case BinaryOperator.CheckedAdd: we = new Add <TLeft, TRight, TResult>() { Checked = true, Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.CheckedMultiply: we = new Multiply <TLeft, TRight, TResult>() { Checked = true, Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.CheckedSubtract: we = new Subtract <TLeft, TRight, TResult>() { Checked = true, Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.Divide: we = new Divide <TLeft, TRight, TResult>() { Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.Equal: we = new Equal <TLeft, TRight, TResult>() { Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.GreaterThan: we = new GreaterThan <TLeft, TRight, TResult>() { Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.GreaterThanOrEqual: we = new GreaterThanOrEqual <TLeft, TRight, TResult>() { Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.LessThan: we = new LessThan <TLeft, TRight, TResult>() { Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.LessThanOrEqual: we = new LessThanOrEqual <TLeft, TRight, TResult>() { Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.Or: we = new Or <TLeft, TRight, TResult>() { Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.Multiply: we = new Multiply <TLeft, TRight, TResult>() { Checked = false, Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.NotEqual: we = new NotEqual <TLeft, TRight, TResult>() { Left = leftArgument, Right = rightArgument }; break; case BinaryOperator.OrElse: we = new OrElse() { Left = TestExpression.GetWorkflowElementFromExpectedNode <bool>(left), Right = TestExpression.GetWorkflowElementFromExpectedNode <bool>(right) }; break; case BinaryOperator.Subtract: we = new Subtract <TLeft, TRight, TResult>() { Checked = false, Left = leftArgument, Right = rightArgument }; break; default: throw new NotSupportedException(string.Format("Operator: {0} is unsupported", op.ToString())); } return(we); }
public void TestMultiplyExpects0() { var operation = new Multiply(); var result = operation.Operate(0, 91); Assert.AreEqual(result, 0); }
public void DynamicTypes() { AllTypes types = new AllTypes(); // boolean types.AnyProperty = false; Assert.False((bool)types.AnyProperty); // string types.AnyProperty = "String"; Assert.Equal("String", types.AnyProperty); // number types.AnyProperty = 12; Assert.Equal((double)12, types.AnyProperty); // date types.AnyProperty = UnixEpoch.AddSeconds(1234); Assert.Equal(UnixEpoch.AddSeconds(1234), types.AnyProperty); // json (notice that when deserialized, it is deserialized as a map). types.AnyProperty = new JObject(new JProperty("Goo", new JArray( "Hello", new JObject(new JProperty("World", 123)) ) )); var @object = (IDictionary <string, object>)types.AnyProperty; var array = (object[])@object["Goo"]; var innerObject = (IDictionary <string, object>)array[1]; Assert.Equal((double)123, innerObject["World"]); // array types.AnyProperty = new[] { "Hello", "World" }; Assert.Equal("Hello", ((object[])types.AnyProperty)[0]); Assert.Equal("World", ((object[])types.AnyProperty)[1]); // array of any types.AnyArrayProperty = new object[] { "Hybrid", new Number(12), 123, false }; Assert.Equal((double)123, types.AnyArrayProperty[2]); // map IDictionary <string, object> map = new Dictionary <string, object>(); map["MapKey"] = "MapValue"; types.AnyProperty = map; Assert.Equal("MapValue", ((IDictionary <string, object>)types.AnyProperty)["MapKey"]); // map of any map["Goo"] = 19289812; types.AnyMapProperty = map; Assert.Equal((double)19289812, types.AnyMapProperty["Goo"]); // classes Multiply mult = new Multiply(new Number(10), new Number(20)); types.AnyProperty = mult; Assert.Same(types.AnyProperty, mult); Assert.IsType <Multiply>(types.AnyProperty); Assert.Equal((double)200, ((Multiply)types.AnyProperty).Value); }
public void EvaluateShouldWorkProperly() { var operand = new Multiply(); Assert.AreEqual(25, operand.Evaluate(5, 5)); }
public static void genNoise(int channelId) { moduleBase[channelId] = new Perlin(); if (teNoiseChanTypeIndex[channelId] == 1) { int tIdx = teNoiseTypeIndex[channelId]; if (tIdx == 0) { moduleBase[channelId] = new Perlin(frequency[channelId], lacunarity[channelId], persistance[channelId], octaves[channelId], seed[channelId], QualityMode.High); } if (tIdx == 1) { moduleBase[channelId] = new Billow(frequency[channelId], lacunarity[channelId], persistance[channelId], octaves[channelId], seed[channelId], QualityMode.High); } if (tIdx == 2) { moduleBase[channelId] = new RidgedMultifractal(frequency[channelId], lacunarity[channelId], octaves[channelId], seed[channelId], QualityMode.High); } if (tIdx == 3) { moduleBase[channelId] = new Voronoi(frequency[channelId], displacement[channelId], seed[channelId], distance[channelId]); } if (tIdx == 4) { moduleBase[channelId] = new BrownianMotion(frequency[channelId], lacunarity[channelId], octaves[channelId], seed[channelId], QualityMode.High); } if (tIdx == 5) { moduleBase[channelId] = new HeterogeneousMultiFractal(frequency[channelId], lacunarity[channelId], octaves[channelId], persistance[channelId], seed[channelId], offset[channelId], QualityMode.High); } if (tIdx == 6) { moduleBase[channelId] = new HybridMulti(frequency[channelId], lacunarity[channelId], octaves[channelId], persistance[channelId], seed[channelId], offset[channelId], gain[channelId], QualityMode.High); } if (tIdx == 7) { moduleBase[channelId] = new LinearGradientNoise(frequency[channelId]); } } if (teNoiseChanTypeIndex[channelId] == 2) { int fIdx = teFunctionTypeIndex[channelId]; if (fIdx == 0) { moduleBase[channelId] = new Add(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); } if (fIdx == 1) { moduleBase[channelId] = new Subtract(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); } if (fIdx == 2) { moduleBase[channelId] = new Multiply(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); } if (fIdx == 3) { moduleBase[channelId] = new Min(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); } if (fIdx == 4) { moduleBase[channelId] = new Max(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); } if (fIdx == 5) { moduleBase[channelId] = new Blend(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]], moduleBase[srcChannel3Id[channelId]]); } if (fIdx == 6) { moduleBase[channelId] = new Clamp((double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId], moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 7) { moduleBase[channelId] = new Power(moduleBase[srcChannel1Id[channelId]],moduleBase[srcChannel2Id[channelId]]);} if (fIdx == 8) { Curve tmpCurve = new Curve(moduleBase[srcChannel1Id[channelId]]); double adjust = double.Parse((controlpointcount[channelId]-1).ToString())*0.5; for(int i=0;i<controlpointcount[channelId];i++){ tmpCurve.Add(double.Parse(i.ToString())-adjust,(double)cpval[channelId,i]); moduleBase[channelId] = tmpCurve; } } if(fIdx==9){Terrace tmpTerrace = new Terrace(invertTerrace[channelId],moduleBase[srcChannel1Id[channelId]]); for(int i=0;i<controlpointcount[channelId];i++){ tmpTerrace.Add((double)cpval[channelId,i]-0.5); moduleBase[channelId] = tmpTerrace; } } if (fIdx == 18) { moduleBase[channelId] = new Mask(moduleBase[srcChannel1Id[channelId]], (double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId]); } if (fIdx == 17) { moduleBase[channelId] = new WindexWarp(moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 16) { moduleBase[channelId] = new TEWarp(moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 15) { moduleBase[channelId] = new Select((double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId], falloff[channelId], moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]], moduleBase[srcChannel3Id[channelId]]); } if (fIdx == 14) { moduleBase[channelId] = new Turbulence(power[channelId],moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 13) { moduleBase[channelId] = new ScaleBias(scale[channelId],bias[channelId],moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 12) { moduleBase[channelId] = new Invert(moduleBase[srcChannel1Id[channelId]]);} if (fIdx == 11) { moduleBase[channelId] = new Exponent(exponent[channelId],moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 10) { moduleBase[channelId] = new Abs(moduleBase[srcChannel1Id[channelId]]);} } int resolution = 64; int xoffset = 0; int yoffset = 0; m_noiseMap[channelId] = new Noise2D(resolution, resolution, moduleBase[channelId]); float x1 = xoffset * zoom[channelId]; float x2 = (xoffset * zoom[channelId]) + ((zoom[channelId] / resolution) * (resolution + 1)); float y1 = -yoffset * zoom[channelId]; float y2 = (-yoffset * zoom[channelId]) + ((zoom[channelId] / resolution) * (resolution + 1)); m_noiseMap[channelId].GeneratePlanar(x1, x2, y1, y2); m_textures[channelId] = m_noiseMap[channelId].GetTexture(); m_textures[channelId].Apply(); }