public void OneTwoThreeSingleCardAllGroups()
        {
            var batch    = GenerateTestCase();
            var result   = GroupingAlgorithms.GetAllOneTwoThreeGroups(batch, new Card(CardNo.Four, CardType.Spades));
            var expected = new List <IList <Card> >
            {
                new List <Card>
                {
                    new Card(CardNo.Ace, CardType.Spades),
                    new Card(CardNo.Two, CardType.Spades),
                    new Card(CardNo.Three, CardType.Spades),
                    new Card(CardNo.Four, CardType.Spades)
                },
                new List <Card>
                {
                    new Card(CardNo.Two, CardType.Spades),
                    new Card(CardNo.Three, CardType.Spades),
                    new Card(CardNo.Four, CardType.Spades)
                },
                new List <Card>
                {
                    new Card(CardNo.Ace, CardType.Spades),
                    new Card(CardNo.Two, CardType.Spades),
                    new Card(CardNo.Three, CardType.Spades)
                }
            };

            Assert.True(result.IsEquivalent(expected, true));
        }
        public void OneTwoThreeSingleCardLargestGroup()
        {
            var batch    = GenerateTestCase();
            var result   = GroupingAlgorithms.GetLargestOneTwoThreeGroup(batch, new Card(CardNo.Four, CardType.Spades));
            var expected = new List <Card>
            {
                new Card(CardNo.Ace, CardType.Spades),
                new Card(CardNo.Two, CardType.Spades),
                new Card(CardNo.Three, CardType.Spades),
                new Card(CardNo.Four, CardType.Spades)
            };

            Assert.True(result.IsEquivalentInOrder(expected));
        }
        public void SevenSevenSevenSingleCardLargestGroup()
        {
            var batch    = GenerateTestCase();
            var result   = GroupingAlgorithms.GetLargestSevenSevenSevenGroup(batch, new Card(CardNo.Four, CardType.Clubs));
            var expected = new List <Card>
            {
                new Card(CardNo.Four, CardType.Hearts),
                new Card(CardNo.Four, CardType.Diamonds),
                new Card(CardNo.Four, CardType.Spades),
                new Card(CardNo.Four, CardType.Clubs)
            };

            Assert.True(result.IsEquivalent(expected));
        }
Example #4
0
    private void Start()
    {
        var cardBatch = new CardBatch
        {
            new Card(CardNo.Ace, CardType.Spades),
            new Card(CardNo.Two, CardType.Spades),
            new Card(CardNo.Three, CardType.Spades),
            new Card(CardNo.Four, CardType.Spades),
            new Card(CardNo.Three, CardType.Diamonds),
            new Card(CardNo.Four, CardType.Diamonds),
            new Card(CardNo.Five, CardType.Diamonds),
            new Card(CardNo.Ace, CardType.Diamonds),
            new Card(CardNo.Ace, CardType.Hearts),
            new Card(CardNo.Four, CardType.Hearts),
            new Card(CardNo.Four, CardType.Clubs)
        };

        var grouping = GroupingAlgorithms.GetSmartGroups(cardBatch);
        var builder  = new StringBuilder();
        var i        = 0;

        foreach (var group in grouping.Groups)
        {
            i++;
            builder.AppendLine("Group " + i + ":");
            foreach (var card in group)
            {
                builder.AppendLine(card.ToString());
            }
            builder.AppendLine();
        }
        builder.AppendLine("Ungrouped Cards:");
        foreach (var card in grouping.Ungrouped)
        {
            builder.AppendLine(card.ToString());
        }
        Debug.Log(builder.ToString());
    }
        public void SmartGroups()
        {
            var batch    = GenerateTestCase();
            var result   = GroupingAlgorithms.GetSmartGroups(batch);
            var expected = new CardGrouping
            {
                Groups =
                {
                    new List <Card>
                    {
                        new Card(CardNo.Ace, CardType.Spades),
                        new Card(CardNo.Two, CardType.Spades),
                        new Card(CardNo.Three, CardType.Spades)
                    },
                    new List <Card>
                    {
                        new Card(CardNo.Four, CardType.Spades),
                        new Card(CardNo.Four, CardType.Hearts),
                        new Card(CardNo.Four, CardType.Clubs)
                    },
                    new List <Card>
                    {
                        new Card(CardNo.Three, CardType.Diamonds),
                        new Card(CardNo.Four, CardType.Diamonds),
                        new Card(CardNo.Five, CardType.Diamonds)
                    }
                },
                Ungrouped =
                {
                    new Card(CardNo.Ace, CardType.Diamonds),
                    new Card(CardNo.Ace, CardType.Hearts)
                }
            };

            Assert.True(result.Groups.IsEquivalent(expected.Groups, false));
            Assert.True(result.Ungrouped.IsEquivalent(expected.Ungrouped));
        }
Example #6
0
 /// <summary>
 /// Sorts the batch by smart grouping.
 /// </summary>
 public void SortBySmartGrouping()
 {
     _cards = GroupingAlgorithms.GetSmartGroups(_cards).ToFlatList();
     OnChange?.Invoke();
 }