protected override void Syanten(IBaseTiles tiles, ref int result) { int terminalCount = 0; int pairFlag = 0; for (int i = 0; i < 34; i++) { if (tiles.Sorted.Tiles[i] == 0) { continue; } if (!BaseTile.AllTiles[i].IsTerminal) { continue; } if (pairFlag == 0 && tiles.Sorted.Tiles[i] >= 2) { pairFlag = 1; } terminalCount++; } int num = 13 - pairFlag - terminalCount; if (num < result) { result = num; } }
protected override void Syanten(IBaseTiles tiles, ref int result) { int c1 = 0, c2 = 0; for (int i = 0; i < 34; i++) { if (tiles.Sorted.Tiles[i] >= 1) { c1++; } else { continue; } if (tiles.Sorted.Tiles[i] >= 2) { c2++; } } int num = 6 - c2; if (c1 < 7) { num += 7 - c1; } if (num < result) { result = num; } }
internal void Syanten(IBaseTiles itiles, ref int result) { int best = 1 - itiles.Count % 3; if (itiles.Count == 13 || itiles.Count == 14) { foreach (var spYaku in SpecialYakus) { spYaku.Syanten(itiles, ref result); if (result == best) { return; } } } NormalSyanten(itiles.Sorted, ref result); }
public TileCollection(IEnumerable <Tile> tiles, IEnumerable <Group> openGroups = null) { handTiles = tiles.OrderBy(t => t.BaseTile).ToArray(); if (openGroups != null) { var allTiles = new List <Tile>(handTiles); foreach (var g in openGroups) { allTiles.AddRange(g.Tiles); } allTiles.Sort(); this.allTiles = allTiles; } else { allTiles = handTiles; } baseTiles = new BaseTileCollection(allTiles.Select(t => t.BaseTile)); }
/// <summary> /// 求向听数。 /// <para>返回-1,表示已和牌。</para> /// </summary> /// <param name="tiles">要计算的牌集合。</param> /// <param name="result">通过此参数返回,同时此参数也表示其他役最小的向听数结果。如果该役的向听数比原先大,则不应该更新该值。</param> internal protected abstract void Syanten(IBaseTiles tiles, ref int result);
public TileCollection(IEnumerable <Tile> tiles) { this.tiles = tiles.ToArray(); baseTiles = new BaseTileCollection(Array.ConvertAll(this.tiles, t => t.BaseTile)); }