Пример #1
0
        private static int AnkouCountWithWait(int waitIndex, Arrangement a)
        {
            var offWaitAnkou  = a.Blocks.Count(b => b.IsKoutsu && b.Index != waitIndex);
            var onWaitAnkou   = a.Blocks.Count(b => b.IsKoutsu && b.Index == waitIndex);
            var onWaitShuntsu = a.Blocks.Count(b => b.IsShuntsu && waitIndex >= b.Index && waitIndex <= b.Index + 2);

            // on wait ankou can only count if there also is an on wait shuntsu to consume the wait.
            return(offWaitAnkou + onWaitAnkou * onWaitShuntsu);
        }
        private static bool Matches(ArrangementGroup arrangements, Arrangement arrangement, FuConstraint constraint)
        {
            if (constraint.DoujunIndex >= 0 && !arrangement.ContainsShuntsu(constraint.DoujunIndex))
            {
                // open hands with less than 6 tiles in the arrangement can use a meld to get sanshoku
                if (arrangements.TileCount > 5 || !constraint.Open)
                {
                    return(false);
                }
            }

            if (constraint.DoukouIndex >= 0 && !arrangement.ContainsKoutsu(constraint.DoukouIndex))
            {
                // hands with less than 6 tiles in the arrangement can use a meld to get sanshoku. If closed must be ankan
                if (arrangements.TileCount > 5)
                {
                    return(false);
                }
            }

            var hasIipeikou = arrangement.Blocks.Where(b => b.IsShuntsu).GroupBy(s => s.Index).Any(g => g.Count() >= 2);

            if (arrangements.HasIipeikou && !constraint.Open && !hasIipeikou)
            {
                if (!arrangements.HasSquareType || constraint.SquareIsNotSanankou)
                {
                    return(false);
                }
            }

            if (constraint.SquareIsNotSanankou && arrangement.Blocks.Count(b => b.IsKoutsu) >= 3)
            {
                return(false);
            }

            return(true);
        }
 private bool HasShuntsuWithWinningTile(Arrangement arrangement, int winningIndex)
 {
     return(arrangement.Blocks.Any(b => b.IsShuntsu && b.Index <= winningIndex && b.Index + 2 >= winningIndex));
 }
Пример #4
0
        private bool HasIttsuu(Arrangement arrangement)
        {
            var shuntsus = arrangement.Blocks.Where(b => b.IsShuntsu).ToList();

            return(shuntsus.Any(s => s.Index == 0) && shuntsus.Any(s => s.Index == 3) && shuntsus.Any(s => s.Index == 6));
        }