下载此文档

c 斗地主出牌算法 精华.doc


文档分类: | 页数:约43页 举报非法文档有奖
1/43
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/43 下载此文档
文档列表 文档介绍
C# 斗地主出牌算法精华
斗地主出牌算法
.
(关于斗地主的出牌规则网上有很多)
思路:,:
假设有牌:333/444/555/789
则拆分后数组中的数据如下
arr[0]:345789
arr[1]:345
arr[2]:345
arr[3]:null
可以看出拆分规则是:如果遇到相同数字的牌则存到下一个数组的末尾.
拆分完后可以根据各数组的存储情况判定玩家出牌的类型,上面例子arr[3](2).[2]为顺子且个数大于1,且arr[2]中存放的牌的张数乘以3刚好等于arr[0]的张数+arr[1]#编写.
using System;
using ;
using ;
namespace LordLibrary
{
/*
*以下程序版权由林奕霖所有,.
*您可以自由拷贝修改此源代码,但必须保留此注释.
*/
public class CheckType
{
private static int[][] DiffRow(int[] nums)
{
int[][] list = new int[4][];
for (int i = 0; i < ; i++)
{
list = new int[20];
}
int[] rowIndex = new int[4];
int columIndex = 0;
for (int i = 0; i < ; i++)
{
if (i + 1 < )
{
if (nums != 0)
{
list[columIndex][rowIndex[columIndex]] = nums;
rowIndex[columIndex]++;
}
if (nums == nums[i + 1])
{
columIndex++;
}
else
{
columIndex = 0;
}
}
else if (nums != 0)
list[columIndex][rowIndex[columIndex]] = nums;
}
return list;
}
private static int checkListCount(int[][] list, int rowIndex, pStart, int rowMaxCount)
{
/* LIST 代表单顺.
*DOUB 代表双顺.
*FEI0 代表三顺.
*FEI1 代表三带一的飞机
*FEI2 代表三带二的飞机
*FOR1 代表四带1
*FOR2 代表四带2
*ROCK 代表大小王
*/
int listCount = 1;
for (int i = compStart; i < rowMaxCount - 1; i++)
{
if (list[rowIndex] + 1 == list[rowIndex][i + 1])
listCount++;
else
listCount = 1;
}
return listCount;
}
public static string getCardType(int[] nums)
{
int[][] list = DiffRow(nums);
int[] counts = new int[4];
for (int k = 0; k < 4; k++)
{
counts[k] = (list[k], 0);
}
int MaxValue = 0;
int listCount = 0;
string type = ;
//当第4行牌的数量为1的时候
#region
if (counts[3] == 1)
{
int index = (list[2], list[3][0]);
switch (counts[2])
{
case 1

c 斗地主出牌算法 精华 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数43
  • 收藏数0 收藏
  • 顶次数0
  • 上传人1136365664
  • 文件大小315 KB
  • 时间2018-03-18