예제 #1
0
        public void Can_shuffle_cards()
        {
            var cardsProvider = new CardsProvider();
            var cards         = cardsProvider.Provide().ToList();

            var shuffled = cards.ShuffleList().ToList();

            Check.That(shuffled.Count).IsEqualTo(cards.Count);
            Check.That(shuffled).IsEquivalentTo(cards);
            Check.ThatCode(() => { Check.That(shuffled).ContainsExactly(cards); }).Throws <NUnit.Framework.AssertionException>();
        }
예제 #2
0
            public AIInstance(InstanceSelector instanceSelector, int instanceNumber, Queue decisionRequestQueue, AIRandomControl aiRandomControl)
            {
                taskTrees = new Dictionary <RequestedInfoKey, InfoProviderTaskTree>();

                this.instanceSelector     = instanceSelector;
                this.instanceNumber       = instanceNumber;
                this.decisionRequestQueue = decisionRequestQueue;
                this.decisionInProgress   = new object();

                //Setup the AI's and providers here
                infoStore = new InfoCollection();

                infoProviderDictList = new Dictionary <InfoProviderType, InfoProviderBase>();
                aiDictList           = new Dictionary <AIGeneration, AIBase>();

                //Setup the 1st infostore instance
                var GP   = new GameProvider(infoStore, infoProviderDictList, aiRandomControl);
                var WRP  = new ProviderWinRatio.WinRatioProvider(infoStore, infoProviderDictList, aiRandomControl);
                var BP   = new BetsProvider(infoStore, infoProviderDictList, aiRandomControl);
                var CP   = new CardsProvider(infoStore, infoProviderDictList, aiRandomControl);
                var AP   = new AggressionProvider(infoStore, infoProviderDictList, aiRandomControl);
                var PAPP = new PlayerActionPredictionProvider(infoStore, infoProviderDictList, aiRandomControl);

                //Hard lock the infostore collection preventing any further changes.
                infoStore.HardLockInfoList();

                //Setup the AI list
                //We are going to lock the AI's into random mode.
                aiDictList.Add(AIGeneration.SimpleV1, new SimpleAIV1(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV2, new SimpleAIV2(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV1, new NeuralAIv1(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV3, new SimpleAIV3(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV2, new NeuralAIv2(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV4AggressionTrack, new SimpleAIV4AggTrack(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV3, new NeuralAIv3(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV4, new NeuralAIv4(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV5, new SimpleAIv5(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV6, new SimpleAIv6(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV5, new NeuralAIv5(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV6, new NeuralAIv6(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV7, new SimpleAIv7(aiRandomControl));
                aiDictList.Add(AIGeneration.CheatV1, new CheatV1(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV7, new NeuralAIv7(aiRandomControl));

                if (ConcurrencyMode.Concurrency == ConcurrencyMode.ConcurencyModel.MultiCore)
                {
                    providerTasks = new Dictionary <InfoProviderType, Task>();
                }
                else
                {
                    providerActions = new Dictionary <InfoProviderType, Action>();
                }
            }
예제 #3
0
        public void Provide_all_52_card()
        {
            var provider = new CardsProvider();
            var cards    = provider.Provide().ToArray();

            Console.WriteLine(string.Join(", ", cards));

            var everyCardValueHasCards = 4;

            foreach (var cardValue in Card.ValidValuesRange)
            {
                Check.That(cards.Where(c => c.Value == cardValue)).HasSize(everyCardValueHasCards);
                Check.That(cards.Select(c => c.Figure).Distinct()).IsEquivalentTo(Figure.Club, Figure.Diamond, Figure.Heart, Figure.Spade);
            }
        }
예제 #4
0
    public void OpenDeck(string identity = null)
    {
        var deckProvider  = new DeckProvider();
        var cardsProvider = new CardsProvider();

        var deck = deckProvider.GetDeck(identity ?? GameController.Controller.PlayerManager.EquippedDeck);

        Cards = cardsProvider.CloneCardsFromDeck(deck).ToList();

        foreach (var card in Cards)
        {
            card.Zone = CardZone.Deck;
            card.StartListening();
        }
    }
예제 #5
0
        private static ICardsProvider GetCards()
        {
            var sourceFiles = new List <string>(new DirectoryInfo(@"F:\Projects\Drinctet\cards").GetFiles("*.xml")
                                                .Select(x => x.FullName));

            var settings = new XmlReaderSettings {
                ConformanceLevel = ConformanceLevel.Fragment
            };
            var provider = new CardsProvider();

            var sw = Stopwatch.StartNew();

            foreach (var sourceFile in sourceFiles)
            {
                using (var reader = XmlReader.Create(sourceFile, settings))
                {
                    provider.AddCards(reader, sourceFile);
                }
            }

            Console.WriteLine($"Parsed {provider.Cards.Count} cards in {sw.ElapsedMilliseconds} ms");

            return(provider);
        }