public static void Main() { Console.WriteLine("================== Running simple =================="); Console.WriteLine(); //// Actually it is not necessary to have the strategy and disposable extensions in a using scope. //// The bootstrapper takes care of that. I use it here to calm FxCop ;) using (var simpleBootstrapper = new DefaultBootstrapper <ISimpleExtension>()) using (var simpleStrategy = new SimpleStrategy()) using (var thirdSimpleExtension = new ThirdSimpleExtension()) { simpleBootstrapper.Initialize(simpleStrategy); simpleBootstrapper.AddExtension(new FirstSimpleExtension()); simpleBootstrapper.AddExtension(new SecondSimpleExtension()); simpleBootstrapper.AddExtension(thirdSimpleExtension); simpleBootstrapper.Run(); simpleBootstrapper.Shutdown(); } Console.WriteLine("================== End simple =================="); Console.WriteLine("Press any key to continue"); Console.ReadLine(); Console.WriteLine("================== Running complex =================="); Console.WriteLine(); //// Actually it is not necessary to have the strategy and disposable extensions in a using scope. //// The bootstrapper takes care of that. I use it here to calm FxCop ;) using (var complexBootstrapper = new DefaultBootstrapper <IComplexExtension>()) using (var complexStrategy = new ComplexStrategy()) { complexBootstrapper.Initialize(complexStrategy); complexBootstrapper.AddExtension(new Log4NetExtension()); complexBootstrapper.AddExtension(new ExtensionWhichRegistersSomething()); complexBootstrapper.AddExtension(new ExtensionWhichNeedsDependency()); complexBootstrapper.AddExtension(new ExtensionWhichIsFunqlet()); complexBootstrapper.AddExtension(new ExtensionWithExtensionConfigurationSection()); complexBootstrapper.AddExtension( new ExtensionWithExtensionConfigurationSectionWithConversionAndCustomizedLoading()); complexBootstrapper.AddExtension(new ExtensionWithExtensionConfigurationSectionWithDictionary()); complexBootstrapper.Run(); complexBootstrapper.Shutdown(); } Console.WriteLine("================== End complex =================="); Console.WriteLine("Press any key to continue"); Console.ReadLine(); }
public static void Main() { Console.WriteLine("================== Running simple =================="); Console.WriteLine(); //// Actually it is not necessary to have the strategy and disposable extensions in a using scope. //// The bootstrapper takes care of that. I use it here to calm FxCop ;) using (var simpleBootstrapper = new DefaultBootstrapper<ISimpleExtension>()) using (var simpleStrategy = new SimpleStrategy()) using (var thirdSimpleExtension = new ThirdSimpleExtension()) { simpleBootstrapper.Initialize(simpleStrategy); simpleBootstrapper.AddExtension(new FirstSimpleExtension()); simpleBootstrapper.AddExtension(new SecondSimpleExtension()); simpleBootstrapper.AddExtension(thirdSimpleExtension); simpleBootstrapper.Run(); simpleBootstrapper.Shutdown(); } Console.WriteLine("================== End simple =================="); Console.WriteLine("Press any key to continue"); Console.ReadLine(); Console.WriteLine("================== Running complex =================="); Console.WriteLine(); //// Actually it is not necessary to have the strategy and disposable extensions in a using scope. //// The bootstrapper takes care of that. I use it here to calm FxCop ;) using (var complexBootstrapper = new DefaultBootstrapper<IComplexExtension>()) using (var complexStrategy = new ComplexStrategy()) { complexBootstrapper.Initialize(complexStrategy); complexBootstrapper.AddExtension(new Log4NetExtension()); complexBootstrapper.AddExtension(new ExtensionWhichRegistersSomething()); complexBootstrapper.AddExtension(new ExtensionWhichNeedsDependency()); complexBootstrapper.AddExtension(new ExtensionWhichIsFunqlet()); complexBootstrapper.AddExtension(new ExtensionWithExtensionConfigurationSection()); complexBootstrapper.AddExtension( new ExtensionWithExtensionConfigurationSectionWithConversionAndCustomizedLoading()); complexBootstrapper.AddExtension(new ExtensionWithExtensionConfigurationSectionWithDictionary()); complexBootstrapper.Run(); complexBootstrapper.Shutdown(); } Console.WriteLine("================== End complex =================="); Console.WriteLine("Press any key to continue"); Console.ReadLine(); }
public void Should_ReturnThreeReplicasPerToken() { var target = new SimpleStrategy(2); var testData = ReplicationStrategyTestData.Create(); var result = target.ComputeTokenToReplicaMap( testData.Ring, testData.PrimaryReplicas, testData.NumberOfHostsWithTokens, testData.Datacenters); // 3 dcs, 3 hosts per rack, 3 racks per dc, 10 tokens per host Assert.AreEqual(10 * 3 * 3 * 3, result.Count); foreach (var token in result) { Assert.AreEqual(2, token.Value.Count); } }
public void SomePlayersTurnTest(byte dealerCard, uint initialMoney, uint initialWager, Decks playingDecks, byte decisionsCounter, uint firstSum, uint firstWager, uint secondSum, uint secondWager, Decisions[] playerDecisions, uint balance, byte bjFlag = 0, bool surrenderFlag = false, bool cardsCounterStrategyFlag = false, bool simpleStrategyFlag = false) { if (cardsCounterStrategyFlag) { CardsCounterStrategy somePlayer = new CardsCounterStrategy(dealerCard, initialMoney, playingDecks, initialWager); SomeStrategyTest(somePlayer, decisionsCounter, firstSum, firstWager, secondSum, secondWager, playerDecisions, balance, bjFlag, surrenderFlag); } else if (simpleStrategyFlag) { SimpleStrategy somePlayer = new SimpleStrategy(dealerCard, initialMoney, playingDecks, initialWager); SomeStrategyTest(somePlayer, decisionsCounter, firstSum, firstWager, secondSum, secondWager, playerDecisions, balance, bjFlag, surrenderFlag); } else { Player somePlayer = new Player(dealerCard, initialMoney, playingDecks, initialWager); SomeStrategyTest(somePlayer, decisionsCounter, firstSum, firstWager, secondSum, secondWager, playerDecisions, balance, bjFlag, surrenderFlag); } }
public GameMove GetMove(Pod pod) { var strategy = new SimpleStrategy(); // return strategy.GetMove(pod); }
public Situation Simulate(Pod pod1, Pod pod2, Pod opp1, Pod opp2, GameMove[] moves, bool Opp = false) { var strategy = new SimpleStrategy(); Console.SetError(StreamWriter.Null); var fastStrat = new FastStrategy(OppDepth); if (!Opp) { moves[2] = strategy.GetMove(opp1); moves[3] = strategy.GetMove(opp2); } else { GameMove[] oppMoves = fastStrat.GetMoves(new Pod[] { opp1, opp2 }, new Pod[] { pod1, pod2 }); moves[2] = oppMoves[0]; moves[3] = oppMoves[1]; } var standardError = new StreamWriter(Console.OpenStandardError()); standardError.AutoFlush = true; Console.SetError(standardError); Pod[] sPod = new Pod[4]; sPod[0] = new Pod(pod1); sPod[1] = new Pod(pod2); sPod[2] = new Pod(opp1); sPod[3] = new Pod(opp2); Pod.UpdatePos(sPod, moves); GameMove[] moves2 = new GameMove[4]; GameMove.Copy(moves, moves2, 4); for (int i = 0; i < SimpleSimDepth; i++) { moves2[0] = strategy.GetMove(sPod[0]); moves2[1] = strategy.GetMove(sPod[1]); moves2[2] = strategy.GetMove(sPod[2]); moves2[3] = strategy.GetMove(sPod[3]); Pod.UpdatePos(sPod, moves2); } return new Situation(sPod); }
public Situation SimulateHR(Pod pod1, Pod pod2, Pod opp1, Pod opp2, GameMove[] moves, int runner) { var strategy = new SimpleStrategy(); Console.SetError(StreamWriter.Null); var fastStrat = new FastStrategy(OppDepth); moves[2] = strategy.GetMove(opp1); moves[3] = strategy.GetMove(opp2); var standardError = new StreamWriter(Console.OpenStandardError()); standardError.AutoFlush = true; Console.SetError(standardError); Pod[] sPod = new Pod[4]; sPod[0] = new Pod(pod1); sPod[1] = new Pod(pod2); sPod[2] = new Pod(opp1); sPod[3] = new Pod(opp2); Pod.UpdatePos(sPod, moves); GameMove[] moves2 = new GameMove[4]; GameMove.Copy(moves, moves2, 4); for (int i = 0; i < SimpleSimDepth; i++) { moves2[runner] = strategy.GetMove(sPod[runner]); moves2[runner ^ 1] = strategy.GetMoveHit(sPod, runner ^ 1); moves2[2] = strategy.GetMove(sPod[2]); moves2[3] = strategy.GetMove(sPod[3]); Pod.UpdatePos(sPod, moves2); } return new Situation(sPod); }
static void Main(string[] args) { InitialInput(); Simulator sim = new Simulator(); int count = 0; int mainDepth = C - 1; while (true) { count++; for (int i = 0; i < 2; i++) { pod[i].Update(Console.ReadLine()); } for (int i = 0; i < 2; i++) { opp[i].Update(Console.ReadLine()); } var strategy = new SimpleStrategy(); GameMove[] moves = new GameMove[4]; if (count < 7) { moves[0] = strategy.GetMove(pod[0]); moves[1] = strategy.GetMove(pod[1]); } else if (count < 50) { var faststrategy = new FastStrategy(); moves = faststrategy.GetMoves(pod, opp); } else { var hitandrun = new HitStrategy(); moves = hitandrun.GetMoves(pod, opp); } if (count == 1) { moves[0].Thrust = 200; moves[1].Thrust = 200; } moves[0].Print(); moves[1].Print(); } }