示例#1
0
        public void IsSuukantsuTest()
        {
            var melds = new List <Meld>
            {
                MakeMeld(MeldType.KAN, sou: "1111"),
                MakeMeld(MeldType.KAN, sou: "3333"),
                MakeMeld(MeldType.KAN, pin: "5555"),
                MakeMeld(MeldType.CHANKAN, man: "2222")
            };

            IsTrue(new Suukantsu().IsConditionMet(null, new object[] { melds }));

            var tiles   = TileIds.Parse(man: "222", pin: "44555", sou: "111333");
            var winTile = TileId.Parse(pin: "4");

            melds = new List <Meld>
            {
                MakeMeld(MeldType.KAN, sou: "1111"),
                MakeMeld(MeldType.KAN, sou: "3333"),
                MakeMeld(MeldType.KAN, pin: "5555"),
                MakeMeld(MeldType.KAN, man: "2222")
            };
            var result = EstimateHandValue(tiles, winTile, melds);

            AreEqual(null, result.Error);
            AreEqual(13, result.Han);
            AreEqual(70, result.Fu);
            AreEqual(1, result.Yaku.Count);
        }
示例#2
0
        public void PenchanFuTest()
        {
            var config = new HandConfig();

            var tiles   = TileIds.Parse(man: "123456", pin: "55", sou: "12456");
            var winTile = TileId.Parse(sou: "3");
            var hand    = Hand(new TileIds(tiles.Append(winTile)).ToTiles34());

            var(fuDetails, fu) = CalculateFu(hand,
                                             winTile,
                                             GetWinGroup(hand, winTile),
                                             config);

            AreEqual(2, fuDetails.Count);
            IsTrue(fuDetails.Contains(new FuDetail(30, BASE)));
            IsTrue(fuDetails.Contains(new FuDetail(2, PENCHAN)));
            AreEqual(fu, 40);

            tiles   = TileIds.Parse(man: "123456", pin: "55", sou: "34589");
            winTile = TileId.Parse(sou: "7");
            hand    = Hand(new TileIds(tiles.Append(winTile)).ToTiles34());

            (fuDetails, fu) = CalculateFu(hand,
                                          winTile,
                                          GetWinGroup(hand, winTile),
                                          config);

            AreEqual(2, fuDetails.Count);
            IsTrue(fuDetails.Contains(new FuDetail(30, BASE)));
            IsTrue(fuDetails.Contains(new FuDetail(2, PENCHAN)));
            AreEqual(fu, 40);
        }
示例#3
0
        public void DisabledDoubleYakumanTest()
        {
            var tiles   = TileIds.Parse(man: "19", pin: "19", sou: "119", honors: "1234567");
            var winTile = TileId.Parse(sou: "1");
            var result  = EstimateHandValue(tiles, winTile, config: new HandConfig(options: new OptionalRules(hasDoubleYakuman: false)));

            AreEqual(null, result.Error);
            AreEqual(13, result.Han);
            AreEqual(0, result.Fu);
            AreEqual(1, result.Yaku.Count);

            tiles   = TileIds.Parse(man: "333", pin: "44455", sou: "111444");
            winTile = TileId.Parse(pin: "5");
            result  = EstimateHandValue(tiles, winTile, config: new HandConfig(isTsumo: true, options: new OptionalRules(hasDoubleYakuman: false)));
            AreEqual(null, result.Error);
            AreEqual(13, result.Han);
            AreEqual(50, result.Fu);
            AreEqual(1, result.Yaku.Count);

            tiles   = TileIds.Parse(man: "11122345678999");
            winTile = TileId.Parse(man: "2");
            result  = EstimateHandValue(tiles, winTile, config: new HandConfig(options: new OptionalRules(hasDoubleYakuman: false)));
            AreEqual(null, result.Error);
            AreEqual(13, result.Han);
            AreEqual(50, result.Fu);
            AreEqual(1, result.Yaku.Count);

            tiles   = TileIds.Parse(sou: "22", honors: "111222333444");
            winTile = TileId.Parse(honors: "4");
            result  = EstimateHandValue(tiles, winTile, config: new HandConfig(options: new OptionalRules(hasDoubleYakuman: false)));
            AreEqual(null, result.Error);
            AreEqual(13, result.Han);
            AreEqual(60, result.Fu);
            AreEqual(1, result.Yaku.Count);
        }
示例#4
0
        public void ClosedHonorPonFuTest()
        {
            var config = new HandConfig();

            var tiles   = TileIds.Parse(man: "123456", sou: "1178", honors: "111");
            var winTile = TileId.Parse(sou: "6");
            var hand    = Hand(new TileIds(tiles.Append(winTile)).ToTiles34());

            var(fuDetails, fu) = CalculateFu(hand,
                                             winTile,
                                             GetWinGroup(hand, winTile),
                                             config);

            AreEqual(2, fuDetails.Count);
            IsTrue(fuDetails.Contains(new FuDetail(30, BASE)));
            IsTrue(fuDetails.Contains(new FuDetail(8, CLOSED_TERMINAL_PON)));
            AreEqual(fu, 40);

            tiles   = TileIds.Parse(man: "123456", sou: "11678", honors: "11");
            winTile = TileId.Parse(honors: "1");
            hand    = Hand(new TileIds(tiles.Append(winTile)).ToTiles34());

            (fuDetails, fu) = CalculateFu(hand,
                                          winTile,
                                          GetWinGroup(hand, winTile),
                                          config);

            AreEqual(2, fuDetails.Count);
            IsTrue(fuDetails.Contains(new FuDetail(30, BASE)));
            IsTrue(fuDetails.Contains(new FuDetail(4, OPEN_TERMINAL_PON)));
            AreEqual(fu, 40);
        }
示例#5
0
        public void ShantenNumberTest()
        {
            var tiles = TileIds.Parse(man: "567", pin: "11", sou: "111234567");

            AreEqual(AGARI_STATE, CalculateShanten(tiles));

            tiles = TileIds.Parse(man: "567", pin: "11", sou: "111345677");
            AreEqual(0, CalculateShanten(tiles));

            tiles = TileIds.Parse(man: "567", pin: "15", sou: "111345677");
            AreEqual(1, CalculateShanten(tiles));

            tiles = TileIds.Parse(man: "1578", pin: "15", sou: "11134567");
            AreEqual(2, CalculateShanten(tiles));

            tiles = TileIds.Parse(man: "1358", pin: "1358", sou: "113456");
            AreEqual(3, CalculateShanten(tiles));

            tiles = TileIds.Parse(man: "1358", pin: "13588", sou: "1589", honors: "1");
            AreEqual(4, CalculateShanten(tiles));

            tiles = TileIds.Parse(man: "1358", pin: "13588", sou: "159", honors: "12");
            AreEqual(5, CalculateShanten(tiles));

            tiles = TileIds.Parse(man: "1358", pin: "258", sou: "1589", honors: "123");
            AreEqual(6, CalculateShanten(tiles));

            tiles = TileIds.Parse(sou: "11123456788999");
            AreEqual(AGARI_STATE, CalculateShanten(tiles));

            tiles = TileIds.Parse(sou: "11122245679999");
            AreEqual(0, CalculateShanten(tiles));
        }
示例#6
0
        public void IsIttsuTest()
        {
            var tiles = Tiles34.Parse(man: "123456789", sou: "123", honors: "22");

            IsTrue(new Ittsu().IsConditionMet(Hand(tiles)));

            tiles = Tiles34.Parse(man: "112233456789", honors: "22");
            IsTrue(new Ittsu().IsConditionMet(Hand(tiles)));

            tiles = Tiles34.Parse(man: "122334567789", honors: "11");
            IsFalse(new Ittsu().IsConditionMet(Hand(tiles)));

            var tiles_  = TileIds.Parse(man: "123456789", sou: "123", honors: "22");
            var winTile = TileId.Parse(sou: "3");
            var result  = EstimateHandValue(tiles_, winTile);

            AreEqual(null, result.Error);
            AreEqual(2, result.Han);
            AreEqual(40, result.Fu);
            AreEqual(1, result.Yaku.Count);

            var melds = new List <Meld> {
                MakeMeld(MeldType.CHI, man: "123")
            };

            result = EstimateHandValue(tiles_, winTile, melds);
            AreEqual(null, result.Error);
            AreEqual(1, result.Han);
            AreEqual(30, result.Fu);
            AreEqual(1, result.Yaku.Count);
        }
示例#7
0
        public void IsEastTest()
        {
            var(playerWind, roundWind) = (EAST, WEST);

            var tiles = Tiles34.Parse(man: "23422", sou: "234567", honors: "111");

            IsTrue(new YakuhaiEast().IsConditionMet(Hand(tiles), new object[] { playerWind, roundWind }));

            var tiles_  = TileIds.Parse(man: "23422", sou: "234567", honors: "111");
            var winTile = TileId.Parse(honors: "1");
            var result  = EstimateHandValue(tiles_, winTile, config: new HandConfig(
                                                isTsumo: false, isRiichi: false, playerWind: playerWind, roundWind: roundWind));

            AreEqual(null, result.Error);
            AreEqual(1, result.Han);
            AreEqual(40, result.Fu);
            AreEqual(1, result.Yaku.Count);

            roundWind = EAST;
            result    = EstimateHandValue(tiles_, winTile, config: new HandConfig(
                                              isTsumo: false, isRiichi: false, playerWind: playerWind, roundWind: roundWind));
            AreEqual(null, result.Error);
            AreEqual(2, result.Han);
            AreEqual(40, result.Fu);
            AreEqual(2, result.Yaku.Count);
        }
示例#8
0
        public void IsHonrotoTest()
        {
            var tiles = Tiles34.Parse(man: "111", sou: "111999", honors: "11222");

            IsTrue(new Honroto().IsConditionMet(Hand(tiles)));

            tiles = Tiles34.Parse(man: "1199", pin: "11", honors: "22334466");
            IsTrue(new Honroto().IsConditionMet(Hand(tiles)));

            var tiles_  = TileIds.Parse(man: "111", sou: "111999", honors: "11222");
            var winTile = TileId.Parse(honors: "2");
            var melds   = new List <Meld> {
                MakeMeld(MeldType.PON, sou: "111")
            };
            var result = EstimateHandValue(tiles_, winTile, melds);

            AreEqual(null, result.Error);
            AreEqual(4, result.Han);
            AreEqual(50, result.Fu);
            AreEqual(2, result.Yaku.Count);

            tiles_  = TileIds.Parse(man: "1199", pin: "11", honors: "22334466");
            winTile = TileId.Parse(man: "1");
            result  = EstimateHandValue(tiles_, winTile);
            AreEqual(4, result.Han);
            AreEqual(25, result.Fu);
        }
示例#9
0
        public void IsJunchanTest()
        {
            var tiles = Tiles34.Parse(man: "123789", pin: "12399", sou: "789");

            IsTrue(new Junchan().IsConditionMet(Hand(tiles)));

            tiles = Tiles34.Parse(man: "111999", sou: "111", honors: "22333");
            IsFalse(new Junchan().IsConditionMet(Hand(tiles)));

            tiles = Tiles34.Parse(man: "111999", pin: "11999", sou: "111999");
            IsFalse(new Junchan().IsConditionMet(Hand(tiles)));

            var tiles_  = TileIds.Parse(man: "123789", pin: "12399", sou: "789");
            var winTile = TileId.Parse(man: "2");
            var result  = EstimateHandValue(tiles_, winTile);

            AreEqual(null, result.Error);
            AreEqual(3, result.Han);
            AreEqual(40, result.Fu);
            AreEqual(1, result.Yaku.Count);

            var melds = new List <Meld> {
                MakeMeld(MeldType.CHI, sou: "789")
            };

            result = EstimateHandValue(tiles_, winTile, melds);
            AreEqual(null, result.Error);
            AreEqual(2, result.Han);
            AreEqual(30, result.Fu);
            AreEqual(1, result.Yaku.Count);
        }
示例#10
0
        public void IsSanshokuTest()
        {
            var tiles = Tiles34.Parse(man: "123", pin: "12345677", sou: "123");

            IsTrue(new Sanshoku().IsConditionMet(Hand(tiles)));

            tiles = Tiles34.Parse(man: "23455", pin: "123", sou: "123456");
            IsFalse(new Sanshoku().IsConditionMet(Hand(tiles)));

            var tiles_  = TileIds.Parse(man: "12399", pin: "123", sou: "123456");
            var winTile = TileId.Parse(man: "2");
            var result  = EstimateHandValue(tiles_, winTile);

            AreEqual(null, result.Error);
            AreEqual(2, result.Han);
            AreEqual(40, result.Fu);
            AreEqual(1, result.Yaku.Count);

            var melds = new List <Meld> {
                MakeMeld(MeldType.CHI, sou: "123")
            };

            result = EstimateHandValue(tiles_, winTile, melds);
            AreEqual(null, result.Error);
            AreEqual(1, result.Han);
            AreEqual(30, result.Fu);
            AreEqual(1, result.Yaku.Count);
        }
示例#11
0
        public void IsToitoiTest()
        {
            var tiles = Tiles34.Parse(man: "333", pin: "44555", sou: "111333");

            IsTrue(new Toitoi().IsConditionMet(Hand(tiles)));

            tiles = Tiles34.Parse(pin: "777888999", sou: "777", honors: "44");
            IsTrue(new Toitoi().IsConditionMet(Hand(tiles)));

            var tiles_  = TileIds.Parse(man: "333", pin: "44555", sou: "111333");
            var winTile = TileId.Parse(pin: "5");
            var melds   = new List <Meld>
            {
                MakeMeld(MeldType.PON, sou: "111"),
                MakeMeld(MeldType.PON, sou: "333")
            };
            var result = EstimateHandValue(tiles_, winTile, melds);

            AreEqual(null, result.Error);
            AreEqual(2, result.Han);
            AreEqual(40, result.Fu);
            AreEqual(1, result.Yaku.Count);

            tiles_  = TileIds.Parse(pin: "777888999", sou: "777", honors: "44");
            winTile = TileId.Parse(pin: "9");
            melds   = new List <Meld> {
                MakeMeld(MeldType.PON, sou: "777")
            };
            result = EstimateHandValue(tiles_, winTile, melds);
            AreEqual(null, result.Error);
            AreEqual(2, result.Han);
            AreEqual(40, result.Fu);
            AreEqual(1, result.Yaku.Count);
        }
示例#12
0
        public void IsRyanpeikouTest()
        {
            var tiles = Tiles34.Parse(man: "22", pin: "223344", sou: "112233");

            IsTrue(new Ryanpeikou().IsConditionMet(Hand(tiles, 1)));

            tiles = Tiles34.Parse(man: "22", sou: "111122223333");
            IsTrue(new Ryanpeikou().IsConditionMet(Hand(tiles, 1)));

            tiles = Tiles34.Parse(man: "123", pin: "23444", sou: "112233");
            IsFalse(new Ryanpeikou().IsConditionMet(Hand(tiles)));

            var tiles_  = TileIds.Parse(man: "33", pin: "223344", sou: "112233");
            var winTile = TileId.Parse(pin: "3");
            var result  = EstimateHandValue(tiles_, winTile);

            AreEqual(null, result.Error);
            AreEqual(3, result.Han);
            AreEqual(40, result.Fu);
            AreEqual(1, result.Yaku.Count);

            var melds = new List <Meld> {
                MakeMeld(MeldType.CHI, sou: "123")
            };

            result = EstimateHandValue(tiles_, winTile, melds);
            AreNotEqual(null, result.Error);
        }
示例#13
0
        public void StringToTiles136WithAkaDora()
        {
            var tiles = TileIds.Parse(man: "2244", pin: "333r67", sou: "44", hasAkaDora: true);

            IsTrue(tiles.Select(t => t.Value).Contains(FIVE_RED_PIN));

            tiles = TileIds.Parse(man: "2244", pin: "333067", sou: "44", hasAkaDora: true);
            IsTrue(tiles.Select(t => t.Value).Contains(FIVE_RED_PIN));
        }
示例#14
0
        public void IsNagashiManganTest()
        {
            var tiles  = TileIds.Parse(man: "234456", pin: "66", sou: "13579");
            var result = EstimateHandValue(tiles, null, config: new HandConfig(isNagashiMangan: true));

            AreEqual(null, result.Error);
            AreEqual(5, result.Han);
            AreEqual(30, result.Fu);
            AreEqual(1, result.Yaku.Count);
        }
示例#15
0
        public void IsRenhouYakumanTest()
        {
            var tiles   = TileIds.Parse(man: "234456", pin: "66", sou: "123444");
            var winTile = TileId.Parse(sou: "4");
            var result  = EstimateHandValue(tiles, winTile, config: new HandConfig(isRenhou: true, options: new OptionalRules(renhouAsYakuman: true)));

            AreEqual(null, result.Error);
            AreEqual(13, result.Han);
            AreEqual(1, result.Yaku.Count);
        }
示例#16
0
        public void IsNotDaisharinTest()
        {
            var tiles   = TileIds.Parse(pin: "22334455667788");
            var winTile = TileId.Parse(pin: "8");
            var result  = EstimateHandValue(tiles, winTile);

            AreEqual(null, result.Error);
            AreEqual(11, result.Han);
            AreEqual(4, result.Yaku.Count);
        }
示例#17
0
        public void SixtupleYakumanTest()
        {
            var tiles   = TileIds.Parse(honors: "11122233344455");
            var winTile = TileId.Parse(honors: "5");
            var config  = new HandConfig(isTenhou: true);
            var result  = EstimateHandValue(tiles, winTile, config: config);

            AreEqual(null, result.Error);
            AreEqual(78, result.Han);
            AreEqual(192000, result.Cost.Main);
        }
示例#18
0
        public void IsChiihouTest()
        {
            var tiles   = TileIds.Parse(man: "234456", pin: "66", sou: "123444");
            var winTile = TileId.Parse(sou: "4");
            var result  = EstimateHandValue(tiles, winTile, config: new HandConfig(isChiihou: true));

            AreEqual(null, result.Error);
            AreEqual(13, result.Han);
            AreEqual(40, result.Fu);
            AreEqual(1, result.Yaku.Count);
        }
示例#19
0
        public static Meld MakeMeld(MeldType meldType,
                                    string man    = "",
                                    string pin    = "",
                                    string sou    = "",
                                    string honors = "",
                                    bool isOpen   = true)
        {
            var tiles = TileIds.Parse(man: man, pin: pin, sou: sou, honors: honors);

            return(new Meld(meldType, tiles, isOpen, tiles[0], who: 0));
        }
示例#20
0
        public void OneLineStringToTiles136()
        {
            var initialString = "789m456p555s11222z";
            var tiles         = TileIds.Parse(str: initialString);

            AreEqual(14, tiles.Count);

            var newString = tiles.ToOneLineString();

            AreEqual(initialString, newString);
        }
示例#21
0
        public void IsAgariAndOpenHandTest()
        {
            var tiles = TileIds.Parse(man: "345", pin: "222", sou: "23455567");
            var melds = new List <TileKinds>
            {
                StringToOpenTiles34(man: "345"),
                StringToOpenTiles34(sou: "555")
            };

            IsFalse(IsAgari(tiles, melds));
        }
示例#22
0
        public void IsDaisharinTest()
        {
            var tiles   = TileIds.Parse(pin: "22334455667788");
            var winTile = TileId.Parse(pin: "8");
            var result  = EstimateHandValue(tiles, winTile, config: new HandConfig(options: new OptionalRules(hasDaisharin: true)));

            AreEqual(null, result.Error);
            AreEqual(13, result.Han);
            AreEqual(1, result.Yaku.Count);
            AreEqual("Daisharin", result.Yaku[0].Name);
        }
示例#23
0
        public void IsChitoitsuAgariTest()
        {
            var tiles = TileIds.Parse(pin: "1199", sou: "1133557799");

            IsTrue(IsAgari(tiles));

            tiles = TileIds.Parse(man: "11", pin: "1199", sou: "2244", honors: "2277");
            IsTrue(IsAgari(tiles));

            tiles = TileIds.Parse(man: "11223344556677");
            IsTrue(IsAgari(tiles));
        }
示例#24
0
        public void IsNotAgari()
        {
            var tiles = TileIds.Parse(pin: "12345", sou: "123456789");

            IsFalse(IsAgari(tiles));

            tiles = TileIds.Parse(pin: "11145", sou: "111222444");
            IsFalse(IsAgari(tiles));

            tiles = TileIds.Parse(sou: "11122233356888");
            IsFalse(IsAgari(tiles));
        }
示例#25
0
        public void StringToTiles136()
        {
            var expected = new TileIds(new List <int>
            {
                0, 32, 36, 68, 72, 104, 108, 112, 116, 120, 124, 128, 132
            });
            var actual = TileIds.Parse(man: "19", pin: "19", sou: "19", honors: "1234567");

            for (var i = 0; i < expected.Count; i++)
            {
                AreEqual(expected[i].Value, actual[i].Value);
            }
        }
示例#26
0
        public void IsAgariAndClosedKanTest()
        {
            var tiles   = TileIds.Parse(man: "45666777", pin: "111", honors: "222");
            var winTile = TileId.Parse(man: "4");
            var melds   = new List <Meld>
            {
                MakeMeld(MeldType.PON, pin: "111"),
                MakeMeld(MeldType.KAN, man: "6666", isOpen: false),
                MakeMeld(MeldType.PON, man: "777")
            };
            var result = EstimateHandValue(tiles, winTile, melds);

            AreNotEqual(null, result.Error);
        }
示例#27
0
        public void OpenHandWithoutAdditionalFuTest()
        {
            var tiles   = TileIds.Parse(man: "234567", pin: "22", sou: "234678");
            var winTile = TileId.Parse(sou: "6");
            var melds   = new List <Meld> {
                MakeMeld(MeldType.CHI, sou: "234")
            };
            var config = new HandConfig(options: new OptionalRules(hasOpenTanyao: true, fuForOpenPinfu: false));
            var result = EstimateHandValue(tiles, winTile, melds, config: config);

            AreEqual(1, result.Han);
            AreEqual(20, result.Fu);
            AreEqual(700, result.Cost.Main);
        }
示例#28
0
        public void IsIppatsuTest()
        {
            var tiles   = TileIds.Parse(man: "234456", pin: "66", sou: "123444");
            var winTile = TileId.Parse(sou: "4");
            var result  = EstimateHandValue(tiles, winTile, config: new HandConfig(isRiichi: true, isIppatsu: true));

            AreEqual(null, result.Error);
            AreEqual(2, result.Han);
            AreEqual(40, result.Fu);
            AreEqual(2, result.Yaku.Count);

            result = EstimateHandValue(tiles, winTile, config: new HandConfig(isRiichi: false, isIppatsu: true));
            AreNotEqual(null, result.Error);
        }
示例#29
0
        public void IsDaisuushiTest()
        {
            var tiles = Tiles34.Parse(sou: "22", honors: "111222333444");

            IsTrue(new DaiSuushi().IsConditionMet(Hand(tiles)));

            var tiles_  = TileIds.Parse(sou: "22", honors: "111222333444");
            var winTile = TileId.Parse(honors: "4");
            var result  = EstimateHandValue(tiles_, winTile);

            AreEqual(null, result.Error);
            AreEqual(26, result.Han);
            AreEqual(60, result.Fu);
            AreEqual(1, result.Yaku.Count);
        }
示例#30
0
        public void IsDaisangenTest()
        {
            var tiles = Tiles34.Parse(man: "22", sou: "123", honors: "555666777");

            IsTrue(new Daisangen().IsConditionMet(Hand(tiles)));

            var tiles_  = TileIds.Parse(man: "22", sou: "123", honors: "555666777");
            var winTile = TileId.Parse(honors: "7");
            var result  = EstimateHandValue(tiles_, winTile);

            AreEqual(null, result.Error);
            AreEqual(13, result.Han);
            AreEqual(50, result.Fu);
            AreEqual(1, result.Yaku.Count);
        }