Пример #1
0
        private static void Main(string[] args)
        {
            random_ = new Random();
            var wall  = new List <int>(Enumerable.Range(0, 136));
            var count = wall.Count;

            for (var i = 0; i < count; i++)
            {
                var r = random_.Next(i, count);
                (wall[i], wall[r]) = (wall[r], wall[i]);
            }
            var hand     = new TileIds(wall.GetRange(0, 13));
            var discards = new List <int>();

            wall.RemoveRange(0, 13);

            for (var c = wall.Count; c > 0; c--)
            {
                hand.Add(wall[0]);
                wall.RemoveAt(0);

                PrintTiles(hand);

                var res = HandCalculator.EstimateHandValue(hand, hand.Last() /*, config:new HandConfig(isTsumo:true)*/);
                if (res.Error is null)
                {
                    Console.WriteLine("");
                    PrintHandResult(hand, hand.Last(), null, res);
                    break;
                }
                discards.Add(DecideDahai(hand));

                PrintTiles(hand);
            }
        }
Пример #2
0
        public void Tsumo(HandConfig config)
        {
            var tsumo = wall_.Tsumo();

            if (tsumo is null)
            {
                return;
            }

            Hand.Tsumo(tsumo);
            var result = HandCalculator.EstimateHandValue(Hand.AllTiles,
                                                          Hand.TsumoTile,
                                                          doraIndicators: DoraIndicators,
                                                          config: config);

            if (result.Error is null)
            {
                IsAgari = true;
                Result  = result;
            }
            else
            {
                IsAgari = false;
                Result  = null;
            }
        }
Пример #3
0
        public ViewModel()
        {
            appService_ = new PlayerApplicationService("yamada");

            appService_.RequestJoin();

            appService_.JoinEvent += (_, e) =>
            {
                System.Console.WriteLine($"id: {e.JoinRes.Id}");
                appService_.RequestHand();
            };
            appService_.HandEvent += (_, e) =>
            {
                Hand = e.HandRes.Hand;
                System.Console.WriteLine($"hand: {Hand.ToOneLineString()}");
                appService_.RequestTsumo();
            };
            appService_.TsumoEvent += (_, e) =>
            {
                var tsumo = e.TsumoRes.Tsumo;
                System.Console.WriteLine($"tsumo: {tsumo.ToOneLineString()}");
                Hand.Add(tsumo);
                System.Console.WriteLine($"shanten: {Shanten.CalculateShanten(Hand)}");
                var result = HandCalculator.EstimateHandValue(Hand, tsumo, config: new HandConfig(isTsumo: true));
                if (result.Error is null)
                {
                    appService_.RequestAgari();
                    return;
                }
                var index = DecideDahai();
                Hand.RemoveAt(index);
                appService_.RequestDahai(index);
            };
            appService_.DahaiEvent += (_, e) => appService_.RequestTsumo();
            appService_.AgariEvent += (_, e) =>
            {
                var res = e.AgariRes;
                PrintHandResult(res.Tiles, res.WinTile, res.Melds, res.Result);
            };
        }
Пример #4
0
        private static void Main(string[] args)
        {
            /***********************************************************************/
            /* タンヤオ ロン                                                       */
            /***********************************************************************/
            var tiles   = TileIds.Parse(man: "22444", pin: "333567", sou: "444");
            var winTile = TileId.Parse(sou: "4");
            var result  = HandCalculator.EstimateHandValue(tiles, winTile);

            PrintHandResult(tiles, winTile, null, result);

            /***********************************************************************/
            /* タンヤオ ツモ                                                       */
            /***********************************************************************/
            result = HandCalculator.EstimateHandValue(tiles, winTile, config: new HandConfig(isTsumo: true));
            PrintHandResult(tiles, winTile, null, result);

            /***********************************************************************/
            /* 副露追加                                                             */
            /***********************************************************************/
            var melds = new List <Meld>
            {
                new Meld(MeldType.PON, tiles: TileIds.Parse(man: "444"))
            };
            var config = new HandConfig(options: new OptionalRules(hasOpenTanyao: true));

            result = HandCalculator.EstimateHandValue(tiles, winTile, melds, config: config);
            PrintHandResult(tiles, winTile, melds, result);

            /***********************************************************************/
            /* シャンテン数計算                                                             */
            /***********************************************************************/
            tiles = TileIds.Parse(man: "13569", pin: "123459", sou: "443");
            var shanten = Shanten.CalculateShanten(tiles);

            Console.WriteLine(tiles.ToOneLineString());
            Console.WriteLine($"{shanten}シャンテン");
            Console.WriteLine("");

            /***********************************************************************/
            /* 数え役満                                                             */
            /***********************************************************************/
            //13翻打ち止め
            tiles   = TileIds.Parse(man: "22244466677788");
            winTile = TileId.Parse(man: "7");
            melds   = new List <Meld>
            {
                new Meld(MeldType.KAN, TileIds.Parse(man: "2222"), opened: false)
            };
            var doraIndicators = TileIds.Parse(man: "1111"); //ドラ表示牌

            config = new HandConfig(isRiichi: true, options: new OptionalRules(kazoeLimit: Kazoe.Limited));
            result = HandCalculator.EstimateHandValue(tiles, winTile, melds, doraIndicators, config);
            PrintHandResult(tiles, winTile, melds, result);

            //三倍満扱い
            config = new HandConfig(isRiichi: true, options: new OptionalRules(kazoeLimit: Kazoe.Sanbaiman));
            result = HandCalculator.EstimateHandValue(tiles, winTile, melds, doraIndicators, config);
            PrintHandResult(tiles, winTile, melds, result);

            //13翻ごとに役満を重ねる(26翻でダブル役満)
            config = new HandConfig(isRiichi: true, options: new OptionalRules(kazoeLimit: Kazoe.Nolimit));
            result = HandCalculator.EstimateHandValue(tiles, winTile, melds, doraIndicators, config);
            PrintHandResult(tiles, winTile, melds, result);
        }