Ejemplo n.º 1
0
        public void シャンテン数(int expected, params TileType[] tiles)
        {
            var round = Game.Create(0, new RuleSetting()).ResetRound(tiles).Round;

            {
                var hand = round.players[0].hand;
                hand.tiles.Clear();
                hand.tiles.AddRange(RandomUtil.GenerateShuffledArray(tiles.Select(_ => new Tile(0, _, red: false)).ToList()));
                var solution = hand.Solve();
                Assert.AreEqual(expected, solution.向聴数);
                Assert.IsTrue(hand.向聴数IsLessThanOrEqual(expected));

                if (expected == -1)
                {
                    var completed = solution.ChoiceCompletedHand(newTileInHand: tiles[0], ownWind: TileType.東, roundWind: TileType.南,
                                                                 ronTarget: null,
                                                                 riichi: true,
                                                                 doubleRiichi: false,
                                                                 openRiichi: false,
                                                                 一発: false,
                                                                 嶺上: false,
                                                                 海底: false,
                                                                 河底: false,
                                                                 天和: false,
                                                                 地和: false,
                                                                 人和: false,
                                                                 doraTiles: new TileType[0],
                                                                 uraDoraTiles: new TileType[0],
                                                                 槍槓: false,
                                                                 handCap: round.game.rule.handCap);
                    var player = round.players[(int)round.dealer + 1];
                    CompletedHand.Execute(new Dictionary <Player, CompletedHand>()
                    {
                        { player, completed }
                    }, out var roundResult, out var results);
                    var result = results[player];
                    Debug.Log(result.tsumoPenalty !.Value);
                    Debug.Log(result.displayScore?.han + "翻 " + result.displayScore?.fu + "符 " + result.scoreType);
                    Debug.Log(string.Join(", ", completed.Yakus.Keys.Concat(completed.役満.Keys)));
                    Assert.AreEqual(0, roundResult.scoreDiffs !.Values.Sum());
                }
            }

            // 上がりからひとつ抜いたらリーチ
            if (expected == -1)
            {
                var hand = round.players[0].hand;
                hand.tiles.Clear();
                hand.tiles.AddRange(tiles.Select(_ => new Tile(0, _, red: false)));

                foreach (var it in hand.tiles)
                {
                    var h = hand.Clone();
                    h.tiles.Remove(it);
                    var solution = h.Solve();
                    Assert.AreEqual(expected + 1, solution.向聴数);
                    Assert.IsTrue(h.向聴数IsLessThanOrEqual(expected + 1));
                }
            }
        }
Ejemplo n.º 2
0
        public void GetWinningTiles(TileType[] expecteds, params TileType[] handTiles)
        {
            var round = Game.Create(0, new RuleSetting()).Round;

            var hand = round.players[0].hand;

            hand.tiles.Clear();
            hand.tiles.AddRange(RandomUtil.GenerateShuffledArray(handTiles.Select(_ => new Tile(0, _, red: false)).ToList()));
            Assert.AreEqual(
                expecteds.OrderBy(_ => _).ToArray(),
                hand.GetWinningTiles().OrderBy(_ => _).ToArray());
            Assert.IsTrue(hand.向聴数IsLessThanOrEqual(0));
            Assert.IsTrue(hand.向聴数IsLessThan(1));
            Assert.IsFalse(hand.向聴数IsLessThanOrEqual(-1));
            Assert.IsFalse(hand.向聴数IsLessThan(0));
        }
Ejemplo n.º 3
0
        public void 親ツモ(int expected, TileType ツモ牌, TileType ownWind, TileType roundWind,
                        bool riichi,
                        params TileType[] tiles)
        {
            var round = Game.Create(0, new RuleSetting()).ResetRound(tiles).Round;

            var hand = round.players[0].hand;

            hand.tiles.Clear();
            hand.tiles.AddRange(RandomUtil.GenerateShuffledArray(tiles.Select(_ => new Tile(0, _, red: false)).ToList()));
            var solution = hand.Solve();

            Assert.AreEqual(-1, solution.向聴数);

            var completed = solution.ChoiceCompletedHand(newTileInHand: ツモ牌, ownWind: ownWind, roundWind: roundWind,
                                                         ronTarget: null,
                                                         riichi: riichi,
                                                         doubleRiichi: false,
                                                         openRiichi: false,
                                                         一発: false,
                                                         嶺上: false,
                                                         海底: false,
                                                         河底: false,
                                                         天和: false,
                                                         地和: false,
                                                         人和: false,
                                                         doraTiles: new TileType[0],
                                                         uraDoraTiles: new TileType[0],
                                                         槍槓: false,
                                                         handCap: round.game.rule.handCap);

            var player = round.Dealer;

            CompletedHand.Execute(new Dictionary <Player, CompletedHand>()
            {
                { player, completed }
            },
                                  out var roundResult,
                                  out var results);
            var result = results[player];

            Debug.Log(string.Join(", ", completed.Yakus.Keys.Concat(completed.役満.Keys)));
            Debug.Log(result.displayScore?.han + "翻 " + result.displayScore?.fu + "符 " + result.scoreType);
            Assert.AreEqual(expected, result.dealerTsumoPenalty);
            Assert.AreEqual(0, roundResult.scoreDiffs !.Values.Sum());
        }