只考虑最简单的胡牌 一对将(对子)+4个坎(四个连顺子 123 456 或四个一样的111 222 或者两者之间的组合)
// 将麻将抽象为数字
//数字
//{01 ~ 09} 表示 {1 ~ 9} 筒
//数字 {11 ~ 19} 表示 {1 ~ 9} 条
//数字 {21 ~ 29} 表示 {1 ~ 9} 万
//数字 {31 33 35 37 } 表示 { 东 南 西 北 }
//数字 {41 43 45} 表示 {中 發 白}
//数字10 20 30 32 34 36 40 42 44 46 空出来不代表任何麻将牌 这样设计的好处就是使得能够形成顺子的牌在用数字表示出来的时候刚好也是连着的, 而不能够形成顺子的牌, 在用数字表示的时候并不是顺子 . 便于以后使用代码进行判断
// shoupai 手上的牌(不包含打出的) Id 摸的牌 或者别人放的炮
public static bool IsCanhu(List<int>mah,int Id)
{
List<int> shouPai = new List<int>(mah);
shouPai.Add(Id);
if(shouPai.Count==2)
{
return shouPai[0]==shouPai[1];
}
//先对手牌进行排序
shouPai.Sort();
//查找牌中的对子
for(i = 0;i<shouPai.Count;i++)
{
//定义剩余的牌
List<int> remain = new List<int>(shoouPai);
List<int> ds = shouPai.FindAll(delegate(int d