public void TakeEnumeratorOutForTestDrive() { var a = TestVariable.Create(LevelsOne); var b = TestVariable.Create(LevelsTwo); var c = Synthesis.Create(a, b, ((resultOne, resultTwo) => string.Format("{0}, {1}", resultOne.ToString(), resultTwo.ToString()))); var d = Synthesis.Create(TestVariable.Create(LevelsOne), input => input.ToString()); var dWithATwist = Synthesis.Create(new List <IFactory> { d }, (Converter <Object, Object>)(thing => thing)); var e = Interleaving.Create(new List <IFactory> { dWithATwist, c }); var strength = e.MaximumStrength; do { foreach (var u in e.CreateEnumerable(strength)) { Console.WriteLine(u.ToString()); } Console.WriteLine("****************"); } while (--strength != 0U); }
public void TestStuff() { const int deferralBudget = 4; var historiesForSeveralThingsFactory = HistoriesForSeveralThingsFactory(); var randomBehaviourSeedFactory = TestVariable.Create(new[] { 67, 890478236, 1123789, 892367 }); var topLevelTestCaseFactory = Synthesis.Create(historiesForSeveralThingsFactory, randomBehaviourSeedFactory, Tuple.Create) .WithDeferralBudgetOf(deferralBudget); const int strength = 3; var numberOfTestCases = topLevelTestCaseFactory.ExecuteParameterisedUnitTestForAllTestCases(strength, topLevelTestCase => { Console.WriteLine("***************"); foreach (var thingHistory in topLevelTestCase.Item1) { Console.WriteLine("Thing record index: {0} => item index: {1}", thingHistory.ThingRecordIndex, thingHistory.ItemIndex); } }); Console.WriteLine("Number of test cases validated: {0}", numberOfTestCases); }
// 显示合成 private void ShowSynthesis(User user, CqGroupMessageEventArgs e, string groupPath) { List <string> items = iniTool.IniReadSectionKey(devPath, synthesisIni, user.Pos); if (items.Count == 0) { Common.CqApi.SendGroupMessage(e.FromGroup, "[" + user.Name + "] 该位置没有商品"); return; } string synthesisItems = "[" + user.Pos + "]" + Environment.NewLine; foreach (string item in items) { string name = iniTool.IniReadValue(devPath, synthesisIni, user.Pos, item); Synthesis synthesis = GetSynthesis(name, e, groupPath); synthesisItems += item + ":" + name + " 所需材料(" + synthesis.Material.Replace("|", ",") + ")" + Environment.NewLine; synthesisItems += "成功率:" + synthesis.SuccessRate + Environment.NewLine + "失败保留:" + synthesis.Retain + Environment.NewLine; } synthesisItems += "输入:合成 编号"; Common.CqApi.SendGroupMessage(e.FromGroup, synthesisItems); return; }
private static ITypedFactory <TestCase> BuildTestCaseFactory() { var factoryForLeastItemInSequence = TestVariable.Create(Enumerable.Range(-3, 10)); const int maximumNumberOfDeltas = 4; var factoryForNonNegativeDeltasAndPermutation = Interleaving.Create( from numberOfDeltas in Enumerable.Range(0, 1 + maximumNumberOfDeltas) select BuildNonNegativeDeltasAndPermutationFactory(numberOfDeltas)); var testCaseFactoryForTrivialCase = Singleton.Create(new TestCase()); var testCaseFactoryForNonTrivialCases = Synthesis.Create(factoryForLeastItemInSequence, factoryForNonNegativeDeltasAndPermutation, (leastItemInSequence, nonNegativeDeltasAndItsPermutation) => new TestCase(leastItemInSequence, nonNegativeDeltasAndItsPermutation.Item1, nonNegativeDeltasAndItsPermutation.Item2)); return (Interleaving.Create(new[] { testCaseFactoryForTrivialCase, testCaseFactoryForNonTrivialCases })); }
BuildExpressionFactoryRecursively(Boolean directlyToTheRightOfABinaryOperator) { var binaryOperatorExpressionFactory = Synthesis.Create( Deferral.Create( () => BuildExpressionFactoryRecursively( directlyToTheRightOfABinaryOperator)), Deferral.Create(() => BuildExpressionFactoryRecursively(true)), BinaryOperatorFactory, BinaryExpressionFrom); var negatedExpressionFactory = Synthesis.Create( Deferral.Create(() => BuildExpressionFactoryRecursively(true)), expression => Tuple.Create(expression.Item1, String.Format( directlyToTheRightOfABinaryOperator ? "(-{0})" : "-{0}", expression.Item2))); var bracketedExpressionFactory = Synthesis.Create( Deferral.Create(() => BuildExpressionFactoryRecursively(false)), expression => Tuple.Create(false, String.Format("({0})", expression.Item2))); return (Interleaving.Create(new[] { ConstantFactory, binaryOperatorExpressionFactory, negatedExpressionFactory, bracketedExpressionFactory })); }
internal SynthesisEvent InvokeEvent(SynthesisEvent arg) { if (_api.ValidateEvent(arg)) { Synthesis?.Invoke(_api, arg); } return(arg); }
void OnGUI() { Synthesis.Interface(cl, h, point, ref start, ref speed, "H2+Cl2=2HCL", style); if (start) { StartCoroutine(Change_texts()); } }
public void Synthesize() { Synthesis.Synthesize(); var count = Math.Min(Synthesis.AudioBufferSize, Samples.Length - GeneratedSamples); Synthesis.AudioBuffer.BlockCopy(0, Samples, GeneratedSamples, count); GeneratedSamples += count; }
public double[] Synthesize() { var yLength = (int)((F0.Length - 1) * FramePeriod / 1000.0 * SampleRate) + 1; var y = new double[yLength]; var synthesis = new Synthesis(); synthesis.Synthesize(F0, F0.Length, Spectrogram, Aperiodicity, FFTSize, FramePeriod, SampleRate, y); return(y); }
BuildNonNegativeDeltasAndPermutationFactory(int numberOfDeltas) { var factoryForNonNegativeDelta = TestVariable.Create(from signedDelta in Enumerable.Range(0, 5) select signedDelta); return (Synthesis.CreateWithPermutation <Int32, Int32>( Enumerable.Repeat(factoryForNonNegativeDelta, numberOfDeltas))); }
public ITypedFactory <ThingHistory> ThingFactory(int thingRecordIndex, int maximumNumberOfItems) { var itemIndexFactory = TestVariable.Create(Enumerable.Range(0, maximumNumberOfItems)); var numberOfRejectionsFactory = TestVariable.Create(Enumerable.Range(0, 3)); return(Synthesis.Create(itemIndexFactory, numberOfRejectionsFactory, numberOfRejectionsFactory, (itemIndex, numberOfRejectionsBeforeAcceptance, numberOfRejectionsBeforeWithdrawal) => new ThingHistory(thingRecordIndex, itemIndex, numberOfRejectionsBeforeAcceptance, numberOfRejectionsBeforeWithdrawal))); }
public override void Handle(Synthesis e) { if (e.Materials == null) { return; } foreach (var mat in e.Materials) { NotifyInventory(mat.Key, -mat.Value, e); } }
private static ITypedFactory <IEnumerable <Tuple <Int32, Int32> > > BuildConnectionsFactory(Int32 numberOfVertices) { var numberOfPotentialUniqueConnectionsWithoutSelfLoops = NumberOfPotentialUniqueConnectionsWithoutSelfLoops(numberOfVertices); var connectionSwitchFactory = TestVariable.Create(new[] { false, true }); return (Synthesis.Create( Enumerable.Repeat(connectionSwitchFactory, numberOfPotentialUniqueConnectionsWithoutSelfLoops), connectionSwitches => EnumerateConnections(connectionSwitches, numberOfVertices))); }
// Start is called before the first frame update void Start() { /* if( testé si deja partie existante ) * else * */ Synthesis.synthesis( "Bonjour capitaine, voulez vous continuez votre aventure ou bien commencer une nouvelle légende"); Recognition.start_recognition(react, "nouvelle continuer commencer", 20); }
public void Ctor() { dynamic props = new Synthesis { { "a", 1 }, { "b", new Func <int, int, int>((arg1, arg2) => arg1 + arg2) } }; int a = props.a, b = props.b(10, 20); Assert.AreEqual(a, 1); Assert.AreEqual(b, 30); }
// 合成 private void Synthesis(string synthesisName, User user, CqGroupMessageEventArgs e, string groupPath) { synthesisName = iniTool.IniReadValue(devPath, synthesisIni, user.Pos, synthesisName); Synthesis synthesis = GetSynthesis(synthesisName, e, groupPath); if (synthesis.SuccessRate == 0) { Common.CqApi.SendGroupMessage(e.FromGroup, "[" + user.Name + "] 该物品不能合成 " + synthesis.Name); return; } string[] allItems = synthesis.Material.Split('|'); bool isExistence = IsExistenceItems(user, e, groupPath, allItems); if (!isExistence) { Common.CqApi.SendGroupMessage(e.FromGroup, "[" + user.Name + "] 合成失败:您背包里没有合成需要的物品数量!"); return; } bool isDeleteItems = DeleteKnapsackItems(user, e, groupPath, allItems); if (!isDeleteItems) { Common.CqApi.SendGroupMessage(e.FromGroup, "[" + user.Name + "] 请稍后再试!"); return; } if (user.isVip) { synthesis.SuccessRate += 20; } bool isSuccess = IsSuccess(synthesis.SuccessRate); if (!isSuccess) { string[] retain = synthesis.Retain.Split('*'); SetKnapsackItemNum(retain[0], 1, groupPath, e.FromQQ.ToString()); Common.CqApi.SendGroupMessage(e.FromGroup, "[" + user.Name + "] 合成失败:长相问题!"); return; } SetKnapsackItemNum(synthesis.Name, 1, groupPath, e.FromQQ.ToString()); Common.CqApi.SendGroupMessage(e.FromGroup, "[" + user.Name + "] 合成成功:" + synthesis.Name); }
public ITypedFactory <String> BuildFactoryRecursivelyUsingDeferral() { var simplerFactoryForShorterStrings = Deferral.Create(BuildFactoryRecursivelyUsingDeferral); var factoryForNonEmptyStrings = Synthesis.Create( _factoryForSingleCharacters, simplerFactoryForShorterStrings, (leftmostCharacterToPrepend, shorterString) => leftmostCharacterToPrepend + shorterString); return (Interleaving.Create(new[] { _emptyStringFactory, factoryForNonEmptyStrings })); }
public ITypedFactory <IEnumerable <ThingHistory> > HistoriesForSeveralThingsFactory(int minimumNumberOfThings = 1) { var historiesForSeveralThingsFactory = Synthesis.Create( from thingRecordIndex in Enumerable.Range(0, minimumNumberOfThings) select ThingFactory(thingRecordIndex, minimumNumberOfThings)) .WithFilter(ThingsShareItemsEfficiently(minimumNumberOfThings)); return (Interleaving.Create(new[] { historiesForSeveralThingsFactory, Deferral.Create(() => HistoriesForSeveralThingsFactory(1 + minimumNumberOfThings)) })); }
void OnGUI() { Synthesis.Interface(o, c, point, ref start, ref speed, "O2+C=CO2", style); if (start) { StartCoroutine(Change_texts()); } if (start) { for (int i = 0; i < o.Count; i++) { Global_Functions.Start_Anim(start, o[i], point[i], speed); } } }
private static ITypedFactory <TestCase> BuildTestCaseFactory(Int32 numberOfVertices) { var connectionsFactory = BuildConnectionsFactory(numberOfVertices) .WithFilter(dictionary => ConnectionsImplyADag(dictionary, numberOfVertices)); var testCaseFactory = Synthesis.Create(connectionsFactory, connections => new TestCase() { NumberOfVertices = numberOfVertices, Connections = connections }); return (Interleaving.Create(new[] { testCaseFactory, Deferral.Create(() => BuildTestCaseFactory(1 + numberOfVertices)) })); }
public ITypedFactory <String> BuildFactoryRecursively(Int32 maximumStringLength) { if (0 == maximumStringLength) { return(_emptyStringFactory); } var simplerFactoryForShorterStrings = BuildFactoryRecursively(maximumStringLength - 1); var factoryForNonEmptyStrings = Synthesis.Create( _factoryForSingleCharacters, simplerFactoryForShorterStrings, (leftmostCharacterToPrepend, shorterString) => leftmostCharacterToPrepend + shorterString); return (Interleaving.Create(new[] { _emptyStringFactory, factoryForNonEmptyStrings })); }
private static ITypedFactory <String> BuildExpressionFactoryRecursively() { var subexpressionFactory = Interleaving.Create(new[] { ConstantFactory, Synthesis.Create(Deferral.Create(BuildExpressionFactoryRecursively), expression => String.Format("({0})", expression)) }); var binaryOperatorExpressionFactory = Synthesis.Create(subexpressionFactory, BinaryOperatorFactory, subexpressionFactory, (lhsOperand, binaryOperator, rhsOperand) => String.Format("{0} {1} {2}", lhsOperand, binaryOperator, rhsOperand)); return (Interleaving.Create(new[] { ConstantFactory, binaryOperatorExpressionFactory })); }
public void MembersAccess() { var syn = new Synthesis(); ((IAtomicity)syn).Create("a", 1); ((IAtomicity)syn).Create("b", new Func <int, int, int>((arg1, arg2) => arg1 + arg2)); dynamic props = syn; int a = props.a, b = props.b(10, 20); Assert.AreEqual(a, 1); Assert.AreEqual(b, 30); ((IAtomicity)syn).Delete("a"); Assert.IsNull(props.a); ((IAtomicity)syn).Delete("b"); Assert.IsNull(props.b); }
public static void Main(string[] args) { var audioPath = @"vaiueo2d.wav"; var audioOutPath = @"vaiueo2d-out.wav"; var(x, fs, nbit) = AudioIO.WavRead(audioPath); var(f0, t) = Dio.Compute(x, fs); f0 = StoneMask.Compute(x, fs, t, f0); var fftSize = CheapTrick.GetFftSize(fs); var sp = CheapTrick.Compute(x, fs, t, f0, fftSize: fftSize); var ap = D4C.Compute(x, fs, t, f0, fftSize: fftSize); var ndim = 60; var mgc = Codec.CodeSpectralEnvelope(sp, fs, ndim); var bap = Codec.CodeAperiodicity(ap, fs); Console.WriteLine($"{audioPath}:"); Console.WriteLine($" input samples count: {x.Length}"); Console.WriteLine($" sampling rate: {fs}"); Console.WriteLine($" bit rate: {nbit}"); Console.WriteLine(); Console.WriteLine($" frame count: {f0.Length}"); Console.WriteLine($" fft size: {fftSize}"); Console.WriteLine($" sp width: {sp.GetLength(1)}"); Console.WriteLine(); Console.WriteLine($" mgc width: {ndim}"); Console.WriteLine($" bap width: {bap.GetLength(1)}"); Console.WriteLine(); for (int i = 0; i < f0.Length; i++) { f0[i] *= 1.6789; } sp = Codec.DecodeSpectralEnvelope(mgc, fs, fftSize); ap = Codec.DecodeAperiodicity(bap, fs, fftSize); var y = Synthesis.Compute(f0, sp, ap, fs); Console.WriteLine($"--> {audioOutPath}"); AudioIO.WavWrite(y, fs, nbit, audioOutPath); }
public void TestStandardDictionaryWithJustOneKey() { var keyFactory = TestVariable.Create(Enumerable.Range(-2, 5)); var operationFactory = TestVariable.Create( from operationKind in ((IEnumerable <OperationKind>) Enum.GetValues(typeof(OperationKind))) select operationKind); const Int32 numberOfOperations = 10; var randomBehaviour = new Random(0); var operationKindSequenceFactory = Synthesis.Create(Enumerable.Repeat(operationFactory, numberOfOperations)) .WithFilter(FilterOutThreeOrMoreConsecutiveIdenticalOperationKinds); var operationListBuilderFactory = Synthesis.Create(keyFactory, operationKindSequenceFactory, (key, operationKindSequence) => { var result = new OperationListBuilder(key, randomBehaviour); foreach (var operationKind in operationKindSequence) { result.AppendNewOperationOfKind(operationKind); } return(result); }); const Int32 strength = 4; var numberOfTestCasesExercised = operationListBuilderFactory.ExecuteParameterisedUnitTestForAllTestCases( strength, ParameterisedUnitTestForStandardDictionaryWithJustOneKey); Console.Out.WriteLine("Exercised {0} test cases.", numberOfTestCasesExercised); }
// 获取Vip信息 private Synthesis GetSynthesis(string synthesisName, CqGroupMessageEventArgs e, string groupPath) { Synthesis synthesis = new Synthesis(); string isItem = iniTool.IniReadValue(devPath, synthesisIni, synthesisName, "合成材料"); if (isItem == "") { return(synthesis); } string synthesisInfo = ""; foreach (string s in GameConfig.synthesis) { synthesisInfo += iniTool.IniReadValue(devPath, synthesisIni, synthesisName, s) + ","; } synthesis.Name = synthesisName; synthesis.Add(synthesisInfo); return(synthesis); }
public ShieldSparkParticleSystem(Synthesis.Game1 game, int howManyEffects) : base(game,howManyEffects) { }
public static async Task StopBusy(bool leaveDuty = true, bool stopFishing = true, bool dismount = true) { for (var tryStep = 1; tryStep < 6; tryStep++) { if (!CheckIfBusy(leaveDuty, stopFishing, dismount)) { break; } Log($"We're occupied. Trying to exit out. Attempt #{tryStep}"); if (stopFishing && FishingManager.State != FishingState.None) { var quit = ActionManager.CurrentActions.Values.FirstOrDefault(i => i.Id == 299); if (quit != default(SpellData)) { Log($"Exiting Fishing."); if (ActionManager.CanCast(quit, Core.Me)) { ActionManager.DoAction(quit, Core.Me); await Coroutine.Wait(6000, () => FishingManager.State == FishingState.None); } } } if (CraftingLog.IsOpen || CraftingManager.IsCrafting || Synthesis.IsOpen) { Log($"Closing Crafting Window."); await Lisbeth.ExitCrafting(); Synthesis.Close(); await Coroutine.Wait(6000, () => !Synthesis.IsOpen); await Coroutine.Wait(1500, () => CraftingLog.IsOpen); CraftingLog.Close(); await Coroutine.Wait(6000, () => !CraftingLog.IsOpen); await Coroutine.Wait(6000, () => !CraftingManager.IsCrafting && !MovementManager.IsOccupied); } if (leaveDuty && DutyManager.InInstance) { Log($"Leaving Diadem."); DutyManager.LeaveActiveDuty(); if (await Coroutine.Wait(30000, () => CommonBehaviors.IsLoading)) { await Coroutine.Yield(); await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading); await Coroutine.Sleep(5000); } } if (dismount && Core.Me.IsMounted) { Log("Dismounting."); ActionManager.Dismount(); await Coroutine.Wait(3000, () => !Core.Me.IsMounted); } if (InSmallTalk) { Log("Skipping smalltalk."); await SmallTalk(); } await Coroutine.Sleep(2500); } if (CheckIfBusy(leaveDuty, stopFishing, dismount)) { Log("Something went wrong, we're still occupied."); TreeRoot.Stop("Stopping bot."); } }
public ExplosionParticleSystem(Synthesis.Game1 game, int howManyEffects) : base(game, howManyEffects) { }
/// <summary> /// Create synthesis in specified synthesis object. /// </summary> /// <param name="synth">The syntesis object to work on.</param> /// <param name="levels">From what level to generate the synthesis from.</param> /// <param name="synthMode">What kernel to use for synthesis.</param> private void SynthesizeCall(Synthesis synth, int levels = 0, SynthesisMode synthMode = SynthesisMode.BiQuadBSpline) { // Use default value if no value is set ( To be changed later to just synthesize all the way up if nothing else is specific) if (levels == 0) levels = _levels; int sampleCompensation = !_UseHigherPoT ? 1 : 0; //Debug.Log(sampleCompensation); // If it is the first level just copy over the top level analysis. (This could be optimized slightly by just directly using it from the analysis list) if (levels == 1) { _cSMain.SetTexture(_cSMain.FindKernel(GetEnumDescription(synthMode)), "source", _analyzeList[synth.SourceLevel - sampleCompensation]); _cSMain.SetTexture(_cSMain.FindKernel(GetEnumDescription(synthMode)), "dest", synth.Pyramid[0]); if (synth.Pyramid[0].width > 32 || synth.Pyramid[0].height > 32) _cSMain.Dispatch(_cSMain.FindKernel(GetEnumDescription(synthMode)), (int)Mathf.Ceil(_analyzeList[synth.SourceLevel - sampleCompensation].width / 32), (int)Mathf.Ceil(_analyzeList[synth.SourceLevel - sampleCompensation].height / 32), 1); else _cSMain.Dispatch(_cSMain.FindKernel(GetEnumDescription(synthMode)), 1, 1, 1); } else { for (int i = 0; i < levels; i++) { if (i == 0) { _cSMain.SetTexture(_cSMain.FindKernel(GetEnumDescription(synthMode)), "source", _analyzeList[synth.SourceLevel - sampleCompensation]); _cSMain.SetTexture(_cSMain.FindKernel(GetEnumDescription(synthMode)), "dest", synth.Pyramid[i]); //Debug.Log("Source: " + _analyzeList[synth.SourceLevel - sampleCompensation].width + " Destination: " + synth.Pyramid[i].width); _cSMain.Dispatch(_cSMain.FindKernel(GetEnumDescription(synthMode)), (int)Mathf.Ceil(_analyzeList[synth.SourceLevel - sampleCompensation].width / 32), (int)Mathf.Ceil(_analyzeList[synth.SourceLevel - sampleCompensation].height / 32), 1); } else { _cSMain.SetTexture(_cSMain.FindKernel(GetEnumDescription(synthMode)), "source", synth.Pyramid[i-1]); _cSMain.SetTexture(_cSMain.FindKernel(GetEnumDescription(synthMode)), "dest", synth.Pyramid[i]); if (synth.Pyramid[i-1].width > 32 || synth.Pyramid[i-1].height > 32) _cSMain.Dispatch(_cSMain.FindKernel(GetEnumDescription(synthMode)), (int)Mathf.Ceil(synth.Pyramid[i-1].width / 32), (int)Mathf.Ceil(synth.Pyramid[i-1].height / 32), 1); else _cSMain.Dispatch(_cSMain.FindKernel(GetEnumDescription(synthMode)), 1, 1, 1); } } } }
public ParticleKillParticleSystem(Synthesis.Game1 game, int howManyEffects) : base(game,howManyEffects) { }
public abstract void Handle(Synthesis e);
void Start() { point = new List <Vector3>(); Synthesis.Init(cl, h, point); }
public SmokePlumeParticleSystem(Synthesis.Game1 game, int howManyEffects) : base(game,howManyEffects) { }
void OnGUI() { GUI.skin = style; Synthesis.Draw_UI("О₂+C=СО₂", ref move_body, ref speed, 1, 5); }
/// <summary> /// Constructs a new ParticleSystem. /// </summary> /// <param name="game">The host for this particle system. The game keeps the /// content manager and sprite batch for us.</param> /// <param name="howManyEffects">the maximum number of particle effects that /// are expected on screen at once.</param> /// <remarks>it is tempting to set the value of howManyEffects very high. /// However, this value should be set to the minimum possible, because /// it has a large impact on the amount of memory required, and slows down the /// Update and Draw functions.</remarks> protected ParticleSystem(Synthesis.Game1 game, int howManyEffects) : base(game) { this.game = game; this.howManyEffects = howManyEffects; }