コード例 #1
0
 public Shuffler(byte[, ][,] grid)
 {
     this.grid  = grid;
     shuffler   = new SudokuPuzzle.Shuffler(grid);
     gridHeight = grid.GetLength(0);
     gridWidth  = grid.GetLength(1);
 }
コード例 #2
0
ファイル: Card.cs プロジェクト: bin0m/ObjectOrientedDesign
 public CardsDeck(IShuffler <T> shuffler)
 {
     _shuffler       = shuffler;
     _nextCardToDeal = 0;
     InitDeck();
     Shuffle();
 }
コード例 #3
0
 public DecksController(Game game, IMapper <Deck, DeckViewModel> deckMapper, IDrawer drawer, IShuffler shuffler)
 {
     _game       = game;
     _deckMapper = deckMapper;
     _drawer     = drawer;
     _shuffler   = shuffler;
 }
コード例 #4
0
        public void GenerateTeams_GivenFourPlayers_PerfectSolutionsExist_PerfectSolutionFound(
            int p1, int g1,
            int p2, int g2,
            int p3, int g3,
            int p4, int g4)
        {
            IShuffler     shuffler      = A.Fake <IShuffler>();
            TeamGenerator teamGenerator = new TeamGenerator(shuffler);

            Player player1 = new Player()
            {
                Id = 1, Name = "Name1", Points = p1, GamesPlayed = g1
            };
            Player player2 = new Player()
            {
                Id = 2, Name = "Name2", Points = p2, GamesPlayed = g2
            };
            Player player3 = new Player()
            {
                Id = 3, Name = "Name3", Points = p3, GamesPlayed = g3
            };
            Player player4 = new Player()
            {
                Id = 4, Name = "Name4", Points = p4, GamesPlayed = g4
            };

            List <Player> selectedPlayers = new List <Player> {
                player1, player2, player3, player4
            };

            var result = teamGenerator.GenerateTeams(selectedPlayers);

            result.Item1.Sum(p => p.PointsPerGame).Should().Be(1);
            result.Item2.Sum(p => p.PointsPerGame).Should().Be(1);
        }
コード例 #5
0
ファイル: Dealer.cs プロジェクト: Jaecen/Deckard
 public Dealer(
     DeckGenerator deckGenerator,
     IShuffler shuffler)
 {
     DeckGenerator = deckGenerator ?? throw new ArgumentNullException(nameof(deckGenerator));
     Shuffler      = shuffler ?? throw new ArgumentNullException(nameof(shuffler));
 }
コード例 #6
0
 public DataRecordAdapter(IDataConverter dataConverter, IDataReader dataReader, IRecordCache cache, IShuffler shuffler)
 {
     _dataConverter = dataConverter;
     _dataReader    = dataReader;
     _cache         = cache;
     _shuffler      = shuffler;
 }
コード例 #7
0
        public void GenerateTeams_GivenThreePlayers_PerfectSolutionsExist_PerfectSolutionFound(
            int p1, int g1,
            int p2, int g2,
            int p3, int g3)
        {
            IShuffler     shuffler      = A.Fake <IShuffler>();
            TeamGenerator teamGenerator = new TeamGenerator(shuffler);

            Player player1 = new Player()
            {
                Id = 1, Name = "Name1", Points = p1, GamesPlayed = g1
            };
            Player player2 = new Player()
            {
                Id = 2, Name = "Name2", Points = p2, GamesPlayed = g2
            };
            Player player3 = new Player()
            {
                Id = 3, Name = "Name3", Points = p3, GamesPlayed = g3
            };

            List <Player> selectedPlayers = new List <Player> {
                player1, player2, player3
            };

            var    result   = teamGenerator.GenerateTeams(selectedPlayers);
            var    r1       = (double)p1 / g1;
            var    r2       = (double)p2 / g2;
            var    r3       = (double)p3 / g3;
            double expected = (r1 + r2 + r3) / 2;

            result.Item1.Sum(p => p.PointsPerGame).Should().Be(expected);
            result.Item2.Sum(p => p.PointsPerGame).Should().Be(expected);
        }
コード例 #8
0
 public Dealer(Card[] deck, IShuffler shuffler)
 {
     _deck     = deck;
     _shuffler = (BasicShuffler)shuffler;
     ShuffleDeck();
     PrepareDeck();
 }
コード例 #9
0
 public void ShufflerAllChoicesTest()
 {
     foreach (string choice in ShufflerFactory.Choices)
     {
         IShuffler shuffler = ShufflerFactory.Create(choice);
         Assert.IsNotNull(shuffler);
     }
 }
コード例 #10
0
        public Deck(IShuffler shuffler)
        {
            _shuffler = shuffler;

            _cards = new List <Card>();

            Initialize();
        }
コード例 #11
0
ファイル: CardFactory.cs プロジェクト: ilmen/AliasGame
        public CardFactory(int wordsCountInOneCard, IShuffler<string> shuffler, ICutter<string> cutter)
        {
            if (wordsCountInOneCard <= 0) throw new ArgumentException("Параметр wordsCountInOneCard должен быть больше нуля!");

            this.MaxWordsCountInOneCard = wordsCountInOneCard;

            this.Shuffler = shuffler;

            this.Cutter = cutter;
        }
コード例 #12
0
ファイル: When.cs プロジェクト: dflynn1024/katas-2PC
        public static void TheShufflerShufflesTheDeckXTimes(IShuffler shuffler, Deck before, out Deck after, int numberOfShuffles)
        {
            after = (Deck)before.Clone();

            while (numberOfShuffles > 0)
            {
                after = shuffler.Shuffle(before);
                numberOfShuffles--;
            }
        }
コード例 #13
0
        public StandardDeck(IShuffler shuffler, string gameId)
            : base()
        {
            _gameid = gameId;
            Shuffler = shuffler;
            Cards = new HashSet<Card>();
            PokerCalculator.PokerLib.init_deck(deck);

            var ed = new HashSet<int>(expectedDeck);
            var actDeck = new HashSet<int>(deck);
            if (!actDeck.SetEquals(ed)) throw new ApplicationException("The deck returned from the PokerLib is corrupt");
        }
コード例 #14
0
        public void ShufflerCreationTest()
        {
            IShuffler shuffler = ShufflerFactory.Create("Simple Knuth Shuffler");

            Assert.IsNotNull(shuffler);
            Assert.AreEqual("KnuthShuffler", shuffler.GetType().Name);
            shuffler = ShufflerFactory.Create("Modified Knuth Shuffler");
            Assert.IsNotNull(shuffler);
            Assert.AreEqual("ModifiedKnuthShuffler", shuffler.GetType().Name);
            shuffler = ShufflerFactory.Create("No Such Shuffler");
            Assert.IsNull(shuffler);
        }
コード例 #15
0
        public PlayCoordinatorFactory(
            ITurnFactory turnFactory,
            IEndConditionDetector endConditionDetector,
            IPlayerCountConstraint playerCountConstraint,
            IShuffler playerShuffler,
            IGameStateConfigurationInitializer gameStateConfigurationInitializer)
        {
            _turnFactory          = turnFactory;
            _endConditionDetector = endConditionDetector;

            _playerCountConstraint             = playerCountConstraint;
            _playerShuffler                    = playerShuffler;
            _gameStateConfigurationInitializer = gameStateConfigurationInitializer;
        }
コード例 #16
0
ファイル: Game.cs プロジェクト: balandin228/team4
        public static int[,] GenerateField(IShuffler shuffler, int width = 8, int height = 4)
        {
            if (width * height % 2 == 1)
            {
                throw new ArgumentException();
            }

            var ids      = Enumerable.Range(1, width * height / 2);
            var cardsIds = ids.Concat(ids);

            cardsIds = shuffler.Shuffle(cardsIds);

            return(ParseIdsToField(cardsIds, width, height));
        }
コード例 #17
0
 public QuizzesController(
     IResultHelper resultHelper,
     IShuffler shuffler,
     UserManager <ApplicationUser> userManager,
     IQuizzesService quizService,
     IResultsService resultService,
     IDistributedCache distributedCache,
     IQuestionsService questionsService)
 {
     this.resultHelper     = resultHelper;
     this.shuffler         = shuffler;
     this.userManager      = userManager;
     this.quizService      = quizService;
     this.resultService    = resultService;
     this.distributedCache = distributedCache;
     this.questionsService = questionsService;
 }
コード例 #18
0
        public PlantationDeck(int playerCount, int randomSeed)
        {
            _random   = new Random(randomSeed);
            _shuffler = new FisherYatesShuffler(new CustomRandomWrapper(_random));

            _deck = new List <IPlantation>(Config.Values.Sum());
            _deck.AddRange(InitPlantationsForType <IndigoPlantation>(Config[typeof(IndigoPlantation)]));
            _deck.AddRange(InitPlantationsForType <SugarPlantation>(Config[typeof(SugarPlantation)]));
            _deck.AddRange(InitPlantationsForType <CornPlantation>(Config[typeof(CornPlantation)]));
            _deck.AddRange(InitPlantationsForType <TobaccoPlantation>(Config[typeof(TobaccoPlantation)]));
            _deck.AddRange(InitPlantationsForType <CoffeePlantation>(Config[typeof(CoffeePlantation)]));
            _deck = _deck.Shuffle(_shuffler);

            _visibleCount = playerCount + 1;
            Drawable      = new IPlantation[_visibleCount];
            DiscardAndDrawNew();
        }
コード例 #19
0
 public ShuffleTests()
 {
     NumberGenerator.Enqueue(1);
     NumberGenerator.Enqueue(2);
     NumberGenerator.Enqueue(1);
     NumberGenerator.Enqueue(2);
     NumberGenerator.Enqueue(1);
     NumberGenerator.Enqueue(2);
     NumberGenerator.Enqueue(1);
     NumberGenerator.Enqueue(2);
     NumberGenerator.Enqueue(1);
     _shuffler = new FisherYatesShuffler <int>(ShuffleForTest);
     _numbers  = new List <int>();
     for (int i = 1; i <= NumbersCount; i++)
     {
         _numbers.Add(i);
     }
 }
コード例 #20
0
        public void GenerateTeams_GivenOddPlayers_EvenSplitReturned_Team1WithMorePlayers(int numberOfPlayers)
        {
            IShuffler     shuffler      = A.Fake <IShuffler>();
            TeamGenerator teamGenerator = new TeamGenerator(shuffler);

            List <Player> selectedPlayers = new List <Player>();

            for (int i = 1; i <= numberOfPlayers; i++)
            {
                selectedPlayers.Add(new Player()
                {
                    Id = i, Name = "Name" + i, Points = 1, GamesPlayed = 1
                });
            }

            var result = teamGenerator.GenerateTeams(selectedPlayers);

            result.Item1.Count().Should().Be((numberOfPlayers + 1) / 2);
            result.Item2.Count().Should().Be((numberOfPlayers - 1) / 2);
        }
コード例 #21
0
 public Cards()
 {
     DeckOfCards = new StandardDeck();
     shuffler    = new ShufflerInt();
     deckSorter  = new SortByNewDeck();
 }
コード例 #22
0
 public void TestInitialize()
 {
     _board    = new Board();
     _sorter   = new Sorter();
     _shuffler = new Shuffler();
 }
コード例 #23
0
 public StandardDeck(IShuffler <ICard> shuffler) : base(shuffler)
 {
     cards = getFiftyTwoCardsStandardDeck();
 }
コード例 #24
0
ファイル: Dealer.cs プロジェクト: tekavec/WarGameKata
 public Dealer(IShuffler shuffler)
 {
     _Shuffler = shuffler;
 }
コード例 #25
0
 public PairOfSixSidedDice(IShuffler shuffler)
 {
     _randomDieRoller = shuffler;
 }
コード例 #26
0
 public Cards(IDeck deck, IShuffler shuffler, IDeckSorter deckSorter)
 {
     this.DeckOfCards = deck;
     this.shuffler    = shuffler;
     this.deckSorter  = deckSorter;
 }
コード例 #27
0
ファイル: Game.cs プロジェクト: tekavec/WarGameKata
 public Dealer NewDealer(IShuffler shuffler)
 {
     return new Dealer(shuffler);
 }
コード例 #28
0
 public Deck()
 {
     Shuffler = new ShufflerFisherYates <ICard>();
 }
コード例 #29
0
 public Deck(IShuffler <ICard> shuffler)
 {
     Shuffler = shuffler;
 }
コード例 #30
0
ファイル: ShufflerTests.cs プロジェクト: dflynn1024/katas-2PC
 public ShufflerTests(SystemUnderTestFixture <Shuffler> fixture)
 {
     _shuffler = fixture.SystemUnderTest;
 }
コード例 #31
0
 public DeckFactory(
     IShuffler shuffler)
 {
     _shuffler = shuffler;
 }
コード例 #32
0
ファイル: Deck.cs プロジェクト: codymullins/DeckOfCards
 /// <summary>
 /// Deck constructor accepting the cards to be used in this deck instance.
 /// </summary>
 /// <param name="cards">The cards to be used for this specific deck.</param>
 /// <param name="shuffler"></param>
 public Deck(IEnumerable<Card> cards, IShuffler<Card> shuffler)
 {
     _cards = cards.ToList();
     _shuffler = shuffler;
 }
コード例 #33
0
 public TurnOrderController(GameObject[] entities, IShuffler <GameObject> shuffler)
     : this(shuffler.shuffle(entities))
 {
 }
コード例 #34
0
 public static Game CreateGame(string tableId, GameType gameType, IShuffler shuffler)
 {
     return new OFCP_Game(tableId, Guid.NewGuid().ToString(), shuffler);
 }
コード例 #35
0
ファイル: TeamGenerator.cs プロジェクト: k-o-t-n/SfwFootball
 public TeamGenerator(IShuffler shuffler)
 {
     _shuffler = shuffler;
 }
コード例 #36
0
 public TeamGenerationModelBuilder(IPlayerRepository playerRepository, IShuffler shuffler)
 {
     _playerRepository = playerRepository;
     _shuffler = shuffler;
 }
コード例 #37
0
 /// <summary>
 /// Конструктор по умолчанию.
 /// </summary>
 public ShuffleService(IShuffler <ICard> shuffler, IOptionsMonitor <ShuffleSettings> settings)
 {
     _shuffler = shuffler;
     _settings = settings;
 }
コード例 #38
0
 public DeckServiceTests()
 {
     _shuffler = Substitute.For <IShuffler>();
     _factory  = new DeckFactory(_shuffler);
 }