参考上一贴:【编程游戏】编写一个会划拳的机器人参加擂台赛,规则内详。路过有分。
不过上一帖的楼太高、打开太慢,所以我把那些机器人集中到这PK
打败对手最多的机器人获胜!奖励200分,其余酌情散掉划拳规则看完了,那我们就开始写一个会划拳的机器人吧! 那么一个会划拳的机器会做什么事情呢?其实就是两件:
第一件、出拳,即:自己出几个手指?自己猜合计是多少。
第二件、知道划拳的结果,即:对方出几个手指,对方猜合计是多少,是否获胜还是平局还是其他。 只要继承Drunkard这个类,重载Come()和Outcome()方法那么你就拥有了一个会划拳的机器人,参与这个游戏了!【游戏规则】
1、比赛共1000局,即:出现胜负算一局,如出拳100次没有结果也算一局并双方均不得分;
2、赢一局得1分、输不扣分;
3、机器人执行中每出现一次异常,扣100分、对方加1分、记一局;
4、机器人执行中反应超时1000毫秒直接判负,每超时100毫秒,扣1分,超时10次以上直接判负;
5、自己得分高于对手并大于600分判胜;
6、自己得分为正数对手得分为负数判胜;
7、其他情况则判平。
具体执行的过程,算法的过程请参考Drunkery <T1, T2>类的实现【入门提示】
1、机器人的命名建议是: <自己的id> + <第几个> + "号",如:Zswang一号、Zswang二号,当然你也可以用“长江七号”
注意不用重名,重名会给比赛带来不便
2、不允许修改Drunkard和Drunkery <T1, T2>;
3、机器人必须从Drunkard继承;
4、分析擂主代码是战胜擂主的关键;
5、打擂容易守擂难,大家自由发挥吧! 谢谢关注先帖调试代码:
using System;
using System.Collections.Generic;
using System.Text;namespace Huaquan
{
/// <summary>
/// 划拳结果
/// </summary>
public enum Result
{
/// <summary>
/// 未知,还没开始判断
/// </summary>
Unknown,
/// <summary>
/// 平局,结果一致
/// </summary>
Dogfall,
/// <summary>
/// 胜,猜中结果
/// </summary>
Win,
/// <summary>
/// 负,对方猜中结果,自己没有猜中
/// </summary>
Lost,
/// <summary>
/// 犯规,
/// </summary>
Foul,
/// <summary>
/// 超时,反应时间超出100毫秒
/// </summary>
Overtime
} /// <summary>
/// 酒鬼类
/// </summary>
public abstract class Drunkard
{
/// <summary>
/// 出拳
/// </summary>
/// <param name="ANumber">出的手指数</param>
/// <param name="ASum">猜的合计</param>
abstract public void Come(out int AFinger, out int ASum); /// <summary>
/// 接收结果
/// </summary>
/// <param name="AOtherFinger">对方出的手指数</param>
/// <param name="AOtherSum">对方猜的合计</param>
/// <param name="AOtherResult">对方划拳的结果</param>
/// <param name="ASelfFinger">自己出的手指数</param>
/// <param name="ASelfSum">自己猜的合计</param>
/// <param name="ASelfResult">自己划拳的结果</param>
abstract public void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult);
} public class Zswang一号 : Drunkard
{
public override void Come(out int AFinger, out int ASum)
{
AFinger = 5; // 每次都出5
ASum = 10; // 每次都猜10
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
/* 这机器人不关心比赛结果 */
}
} public class Zswang二号 : Drunkard
{
private Random random;
public Zswang二号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
ASum = random.Next(10 + 1); //0-10
if (ASum < 5) // 别犯规
AFinger = random.Next(ASum + 1);
else AFinger = random.Next(ASum - 5, 5 + 1);
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
/* 这机器人也不关心比赛结果 */
}
} /// <summary>
/// 酒馆类
/// </summary>
/// <typeparam name="T1">划拳机器人1</typeparam>
/// <typeparam name="T2">划拳机器人2</typeparam>
public class Drunkery<T1, T2>
where T1 : Drunkard, new()
where T2 : Drunkard, new()
{
/// <summary>
/// 东家
/// </summary>
private Drunkard eastPlayer;
/// <summary>
/// 西家
/// </summary>
private Drunkard westPlayer;
/// <summary>
/// 东家积分
/// </summary>
private int eastTotal;
/// <summary>
/// 西家积分
/// </summary>
private int westTotal;
/// <summary>
/// 东家超时次数
/// </summary>
private int eastOvertime;
/// <summary>
/// 西家超时次数
/// </summary>
private int westOvertime;
/// <summary>
/// 划拳次数
/// </summary>
public const int comeCount = 1000;
/// <summary>
/// 超时罚分
/// </summary>
public const int overtimePenalty = 1;
/// <summary>
/// 异常罚分
/// </summary>
public const int catchPenalty = 100;
/// <summary>
/// 开始比赛
/// </summary>
public void Play()
{
#region 初始化
long vEastTick = Environment.TickCount; // 东家初始化的时间
eastPlayer = new T1();
vEastTick = Environment.TickCount - vEastTick; long vWestTick = Environment.TickCount; // 西家初始化的时间
westPlayer = new T2();
vWestTick = Environment.TickCount - vWestTick; eastTotal = 0; westTotal = 0; eastOvertime = 0; westOvertime = 0; #region 超时处理
if (vEastTick > 1000 || vWestTick > 1000)
{
if (vEastTick > 1000)
Console.WriteLine("{0}初始化严重超时", typeof(T1).Name);
if (vWestTick > 1000)
Console.WriteLine("{0}初始化严重超时", typeof(T2).Name);
return;
}
if (vEastTick > 100)
{
eastTotal -= overtimePenalty;
eastOvertime++;
}
if (vWestTick > 100)
{
westTotal -= overtimePenalty;
westOvertime++;
}
#endregion 超时处理
#endregion 初始化 #region 猜拳过程
for (int i = 0; i < comeCount; i++)
{
for (int j = 0; j < 100; j++)
{
int vEastFinger = 0, vWestFinger = 0;
int vEastSum = 0, vWestSum = 0;
Result vEastResult = Result.Unknown;
Result vWestResult = Result.Unknown; #region 出拳
bool vEastCatch = false;
vEastTick = Environment.TickCount; // 东家出拳的时间
try
{
eastPlayer.Come(out vEastFinger, out vEastSum);
}
catch // 出现异常
{
vEastCatch = true;
}
vEastTick = Environment.TickCount - vEastTick; bool vWestCatch = false;
vWestTick = Environment.TickCount; // 西家出拳的时间
try
{
westPlayer.Come(out vWestFinger, out vWestSum);
}
catch // 出现异常
{
vWestCatch = true;
}
vWestTick = Environment.TickCount - vWestTick;
#endregion 出拳 #region 出现异常
if (vEastCatch || vWestCatch)
{
if (vEastCatch)
{
eastTotal -= catchPenalty;
westTotal++;
}
if (vWestCatch)
{
westTotal -= catchPenalty;
eastTotal++;
}
break;
}
#endregion 出现异常
不过上一帖的楼太高、打开太慢,所以我把那些机器人集中到这PK
打败对手最多的机器人获胜!奖励200分,其余酌情散掉划拳规则看完了,那我们就开始写一个会划拳的机器人吧! 那么一个会划拳的机器会做什么事情呢?其实就是两件:
第一件、出拳,即:自己出几个手指?自己猜合计是多少。
第二件、知道划拳的结果,即:对方出几个手指,对方猜合计是多少,是否获胜还是平局还是其他。 只要继承Drunkard这个类,重载Come()和Outcome()方法那么你就拥有了一个会划拳的机器人,参与这个游戏了!【游戏规则】
1、比赛共1000局,即:出现胜负算一局,如出拳100次没有结果也算一局并双方均不得分;
2、赢一局得1分、输不扣分;
3、机器人执行中每出现一次异常,扣100分、对方加1分、记一局;
4、机器人执行中反应超时1000毫秒直接判负,每超时100毫秒,扣1分,超时10次以上直接判负;
5、自己得分高于对手并大于600分判胜;
6、自己得分为正数对手得分为负数判胜;
7、其他情况则判平。
具体执行的过程,算法的过程请参考Drunkery <T1, T2>类的实现【入门提示】
1、机器人的命名建议是: <自己的id> + <第几个> + "号",如:Zswang一号、Zswang二号,当然你也可以用“长江七号”
注意不用重名,重名会给比赛带来不便
2、不允许修改Drunkard和Drunkery <T1, T2>;
3、机器人必须从Drunkard继承;
4、分析擂主代码是战胜擂主的关键;
5、打擂容易守擂难,大家自由发挥吧! 谢谢关注先帖调试代码:
using System;
using System.Collections.Generic;
using System.Text;namespace Huaquan
{
/// <summary>
/// 划拳结果
/// </summary>
public enum Result
{
/// <summary>
/// 未知,还没开始判断
/// </summary>
Unknown,
/// <summary>
/// 平局,结果一致
/// </summary>
Dogfall,
/// <summary>
/// 胜,猜中结果
/// </summary>
Win,
/// <summary>
/// 负,对方猜中结果,自己没有猜中
/// </summary>
Lost,
/// <summary>
/// 犯规,
/// </summary>
Foul,
/// <summary>
/// 超时,反应时间超出100毫秒
/// </summary>
Overtime
} /// <summary>
/// 酒鬼类
/// </summary>
public abstract class Drunkard
{
/// <summary>
/// 出拳
/// </summary>
/// <param name="ANumber">出的手指数</param>
/// <param name="ASum">猜的合计</param>
abstract public void Come(out int AFinger, out int ASum); /// <summary>
/// 接收结果
/// </summary>
/// <param name="AOtherFinger">对方出的手指数</param>
/// <param name="AOtherSum">对方猜的合计</param>
/// <param name="AOtherResult">对方划拳的结果</param>
/// <param name="ASelfFinger">自己出的手指数</param>
/// <param name="ASelfSum">自己猜的合计</param>
/// <param name="ASelfResult">自己划拳的结果</param>
abstract public void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult);
} public class Zswang一号 : Drunkard
{
public override void Come(out int AFinger, out int ASum)
{
AFinger = 5; // 每次都出5
ASum = 10; // 每次都猜10
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
/* 这机器人不关心比赛结果 */
}
} public class Zswang二号 : Drunkard
{
private Random random;
public Zswang二号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
ASum = random.Next(10 + 1); //0-10
if (ASum < 5) // 别犯规
AFinger = random.Next(ASum + 1);
else AFinger = random.Next(ASum - 5, 5 + 1);
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
/* 这机器人也不关心比赛结果 */
}
} /// <summary>
/// 酒馆类
/// </summary>
/// <typeparam name="T1">划拳机器人1</typeparam>
/// <typeparam name="T2">划拳机器人2</typeparam>
public class Drunkery<T1, T2>
where T1 : Drunkard, new()
where T2 : Drunkard, new()
{
/// <summary>
/// 东家
/// </summary>
private Drunkard eastPlayer;
/// <summary>
/// 西家
/// </summary>
private Drunkard westPlayer;
/// <summary>
/// 东家积分
/// </summary>
private int eastTotal;
/// <summary>
/// 西家积分
/// </summary>
private int westTotal;
/// <summary>
/// 东家超时次数
/// </summary>
private int eastOvertime;
/// <summary>
/// 西家超时次数
/// </summary>
private int westOvertime;
/// <summary>
/// 划拳次数
/// </summary>
public const int comeCount = 1000;
/// <summary>
/// 超时罚分
/// </summary>
public const int overtimePenalty = 1;
/// <summary>
/// 异常罚分
/// </summary>
public const int catchPenalty = 100;
/// <summary>
/// 开始比赛
/// </summary>
public void Play()
{
#region 初始化
long vEastTick = Environment.TickCount; // 东家初始化的时间
eastPlayer = new T1();
vEastTick = Environment.TickCount - vEastTick; long vWestTick = Environment.TickCount; // 西家初始化的时间
westPlayer = new T2();
vWestTick = Environment.TickCount - vWestTick; eastTotal = 0; westTotal = 0; eastOvertime = 0; westOvertime = 0; #region 超时处理
if (vEastTick > 1000 || vWestTick > 1000)
{
if (vEastTick > 1000)
Console.WriteLine("{0}初始化严重超时", typeof(T1).Name);
if (vWestTick > 1000)
Console.WriteLine("{0}初始化严重超时", typeof(T2).Name);
return;
}
if (vEastTick > 100)
{
eastTotal -= overtimePenalty;
eastOvertime++;
}
if (vWestTick > 100)
{
westTotal -= overtimePenalty;
westOvertime++;
}
#endregion 超时处理
#endregion 初始化 #region 猜拳过程
for (int i = 0; i < comeCount; i++)
{
for (int j = 0; j < 100; j++)
{
int vEastFinger = 0, vWestFinger = 0;
int vEastSum = 0, vWestSum = 0;
Result vEastResult = Result.Unknown;
Result vWestResult = Result.Unknown; #region 出拳
bool vEastCatch = false;
vEastTick = Environment.TickCount; // 东家出拳的时间
try
{
eastPlayer.Come(out vEastFinger, out vEastSum);
}
catch // 出现异常
{
vEastCatch = true;
}
vEastTick = Environment.TickCount - vEastTick; bool vWestCatch = false;
vWestTick = Environment.TickCount; // 西家出拳的时间
try
{
westPlayer.Come(out vWestFinger, out vWestSum);
}
catch // 出现异常
{
vWestCatch = true;
}
vWestTick = Environment.TickCount - vWestTick;
#endregion 出拳 #region 出现异常
if (vEastCatch || vWestCatch)
{
if (vEastCatch)
{
eastTotal -= catchPenalty;
westTotal++;
}
if (vWestCatch)
{
westTotal -= catchPenalty;
eastTotal++;
}
break;
}
#endregion 出现异常
if (vEastTick > 1000 || vWestTick > 1000)
{
if (vEastTick > 1000)
Console.WriteLine("{0}出拳严重超时", typeof(T1).Name);
if (vWestTick > 1000)
Console.WriteLine("{0}出拳严重超时", typeof(T2).Name);
return;
} if (vEastTick > 100)
{
vEastResult = Result.Overtime;
eastOvertime++;
}
if (vWestTick > 100)
{
vWestResult = Result.Overtime;
westOvertime++;
}
#endregion 超时处理 #region 判断谁犯规
if (vEastResult == Result.Unknown)
if (vEastSum < 0 || vEastSum > 10 ||
vEastFinger < 0 || vEastFinger > 5 ||
vEastSum - 5 > vEastFinger || vEastFinger > vEastSum)
vEastResult = Result.Foul;
if (vWestResult == Result.Unknown)
if (vWestSum < 0 || vWestSum > 10 ||
vWestFinger < 0 || vWestFinger > 5 ||
vWestSum - 5 > vWestFinger || vWestFinger > vWestSum)
vWestResult = Result.Foul;
#endregion 判断谁犯规 #region 有一个人犯规
if (vEastResult == Result.Foul ^ vWestResult == Result.Foul)
{
#region 如犯规判则对方赢
if (vEastResult == Result.Foul)
vWestResult = Result.Win;
else if (vWestResult == Result.Foul)
vEastResult = Result.Win;
#endregion 如犯规判则对方赢
}
#endregion 有一个人犯规 #region 划拳比较
if (vEastResult == Result.Unknown)
if (vEastFinger + vWestFinger == vEastSum)
vEastResult = Result.Win; if (vWestResult == Result.Unknown)
if (vEastFinger + vWestFinger == vWestSum)
vWestResult = Result.Win;
#endregion 划拳比较 #region 平局
if (vEastResult == vWestResult)
{
vEastResult = Result.Dogfall;
vWestResult = Result.Dogfall;
}
#endregion 平局 #region 出现胜负
if (vEastResult == Result.Win || vWestResult == Result.Win)
{
if (vEastResult == Result.Win)
{
eastTotal++;
vWestResult = Result.Lost;
}
else if (vWestResult == Result.Win)
{
westTotal++;
vEastResult = Result.Lost;
}
}
#endregion 出现胜负 #region 通知划拳的结果
vEastTick = Environment.TickCount;
vEastCatch = false;
try
{
eastPlayer.Outcome(vWestFinger, vWestSum, vWestResult,
vEastFinger, vEastSum, vEastResult);
}
catch
{
vEastCatch = true;
}
vEastTick = Environment.TickCount - vEastTick; vWestTick = Environment.TickCount;
vWestCatch = false;
try
{
westPlayer.Outcome(vEastFinger, vEastSum, vEastResult,
vWestFinger, vWestSum, vWestResult);
}
catch
{
vWestCatch = true;
}
vWestTick = Environment.TickCount - vWestTick;
#endregion 通知划拳的结果 #region 出现异常
if (vEastCatch || vWestCatch)
{
if (vEastCatch)
{
eastTotal -= catchPenalty;
westTotal++;
}
if (vWestCatch)
{
westTotal -= catchPenalty;
eastTotal++;
}
break;
}
#endregion 出现异常 #region 超时处理
if (vEastTick > 1000 || vWestTick > 1000)
{
if (vEastTick > 1000)
Console.WriteLine("{0}接收结果严重超时", typeof(T1).Name);
if (vWestTick > 1000)
Console.WriteLine("{0}接收结果严重超时", typeof(T2).Name);
return;
} if (vEastTick > 100)
{
eastTotal -= overtimePenalty;
eastOvertime++;
}
if (vWestTick > 100)
{
westTotal -= overtimePenalty;
westOvertime++;
}
if (eastOvertime > 10 || westOvertime > 10)
{
if (eastOvertime > 10)
Console.WriteLine("{0}超时十次以上", typeof(T1).Name);
if (westOvertime > 10)
Console.WriteLine("{0}超时十次以上", typeof(T2).Name);
return;
}
#endregion 超时处理 #region 出现胜负
if (vEastResult == Result.Win || vWestResult == Result.Win)
break;
#endregion 出现胜负
}
}
#endregion 猜拳过程 #region 输出结果
Console.WriteLine("{0}得分:{1}, {2}得分:{3}",
typeof(T1).Name, eastTotal,
typeof(T2).Name, westTotal);
Console.ReadLine();
#endregion 输出结果
}
} class Program
{
static void Main(string[] args)
{
new Drunkery<Zswang一号, Zswang二号>().Play();
}
}
}
{
private Random random;
public Zswang二号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
ASum = random.Next(10 + 1); //0-10
if (ASum < 5) // 别犯规
AFinger = random.Next(ASum + 1);
else AFinger = random.Next(ASum - 5, 5 + 1);
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
/* 这机器人也不关心比赛结果 */
}
}public class zhangenter : Drunkard
{
private Random random;
int[] betterFinger = new int[] { 0, 0, 5, 5 };
int[] betterSum = new int[] { 0, 5, 5, 10 };
int lastIndex = 0; public zhangenter()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = betterFinger[lastIndex];
ASum = betterSum[lastIndex];
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
if (ASelfResult != Result.Win)
{
int newIndex;
while ((newIndex = random.Next(4)) != lastIndex)
lastIndex = newIndex;
}
}
}public class Zswang三号66楼 : Drunkard
{
private Random random;
private int lessFour;
private int lassFour;
public Zswang三号66楼()
{
random = new Random();
lessFour = 0;
lassFour = 0;
} private int Finger()
{
int finger = 0;
if (lessFour >= lassFour)
finger = random.Next(5 + 1); //0-10
if (lessFour < lassFour)
finger = 5;
return finger;
} public override void Come(out int AFinger, out int ASum)
{
AFinger = Finger(); //0-10
if (AFinger <= 4)
ASum = 4;
else ASum = 10;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
if (ASelfResult == Result.Win)
{
if (ASelfSum == 4) lessFour++;
else lassFour++;
}
}
}public class Yuwenge : Drunkard
{
private Random random;
public Yuwenge()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = 2;
ASum = 2 + random.Next(99) % 5 + 1; }
public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}public class yunfeng007 : Drunkard
{
private Random random;
private int lessFour;
private int lassFour;
private int otherlessFour;
private int otherlassFour; public yunfeng007()
{
random = new Random();
lessFour = 0;
lassFour = 0;
otherlessFour = 0;
otherlassFour = 0;
}
private int Finger()
{
int finger = 0;
if (lessFour >= lassFour)
finger = 1 + random.Next(3 + 1); //0-10
if (lessFour < lassFour)
finger = 5;
return finger;
} public override void Come(out int AFinger, out int ASum)
{
AFinger = Finger(); //0-10
if (AFinger <= 4)
ASum = 4;
else ASum = 10;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
if (AOtherFinger <= 4) ++otherlessFour;
else ++otherlassFour;
if (ASelfResult == Result.Win)
{
if (ASelfSum == 4) ++lessFour;
else ++lassFour;
}
if (ASelfResult == Result.Lost || ASelfResult == Result.Unknown)
{
if (ASelfSum == 4 && otherlessFour <= otherlassFour)
{ --lessFour; ++lassFour; }
else { --lassFour; ++lessFour; }
}
}
}
class hhhh : Drunkard
{ private Random random;
public hhhh()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
ASum = 6; //0-10
AFinger = random.Next(1, 6);
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}public class ren : Drunkard
{
public override void Come(out int AFinger, out int ASum)
{
Random random = new Random();
AFinger = 0; // 每次都出0
ASum = random.Next(1, 5);
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}class hhhh2 : Drunkard
{ private Random random;
public hhhh2()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = 0;
ASum = random.Next(1, 5);
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}class 守擂 : Drunkard
{
private Random random;
public 守擂()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = random.Next(5);
ASum = 5;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}public class Linxu二号 : Drunkard
{
private Random random; public Linxu二号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = random.Next(5);
ASum = 4;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}class 专打Linxu二号 : Drunkard
{
private Random random;
public 专打Linxu二号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = 5;
ASum = random.Next(5) + 5;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}class 守擂二号 : Drunkard
{
private Random random;
public 守擂二号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = random.Next(5);
ASum = AFinger + random.Next(5);
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}public class Linxu三号 : Drunkard
{
private Random random;
private Random random2; public Linxu三号()
{
random = new Random();
random2 = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = random.Next(random2.Next(5));
ASum = 5; } public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}
{
private Random random;
public 守擂三号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = random.Next(6);
ASum = 5;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}class Linxu四号 : Drunkard
{
private Random random;
public Linxu四号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = 5;
ASum = random.Next(5, 10);
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}public class Zswang三号 : Drunkard
{
private Random random;
private bool is守擂三号 = true; // 对手是不是守擂三号? public Zswang三号()
{
random = new Random(); // 因为是伪随机,一毫秒内创建的随机种子是一样的
} public override void Come(out int AFinger, out int ASum)
{
if (is守擂三号)
{
#region 计算守擂三号出的数字
int vFinger = random.Next(6); // 这里可以猜测他是否用随机
#endregion 计算守擂三号出的数字
if (vFinger == 0)
{
AFinger = 1;
ASum = 1;
}
else
{
AFinger = 5;
ASum = vFinger + AFinger;
}
}
else
{
AFinger = random.Next(6); // 骂我吧,内核就是:“守擂三号”
ASum = 5;
}
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
if (is守擂三号) // 擂主如是is守擂三号
{
if (ASelfResult != Result.Win) // 输了?那对手就不是守擂三号了
{
random = new Random(); // 重新生成随机数
}
}
}
}public class nik_amis : Drunkard
{
public override void Come(out int AFinger, out int ASum)
{
Random r = new Random(76);
int[] f = new int[] { 5, 3, 2, 4, 1, 0 };
AFinger = f[r.Next(0, 10) / 2];
ASum = r.Next(0, 2) * 5 + AFinger;
if (r.Next(11) > 9) ASum = r.Next(1, 6) + AFinger;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}class linxu五号 : Drunkard
{
private Random random;
public linxu五号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = random.Next(random.Next(7));
ASum = 5;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}class 专打Zswang三号 : Drunkard
{
private Random random;
public 专打Zswang三号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = 5 - random.Next(6);
if (AFinger == 5)
ASum = 6;
else
ASum = 5 + AFinger;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}public class yunfeng007二号 : Drunkard
{
private Random random; public yunfeng007二号()
{
random = new Random();
Finger = 0;
}
private static int Finger; public override void Come(out int AFinger, out int ASum)
{
AFinger = Finger;
if (AFinger <= 4)
ASum = 4;
else ASum = 10;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
Finger = NextFinger(ASelfResult, ASelfFinger, AOtherFinger);
} private int NextFinger(Result SelfResult, int SelfFinger, int OtherFinger)
{
int finger = 0;
if (SelfResult == Result.Win)
{
finger = SelfFinger;
}
if (SelfResult == Result.Lost || SelfResult == Result.Unknown || SelfResult == Result.Dogfall)
{
finger = OtherFinger + random.Next(4 - OtherFinger + 1);
}
return finger;
}
}class 专打Zlinxu五号 : Drunkard
{
private Random random;
public 专打Zlinxu五号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = random.Next(6);
ASum = AFinger;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}class 专打Zlinxu四号 : Drunkard
{
private Random random;
public 专打Zlinxu四号()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = random.Next(6);
ASum = AFinger + 5;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}class 擂主4 : Drunkard
{
private Random random;
public 擂主4()
{
random = new Random();
} public override void Come(out int AFinger, out int ASum)
{ for (int i = 0; i < random.Next(10); i++)
{
AFinger = random.Next(6);
}
AFinger = random.Next(6);
ASum = 5;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}public class yunfeng007二号210楼 : Drunkard
{
private Random random; public yunfeng007二号210楼()
{
random = new Random();
Finger = 0;
}
private static int Finger; public override void Come(out int AFinger, out int ASum)
{
AFinger = Finger;
if (AFinger <= 4)
ASum = 4;
else ASum = 10;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
Finger = NextFinger(ASelfResult, ASelfFinger, AOtherFinger);
} private void Count(int OtherFinger)
{
} private int NextFinger(Result SelfResult, int SelfFinger, int OtherFinger)
{
int finger = 0;
if (SelfResult == Result.Win)
{
finger = SelfFinger;
}
if (SelfResult == Result.Lost || SelfResult == Result.Unknown || SelfResult == Result.Dogfall)
{
finger = OtherFinger + random.Next(4 - OtherFinger + 1);
}
return finger;
}
}public class 剪刀一号 : Drunkard
{
private Random random;
public 剪刀一号()
{
random = new Random();
}
public override void Come(out int AFinger, out int ASum)
{
AFinger = 5;
ASum = random.Next(6, 11);
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}
{
private Random random;
public 专打yunfeng二号()
{
random = new Random();
}
static int Finger = 5;
public override void Come(out int AFinger, out int ASum)
{
AFinger = Finger;
ASum = 9;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
Finger = NextFinger(ASelfResult, ASelfFinger, AOtherFinger);
} private int NextFinger(Result SelfResult, int SelfFinger, int OtherFinger)
{
int finger = 0;
{
if (SelfFinger == 5)
finger = 4;
else if (SelfFinger == 4)
finger = 5;
} return finger;
}
}public class yunfeng007二号188楼 : Drunkard
{
private Random random; public yunfeng007二号188楼()
{
random = new Random();
Finger = random.Next(6);
}
private static int Finger; public override void Come(out int AFinger, out int ASum)
{
AFinger = Finger;
if (AFinger <= 4)
ASum = 4;
else ASum = 10;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
Finger = NextFinger(ASelfResult, ASelfFinger, AOtherFinger);
} private int NextFinger(Result SelfResult, int SelfFinger, int OtherFinger)
{
int finger = 0;
if (SelfResult == Result.Win)
{
finger = SelfFinger;
}
if (SelfResult == Result.Lost || SelfResult == Result.Unknown || SelfResult == Result.Dogfall)
{
finger = OtherFinger + random.Next(4 - OtherFinger + 1);
}
return finger;
}
}public class ZhangenterCome : Drunkard
{
private Random random; Dictionary<int, int> figuerCount = new Dictionary<int, int>();
Dictionary<int, int> sumCount = new Dictionary<int, int>(); public ZhangenterCome()
{
random = new Random(); for (int i = 0; i <= 5; i++)
{
figuerCount.Add(i, 0);
} for (int i = 0; i <= 10; i++)
{
sumCount.Add(i, 0);
}
} public override void Come(out int AFinger, out int ASum)
{
int otherMaxFinger, otherMaxFingerCount, otherMaxSum, otherMaxSumCount; GetMaxValue(figuerCount, out otherMaxFinger, out otherMaxFingerCount);
GetMaxValue(sumCount, out otherMaxSum, out otherMaxSumCount); int warningFinger = otherMaxSum - otherMaxFinger; int mod = DateTime.Now.Millisecond % 2; if (otherMaxFingerCount > 2 * otherMaxSumCount)
{
mod = 0;
} if (otherMaxSumCount > 2 * otherMaxFingerCount)
{
mod = 1;
} if (mod == 0)
{
// 避免对方猜中手指
while (true)
{
//AFinger = random.Next(6);
AFinger = (random.Next(1000) + DateTime.Now.Millisecond) % 6; if (AFinger != warningFinger)
{
break;
}
} ASum = otherMaxFinger + AFinger;
}
else
{
// 避免对方猜中总和
int warningSum = otherMaxSum; while (true)
{
ASum = otherMaxFinger + (random.Next(9) * DateTime.Now.Millisecond) % 6; if (ASum != warningSum)
{
break;
}
} AFinger = ASum - otherMaxFinger;
} double count = 1;
// 浪费点时间,把时间弄乱,反正楼主给的时间充裕
for (int i = 0; i < DateTime.Now.Millisecond % 98765; i++)
{
count *= random.Next(12345, 67890);
count /= random.Next(12345, 67890); if (count % 987654321 == DateTime.Now.Millisecond % 54321)
break;
}
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
if (figuerCount.ContainsKey(AOtherFinger))
figuerCount[AOtherFinger]++; if (sumCount.ContainsKey(AOtherSum))
sumCount[AOtherSum]++; double count = 1;
// 浪费点时间,把时间弄乱,反正楼主给的时间充裕
for (int i = 0; i < DateTime.Now.Millisecond % 98765; i++)
{
count *= random.Next(12345, 67890);
count /= random.Next(12345, 67890); if (count % 987654321 == DateTime.Now.Millisecond % 54321)
break;
}
} private void GetMaxValue(Dictionary<int, int> d, out int maxKey, out int maxValue)
{
maxValue = 0;
maxKey = d[maxValue]; foreach (int k in d.Keys)
{
if (d[k] > maxValue)
{
maxValue = d[k];
maxKey = k;
}
}
}
}public class 专打yunfeng二号226楼 : Drunkard
{
private Random random;
public 专打yunfeng二号226楼()
{
random = new Random();
}
static int Finger = 5;
public override void Come(out int AFinger, out int ASum)
{
AFinger = Finger;
ASum = 9;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
/* 这机器人关心比赛结果 */
Finger = NextFinger(ASelfResult, ASelfFinger, AOtherFinger);
}
private int NextFinger(Result SelfResult, int SelfFinger, int OtherFinger)
{
int finger = 0;
{
if (SelfFinger == 5)
finger = 4;
else if (SelfFinger == 4)
finger = 5;
} return finger;
}
}
{
private Random random; System.Data.DataTable historyFinger = new System.Data.DataTable();
System.Data.DataTable historySum = new System.Data.DataTable(); int lookCount = 0;
int lookTotalCount = 0;
int comeTotalCount = 0; public 剪刀二号()
{
random = new Random();
lookTotalCount = random.Next(500, 1000);
historyFinger.Columns.Add("OtherFinger", typeof(int));
historyFinger.Columns.Add("OtherFingerCount", typeof(int));
historySum.Columns.Add("OtherSum", typeof(int));
historySum.Columns.Add("OtherSumCount", typeof(int)); for (int i = 0; i <= 5; i++)
{
System.Data.DataRow dRow = historyFinger.NewRow();
dRow["OtherFinger"] = i;
dRow["OtherFingerCount"] = 0;
historyFinger.Rows.Add(dRow);
} for (int i = 0; i <= 10; i++)
{
System.Data.DataRow dRow = historySum.NewRow();
dRow["OtherSum"] = i;
dRow["OtherSumCount"] = 0;
historySum.Rows.Add(dRow);
} }
public override void Come(out int AFinger, out int ASum)
{
lookCount++;
comeTotalCount++;
int minFingerCount = (int)historyFinger.Compute("min(OtherFingerCount)", "");
int minFinger = (int)historyFinger.Select(string.Format("OtherFingerCount={0}", minFingerCount))[0]["OtherFinger"];
int maxFingerCount = (int)historyFinger.Compute("max(OtherFingerCount)", "");
int maxFinger = (int)historyFinger.Select(string.Format("OtherFingerCount={0}", maxFingerCount))[0]["OtherFinger"]; int minSumCount = (int)historySum.Compute("min(OtherSumCount)", "");
int minSum = (int)historySum.Select(string.Format("OtherSumCount={0}", minSumCount))[0]["OtherSum"];
int maxSumCount = (int)historySum.Compute("max(OtherSumCount)", "");
int maxSum = (int)historySum.Select(string.Format("OtherSumCount={0}", maxSumCount))[0]["OtherSum"];
int sugguestFinger = maxFinger;
if ((minFingerCount > 0) && (float)maxFingerCount / minFingerCount <= 1.1)
{
sugguestFinger = minFinger;
}
int suggestSum = maxSum;
if ((minSumCount > 0) && maxSumCount / minSumCount <= 1.1)
{
sugguestFinger = minSum;
}
while (true)
{
AFinger = random.Next(6);
if (AFinger + sugguestFinger == suggestSum) continue;
ASum = AFinger + sugguestFinger;
break;
}
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
System.Data.DataRow dRow = historyFinger.Select(string.Format("OtherFinger={0}", AOtherFinger))[0];
dRow["OtherFingerCount"] = int.Parse(dRow["OtherFingerCount"].ToString()) + 1; dRow = historySum.Select(string.Format("OtherSum={0}", AOtherFinger))[0];
dRow["OtherSumCount"] = int.Parse(dRow["OtherSumCount"].ToString()) + 1; }
}public class ZhangenterCome加强版 : Drunkard
{
private Random random; Dictionary<int, int> figuerCount = new Dictionary<int, int>();
Dictionary<int, int> sumCount = new Dictionary<int, int>(); public ZhangenterCome加强版()
{
random = new Random(); for (int i = 0; i <= 5; i++)
{
figuerCount.Add(i, 0);
} for (int i = 0; i <= 10; i++)
{
sumCount.Add(i, 0);
}
} public override void Come(out int AFinger, out int ASum)
{
int otherMaxFinger, otherMaxFingerCount, otherMaxSum, otherMaxSumCount;
bool mainFinger, mainSum; GetMaxValue(figuerCount, out otherMaxFinger, out otherMaxFingerCount, out mainFinger);
GetMaxValue(sumCount, out otherMaxSum, out otherMaxSumCount, out mainSum); int warningFinger = otherMaxSum - otherMaxFinger; int mod = DateTime.Now.Millisecond % 2; if (mainFinger)
{
mod = 0;
}
else
{
otherMaxFinger = GetOtherMaxFinger(figuerCount);
} if (mod == 0)
{
// 避免对方猜中手指
while (true)
{
AFinger = (random.Next(1000) + DateTime.Now.Millisecond) % 6; if (AFinger != warningFinger)
{
break;
}
} ASum = otherMaxFinger + AFinger;
}
else
{
// 避免对方猜中总和
int warningSum = otherMaxSum; while (true)
{
//otherMaxFinger = (random.Next(9) * DateTime.Now.Millisecond) % 6;
ASum = otherMaxFinger + (random.Next(9) * DateTime.Now.Millisecond) % 6; if (ASum != warningSum)
{
break;
}
} AFinger = ASum - otherMaxFinger;
} double count = 1;
// 浪费点时间,把时间弄乱,反正楼主给的时间充裕
for (int i = 0; i < DateTime.Now.Millisecond % 98765; i++)
{
count *= random.Next(12345, 67890);
count /= random.Next(12345, 67890); if (count % 987654321 == DateTime.Now.Millisecond % 54321)
break;
}
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
if (figuerCount.ContainsKey(AOtherFinger))
figuerCount[AOtherFinger]++; if (sumCount.ContainsKey(AOtherSum))
sumCount[AOtherSum]++;
} private void GetMaxValue(Dictionary<int, int> d, out int maxKey, out int maxValue, out bool mainValue)
{
maxKey = 0;
maxValue = d[maxKey];
int aboutMaxValue = maxValue; foreach (int k in d.Keys)
{
if (d[k] > maxValue)
{
aboutMaxValue = maxValue; maxValue = d[k];
maxKey = k;
}
} if (maxValue > aboutMaxValue * 2 + 1)
mainValue = true;
else
mainValue = false;
} private int GetOtherMaxFinger(Dictionary<int, int> d)
{
List<int> indexKeys = new List<int>(); foreach (int k in d.Keys)
{
for (int i = 0; i < d[k]; i++)
{
indexKeys.Add(k);
}
} if (indexKeys.Count == 0)
return random.Next(6);
else
return indexKeys[random.Next(indexKeys.Count)];
}
}
{
public int[] 对方猜的数的次数记录 = new int[6];
public int[] 对方出的数的次数记录 = new int[6];
public int[] 对方喊的和的次数记录 = new int[11]; public override void Come(out int AFinger, out int ASum)
{
List<int[]> 最优解集 = new List<int[]>(36); int 最佳分数 = int.MinValue;
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 6; j++)
{
int sum = i + j;
int 得分 = checked(-对方猜的数的次数记录[i] + 对方出的数的次数记录[j] - 对方喊的和的次数记录[sum]);
if (得分 > 最佳分数)
{
最佳分数 = 得分;
最优解集.Clear();
}
else if (得分 < 最佳分数)
continue;
最优解集.Add(new int[] { i, j });
}
}
int[] 最优解 = 最优解集[new Random().Next(最优解集.Count)];
AFinger = 最优解[0];
ASum = 最优解[1] + AFinger;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
/* 这机器人关心比赛结果 */
对方猜的数的次数记录[AOtherSum - AOtherFinger] = 对方猜的数的次数记录[AOtherSum - AOtherFinger] + 1;
对方出的数的次数记录[AOtherFinger] = 对方出的数的次数记录[AOtherFinger] + 1;
对方喊的和的次数记录[AOtherSum] = 对方喊的和的次数记录[AOtherSum] + 1;
}
}public class 剪刀三号 : Drunkard
{ private Random random; System.Data.DataTable historyTable = new System.Data.DataTable();
System.Data.DataTable suggestTable = new System.Data.DataTable(); public 剪刀三号()
{
random = new Random();
historyTable.Columns.Add("f", typeof(int));
historyTable.Columns.Add("c", typeof(int)); suggestTable.Columns.Add("m", typeof(int));
suggestTable.Columns.Add("c", typeof(int)); for (int i = 0; i <= 5; i++)
{
System.Data.DataRow drow = suggestTable.NewRow();
drow["m"] = i;
drow["c"] = 0;
suggestTable.Rows.Add(drow); drow = historyTable.NewRow();
drow["f"] = i;
drow["c"] = 0;
historyTable.Rows.Add(drow);
} } public override void Come(out int AFinger, out int ASum)
{
System.Data.DataRow[] rows = suggestTable.Select("1=1", "c");
AFinger = (int)rows[0]["m"]; int iIndex = random.Next(2); rows = historyTable.Select("c>avg(c)", "c desc"); if (rows.Length == 0)
{
ASum = AFinger + random.Next(6);
}
else
if (rows.Length == 1)
{
ASum = AFinger + (int)rows[0]["f"];
}
else
{
ASum = AFinger + (int)rows[iIndex]["f"];
}
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
suggestTable.Rows[AOtherSum - AOtherFinger]["c"] = int.Parse(suggestTable.Rows[AOtherSum - AOtherFinger]["c"].ToString()) + 1;
historyTable.Rows[AOtherFinger]["c"] = int.Parse(historyTable.Rows[AOtherFinger]["c"].ToString()) + 1;
}
}public class Zswang四号 : Drunkard
{
public override void Come(out int AFinger, out int ASum)
{
AFinger = int.MinValue;
ASum = int.MaxValue;
}
public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}public class yatobiaf_四号 : Drunkard
{
public int[] OtherGuess = new int[6];
public int[] OtherFinger = new int[6];
public int[] SelfGuess = new int[6];
public int[] SelfFinger = new int[6];
public int[] 判断智能机器人次数 = new int[2]; public int NextFinger = 0;
bool isOtherClever = false;//判断对方是否为智能机器人
int i; public override void Come(out int AFinger, out int ASum)
{
AFinger = 0;
ASum = 0;
if (isOtherClever)//智能机器人,那我就出对方认为我最不可能出的牌
{
int minIfingerd = int.MinValue;
for (i = 0; i < 6; i++)
{
if (minIfingerd > SelfFinger[i])
{
minIfingerd = SelfFinger[i];
AFinger = i;
}
}
int maxIguess = int.MaxValue;
for (i = 0; i < 6; i++)
{
if (maxIguess < SelfGuess[i])
{
maxIguess = SelfGuess[i];
ASum = AFinger + i;
}
} }
else //笨笨机器人,那我就猜对方最可能出的牌。
{
int minGuess = int.MaxValue;
for (i = 0; i < 6; i++)
{
if (minGuess > OtherGuess[i])
{
minGuess = OtherGuess[i];
AFinger = i;
}
}
int maxFinger = int.MinValue;
for (i = 0; i < 6; i++)
{
if (maxFinger < OtherFinger[i])
{
maxFinger = OtherFinger[i];
ASum = AFinger + i;
}
}
}
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
OtherGuess[AOtherSum - AOtherFinger] = OtherGuess[AOtherSum - AOtherFinger] + 1;
OtherFinger[AOtherFinger] = OtherFinger[AOtherFinger] + 1;
SelfGuess[ASelfSum - ASelfFinger] = SelfGuess[ASelfSum - ASelfFinger] + 1;
SelfFinger[ASelfFinger] = SelfFinger[ASelfFinger] + 1; if (ASelfResult == Result.Lost)
isOtherClever = !isOtherClever; }
}public class xx_一号 : Drunkard
{
public int[][] OldFingerNum = new int[6][];
public int[][] OldGuessNum = new int[11][];
int Counter = 0; Boolean isDogFall;
int lastFinger;
private Random random;
public xx_一号()
{
random = new Random();
for (int i = 0; i < OldFingerNum.Length; i++)
{
OldFingerNum[i] = new int[1];
}
for (int i = 0; i < OldGuessNum.Length; i++)
{
OldGuessNum[i] = new int[1];
}
} public override void Come(out int AFinger, out int ASum)
{ if (Counter < 30)
{
AFinger = random.Next(6);
ASum = AFinger + random.Next(6);
}
else
{
int OtherlikeFinger = GetTheMax(OldFingerNum);
int OtherlikeSum = GetTheMax(OldGuessNum);
AFinger = random.Next(6);
if (isDogFall)
{
ASum = AFinger + lastFinger;
}
else
{
ASum = AFinger + OtherlikeFinger;
}
}
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
if (AOtherResult == Result.Dogfall)
{
isDogFall = true;
lastFinger = AOtherFinger;
} if (AOtherFinger <= 0 || AOtherFinger >= 5)
{
OldFingerNum[AOtherFinger][0]++;
} if (AOtherSum <= 0 || AOtherSum >= 11)
{
OldGuessNum[AOtherSum][0]++;
}
Counter++;
} public int GetTheMax(int[][] Value)
{
int MaxVaule = 0;
int Counter = 0;
for (int i = 0; i < Value.Length; i++)
{
if (MaxVaule < Value[i][0])
{
MaxVaule = Value[i][0];
Counter = i; }
}
return Counter;
}
}
{
public int[] OtherGuess = new int[6];
public int[] OtherFinger = new int[6];
public int[] SelfGuess = new int[6];
public int[] SelfFinger = new int[6];
public int[] 判断智能机器人次数 = new int[2]; public int NextFinger = 0;
bool isOtherClever = false;//判断对方是否为智能机器人
int i; public override void Come(out int AFinger, out int ASum)
{
AFinger = 0;
ASum = 0;
if (isOtherClever)//智能机器人,那我就出对方认为我最不可能出的牌
{
int minIfingerd = int.MaxValue;
for (i = 0; i < 6; i++)
{
if (minIfingerd > SelfFinger[i])
{
minIfingerd = SelfFinger[i];
AFinger = i;
}
}
int minIguess = int.MaxValue;
for (i = 0; i < 6; i++)
{
if (minIguess > SelfGuess[i])
{
minIguess = SelfGuess[i];
ASum = AFinger + i;
}
} }
else //笨笨机器人,那我就猜对方最可能出的牌。
{
int minGuess = int.MaxValue;
for (i = 0; i < 6; i++)
{
if (minGuess > OtherGuess[i])
{
minGuess = OtherGuess[i];
AFinger = i;
}
}
int maxFinger = int.MinValue;
for (i = 0; i < 6; i++)
{
if (maxFinger < OtherFinger[i])
{
maxFinger = OtherFinger[i];
ASum = AFinger + i;
}
}
}
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
OtherGuess[AOtherSum - AOtherFinger] = OtherGuess[AOtherSum - AOtherFinger] + 1;
OtherFinger[AOtherFinger] = OtherFinger[AOtherFinger] + 1;
SelfGuess[ASelfSum - ASelfFinger] = SelfGuess[ASelfSum - ASelfFinger] + 1;
SelfFinger[ASelfFinger] = SelfFinger[ASelfFinger] + 1; if (ASelfResult == Result.Lost)
isOtherClever = !isOtherClever; if (ASelfResult == Result.Win)
判断智能机器人次数[Convert.ToInt16(isOtherClever)]++;
}
}public class xx_一号b : Drunkard
{
public int[][] OldFingerNum = new int[6][];
public int[][] OldGuessNum = new int[11][];
int Counter = 0; Boolean isDogFall;
Boolean isSer;
int lastFinger;
private Random random;
public xx_一号b()
{
random = new Random();
for (int i = 0; i < OldFingerNum.Length; i++)
{
OldFingerNum[i] = new int[1];
}
for (int i = 0; i < OldGuessNum.Length; i++)
{
OldGuessNum[i] = new int[1];
}
} public override void Come(out int AFinger, out int ASum)
{ if (Counter < 30)
{
AFinger = random.Next(6);
ASum = AFinger + random.Next(6);
}
else
{
int OtherlikeFinger = GetTheMax(OldFingerNum);
int OtherlikeSum = GetTheMax(OldGuessNum); AFinger = random.Next(6);
if (isDogFall)
{
if (isSer)
{
ASum = AFinger + lastFinger + 1;
}
else
{
ASum = AFinger + lastFinger;
}
}
else
{
ASum = AFinger + OtherlikeFinger;
} }
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
if (AOtherResult == Result.Dogfall)
{
isDogFall = true;
if (AOtherFinger - lastFinger == 1)
{
isSer = true;
}
lastFinger = AOtherFinger; }
else
{
isDogFall = false;
isSer = false;
} Console.Write("Counter" + Counter + "对方出" + AOtherFinger + " 我出" + ASelfFinger + " 对方猜" + AOtherSum + " 我猜" + ASelfSum + " 结果" + ASelfResult + "\n");
if (AOtherFinger <= 0 || AOtherFinger >= 5)
{ }
else
{
OldFingerNum[AOtherFinger][0]++;
} if (AOtherSum <= 0 || AOtherSum >= 11)
{ }
else
{
OldGuessNum[AOtherSum][0]++;
}
Counter++;
} public int GetTheMax(int[][] Value)
{
int MaxVaule = 0;
int Counter = 0;
for (int i = 0; i < Value.Length; i++)
{
if (MaxVaule < Value[i][0])
{
MaxVaule = Value[i][0];
Counter = i;
}
}
return Counter;
}
}
{
private Random random; Dictionary<int, int> figuerCount = new Dictionary<int, int>();
Dictionary<int, int> sumCount = new Dictionary<int, int>(); Dictionary<int, int> selffiguerCount = new Dictionary<int, int>();
Dictionary<int, int> selfSumCount = new Dictionary<int, int>(); public ZhangenterCome黄金版()
{
random = new Random(); for (int i = 0; i <= 5; i++)
{
figuerCount.Add(i, 0);
selffiguerCount.Add(i, 0);
} for (int i = 0; i <= 10; i++)
{
sumCount.Add(i, 0);
selfSumCount.Add(i, 0);
}
} public override void Come(out int AFinger, out int ASum)
{
int otherMaxFinger, otherMaxFingerCount, otherMaxSum, otherMaxSumCount, selfMaxFinger, selfMaxFingerCount;
bool mainFinger, mainSum, selfMainFigure; GetMaxValue(figuerCount, out otherMaxFinger, out otherMaxFingerCount, out mainFinger);
GetMaxValue(sumCount, out otherMaxSum, out otherMaxSumCount, out mainSum); GetMaxValue(selffiguerCount, out selfMaxFinger, out selfMaxFingerCount, out selfMainFigure); int warningFinger = otherMaxSum - otherMaxFinger; int mod = DateTime.Now.Millisecond % 2; if (!mainFinger)
{
warningFinger = GetSelfSuggestFinger(selffiguerCount); otherMaxFinger = GetOtherMaxFinger(figuerCount);
} while (true)
{
AFinger = (random.Next(6) + DateTime.Now.Millisecond) % 6;
ASum = otherMaxFinger + AFinger; if (mainFinger)
{
if (AFinger != warningFinger)
{
break;
}
}
else
{
if (AFinger != selfMaxFinger && AFinger != warningFinger && ASum != otherMaxSum)
{
break;
}
}
} double count = 1;
// 浪费点时间,把时间弄乱,反正楼主给的时间充裕
for (int i = 0; i < DateTime.Now.Millisecond % 98765; i++)
{
count *= random.Next(12345, 67890);
count /= random.Next(12345, 67890); if (count % 987654321 == DateTime.Now.Millisecond % 54321)
break;
} selffiguerCount[AFinger]++;
selfSumCount[ASum]++;
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
if (figuerCount.ContainsKey(AOtherFinger))
figuerCount[AOtherFinger]++; if (sumCount.ContainsKey(AOtherSum))
sumCount[AOtherSum]++; double count = 1;
// 浪费点时间,把时间弄乱,反正楼主给的时间充裕
for (int i = 0; i < DateTime.Now.Millisecond % 98765; i++)
{
count *= random.Next(12345, 67890);
count /= random.Next(12345, 67890); if (count % 987654321 == DateTime.Now.Millisecond % 54321)
break;
}
} private void GetMaxValue(Dictionary<int, int> d, out int maxKey, out int maxValue, out bool mainValue)
{
maxKey = 0;
maxValue = d[maxKey];
int aboutMaxValue = maxValue; foreach (int k in d.Keys)
{
if (d[k] > maxValue)
{
aboutMaxValue = maxValue; maxValue = d[k];
maxKey = k;
}
} if (maxValue > aboutMaxValue * 2 + 1)
mainValue = true;
else
mainValue = false;
} private int GetOtherMaxFinger(Dictionary<int, int> d)
{
List<int> indexKeys = new List<int>(); foreach (int k in d.Keys)
{
for (int i = 0; i < d[k]; i++)
{
indexKeys.Add(k);
}
} if (indexKeys.Count == 0)
return random.Next(6);
else
return indexKeys[random.Next(indexKeys.Count)];
} private int GetSelfSuggestFinger(Dictionary<int, int> d)
{
List<int> indexKeys = new List<int>(); foreach (int k in d.Keys)
{
for (int i = 0; i < 1000 / (d[k] + 1); i++)
{
indexKeys.Add(k);
}
} if (indexKeys.Count == 0)
return random.Next(6);
else
return indexKeys[random.Next(indexKeys.Count)];
}
}
总算帖完,大家生产的机器人还不少啊!
楼住搞个代码下载吧,顺便改成winform的
复制结果也方便
程序里单独开了一个线程,在对方演算的时候把主线程挂起1000毫秒,仅动作一次,就会导致对手严重超时而出局。但如果主线程开始挂起的时候双方对战已经结束了(电脑硬件很牛,双方算法很快的情况下),就没有意义了。如果延迟的时间不对(目前只能靠手工填个2,将来也许可以通过在Come和Outcome里计时来掌握这个时间值),就会造成自己被打出局的尴尬场面,这时你只能试着改改那个时间值。理论上可以打败任何算法延时在1毫秒以上的对手,但实际上并不一定会。另外简化了酒彪子一号的算法,确切的说是还原了,主要为了缩短算法时间,但成绩反而有些微小提升。例如能打平剪刀三号。但仍然无法打败yatobiaf_四号等杰出的算法,因为他们的算法耗时0毫秒,我的伎俩完全不起作用。而且我总是会被yatobiaf_四号把致命一击反弹到自己身上,确实佩服。 static void Main(string[] args)
{
new Drunkery<酒彪子二号, Zswang一号>().Play();
new Drunkery<酒彪子二号, Zswang二号>().Play();
new Drunkery<酒彪子二号, zhangenter>().Play();
new Drunkery<酒彪子二号, zhangenter_Killer>().Play();
new Drunkery<酒彪子二号, Zswang三号>().Play();
new Drunkery<酒彪子二号, Yuwenge>().Play();
new Drunkery<酒彪子二号, Linxu一号>().Play();
new Drunkery<酒彪子二号, yunfeng007>().Play();
new Drunkery<酒彪子二号, hhhh>().Play();
new Drunkery<酒彪子二号, ren>().Play();
new Drunkery<酒彪子二号, hhhh2>().Play();
new Drunkery<酒彪子二号, 守擂>().Play();
new Drunkery<酒彪子二号, Linxu二号>().Play();
new Drunkery<酒彪子二号, 专打Linxu二号>().Play();
new Drunkery<酒彪子二号, 守擂二号>().Play();
new Drunkery<酒彪子二号, Linxu三号>().Play();
new Drunkery<酒彪子二号, 守擂三号>().Play();
new Drunkery<酒彪子二号, Linxu四号>().Play();
new Drunkery<酒彪子二号, Zswang三号_2>().Play();
new Drunkery<酒彪子二号, nik_amis>().Play();
new Drunkery<酒彪子二号, linxu五号>().Play();
new Drunkery<酒彪子二号, 专打Zswang三号>().Play();
new Drunkery<酒彪子二号, yunfeng007二号>().Play();
new Drunkery<酒彪子二号, 专打Zlinxu五号>().Play();
new Drunkery<酒彪子二号, 专打Zlinxu四号>().Play();
new Drunkery<酒彪子二号, 擂主4>().Play();
new Drunkery<酒彪子二号, Shunyao一号>().Play();
new Drunkery<酒彪子二号, yatobiaf二号>().Play();
new Drunkery<酒彪子二号, 剪刀一号>().Play();
new Drunkery<酒彪子二号, 专打yunfeng二号>().Play();
new Drunkery<酒彪子二号, yunfeng007二号_2>().Play();
new Drunkery<酒彪子二号, yatobiaf三号>().Play();
new Drunkery<酒彪子二号, ZhangenterCome>().Play();
new Drunkery<酒彪子二号, 剪刀二号>().Play();
new Drunkery<酒彪子二号, ZhangenterCome加强版>().Play();
new Drunkery<酒彪子二号, 剪刀三号>().Play();
new Drunkery<酒彪子二号, yatobiaf_四号>().Play();
new Drunkery<酒彪子二号, yatobiaf_四号修正版>().Play();
new Drunkery<酒彪子二号, xx_一号b>().Play();
new Drunkery<酒彪子二号, ZhangenterCome黄金版>().Play();
}酒彪子二号得分:1000, Zswang一号得分:0酒彪子二号得分:637, Zswang二号得分:363酒彪子二号出拳严重超时
酒彪子二号出拳严重超时
酒彪子二号超时十次以上
酒彪子二号得分:1000, Yuwenge得分:0酒彪子二号得分:1000, Linxu一号得分:0yunfeng007接收结果严重超时
酒彪子二号出拳严重超时
酒彪子二号出拳严重超时
酒彪子二号得分:1000, hhhh2得分:0酒彪子二号超时十次以上
酒彪子二号超时十次以上
酒彪子二号出拳严重超时
守擂二号接收结果严重超时
酒彪子二号得分:998, Linxu三号得分:2酒彪子二号出拳严重超时
酒彪子二号得分:1000, Linxu四号得分:0Zswang三号_2接收结果严重超时
酒彪子二号得分:1000, nik_amis得分:0酒彪子二号得分:956, linxu五号得分:44酒彪子二号超时十次以上
yunfeng007二号接收结果严重超时
专打Zlinxu五号接收结果严重超时
酒彪子二号超时十次以上
酒彪子二号得分:494, 擂主4得分:506Shunyao一号出拳严重超时
酒彪子二号超时十次以上
酒彪子二号得分:999, 剪刀一号得分:1酒彪子二号超时十次以上
酒彪子二号得分:999, yunfeng007二号_2得分:1酒彪子二号得分:1000, yatobiaf三号得分:0ZhangenterCome出拳严重超时
剪刀二号出拳严重超时
ZhangenterCome加强版出拳严重超时
剪刀三号出拳严重超时
yatobiaf_四号出拳严重超时
酒彪子二号超时十次以上
Counter0对方出3 我出4 对方猜5 我猜9 结果Dogfall
xx_一号b接收结果严重超时
ZhangenterCome黄金版出拳严重超时 // using System.Threading;
public class 酒彪子二号 : Drunkard
{
int[] 对方猜的数的次数记录 = new int[6];
int[] 对方出的数的次数记录 = new int[6];
Thread 被干扰的线程 = Thread.CurrentThread;
bool 我要发赖=true;
Thread 干扰器线程; public 酒彪子二号()
{
干扰器线程 = new Thread(干扰器);
} void 干扰器()
{
// 关键就是这个延时值,调整好了可以一局定输赢
// 目前还无法自动计算这个值,以后也许能做出来
Thread.Sleep(2);
被干扰的线程.Suspend();
Thread.Sleep(1000);
被干扰的线程.Resume();
Thread.EndThreadAffinity();
} public override void Come(out int AFinger, out int ASum)
{
int[] 最优解集 ={ 0, 1, 2, 3, 4, 5 };
Array.Sort((int[])(对方猜的数的次数记录.Clone()), 最优解集);
AFinger = 最优解集[new Random().Next(Array.LastIndexOf<int>(最优解集, 最优解集[0]) + 1)]; 最优解集 = new int[6] { 0, 1, 2, 3, 4, 5 };
Array.Sort((int[])(对方出的数的次数记录.Clone()), 最优解集);
ASum = 最优解集[new Random().Next(Array.LastIndexOf<int>(最优解集, 最优解集[5]), 6)] + AFinger; if (我要发赖)
{
我要发赖 = false;
干扰器线程.Start();
被干扰的线程.Priority = ThreadPriority.BelowNormal;
}
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
/* 这机器人关心比赛结果 */
对方猜的数的次数记录[AOtherSum - AOtherFinger] = 对方猜的数的次数记录[AOtherSum - AOtherFinger] + 1;
对方出的数的次数记录[AOtherFinger] = 对方出的数的次数记录[AOtherFinger] + 1;
}
}
乱写了个,先撑下场面,避免大比分落败,嘿嘿-_-!
public class nik_amis2 : Drunkard
{
Random r = new Random(DateTime.Now.Millisecond);
static int n = 0;
public override void Come(out int AFinger, out int ASum)
{
switch (r.Next(3))
{
case 0:
Thread.Sleep(r.Next(2));
int c=DateTime.Now.Millisecond;
AFinger = c / 100; if (AFinger > 5) AFinger -= 5;
ASum = r.Next(0, 6) + AFinger;
break;
case 1:
Thread.Sleep(r.Next(2));
AFinger = r.Next(6);
ASum = r.Next(0, 6) + AFinger;
break;
default:
Thread.Sleep(r.Next(2));
Random m = new Random(r.Next(10000));
int[] f = new int[] { 5, 3, 2, 4, 1, 0 };
AFinger = f[r.Next(0, 120) / 20];
ASum = m.Next(0, 2) * 5 + AFinger;
if (r.Next(1000) > 500) ASum = m.Next(1, 6) + AFinger;
break;
}
} public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult,
int ASelfFinger, int ASelfSum, Result ASelfResult)
{
}
}
这种算是出老千,而且容易误伤自己,呵呵
关于出老千,我觉得还可以通过分析Come()方法堆栈,获得Drunkery<T1, T2>的实例,然后将对手替换掉不过,如何获得调用方法的实例我还没有找到。
目前止步于:
public override void Come(out int AFinger, out int ASum)
{
AFinger = random.Next(6);
ASum = 5;
StackTrace vStackTrace = new StackTrace();
foreach (StackFrame vStackFrame in vStackTrace.GetFrames())
{
MethodBase vMethodBase = vStackFrame.GetMethod();
if (string.Compare(vMethodBase.Name, "Play", true) == 0)
{
Console.WriteLine(vMethodBase.Name);
break;
}
}
}当然,做人要厚道;
抓住别人的弱点攻击没有问题,但不能抓住比赛平台的弱点攻击。
作为研究,关于出老千我们另行讨论,不参与正常比赛 ^o^
1.随机数是否要规定必须用自己的函数生成,而不是调用random(),这样对擂主的挑战会更大点,不然基本靠随机了。
2.可不可以,实时更新最新的擂主是谁,他的代码,这样就不用看完贴才知道是咋回事,毕竟大家都很忙,玩玩而已,不必太累了。
3.提供界面程序。这样趣味性更大。
uses SysConst;
//这是我照内核翻译的Random代码
type
TRandom = class
private
inext: Integer;
inextp: Integer;
SeedArray: array of Integer;
function GetSampleForLargeRange: Double;
function InternalSample: Integer;
function Sample: Double;
public
constructor Create; overload;
constructor Create(Seed: Integer); overload; function Next: Integer; overload;
function Next(maxValue: Integer): Integer; overload;
function Next(minValue, maxValue: Integer): Integer; overload;
function NextDouble: Double; overload;
procedure NextBytes(var buffer; size: Integer);
end;{ TRandom }constructor TRandom.Create(Seed: Integer);
var
num2, num3: Integer;
i, j, k: Integer;
index: Integer;
begin
SetLength(SeedArray, $38);
num2 := $9a4ec86 - Abs(Seed);
SeedArray[$37] := num2;
num3 := 1;
for i := 1 to $37 - 1 do
begin
index := ($15 * i) mod $37;
SeedArray[index] := num3;
num3 := num2 - num3;
if num3 < 0 then Inc(num3, $7fffffff);
num2 := SeedArray[index];
end;
for j := 1 to 5 - 1 do
begin
for k := 1 to $38 - 1 do
begin
SeedArray[k] := SeedArray[k] - SeedArray[1 + ((k + 30) mod $37)];
if SeedArray[k] < 0 then Inc(SeedArray[k], $7fffffff);
end;
end;
inext := 0;
inextp := $15;
end;constructor TRandom.Create;
begin
Create(GetTickCount);
end;function TRandom.GetSampleForLargeRange: Double;
var
num, num2: Double;
begin
num := InternalSample;
if InternalSample mod 2 <> 0 then
num := -num;
num2 := num + 2147483646.0;
Result := num2 / 4294967293;
end;function TRandom.InternalSample: Integer;
var
inext, inextp: Integer;
num: Integer;
begin
inext := Self.inext;
inextp := Self.inextp;
Inc(inext);
if inext >= $38 then inext := 1;
Inc(inextp);
if inextp >= $38 then inextp := 1; num := SeedArray[inext] - SeedArray[inextp];
if num < 0 then Inc(num, $7fffffff);
SeedArray[inext] := num;
Self.inext := inext;
Self.inextp := inextp;
Result := num;
end;function TRandom.Next: Integer;
begin
Result := InternalSample;
end;function TRandom.Next(maxValue: Integer): Integer;
begin
if maxValue < 0 then
raise ERangeError.CreateRes(@SRangeError);
Result := Trunc(Sample * maxValue);
end;function TRandom.Next(minValue, maxValue: Integer): Integer;
var
num: Int64;
begin
if minValue > maxValue then
raise ERangeError.CreateRes(@SRangeError);
num := maxValue - minValue;
if num <= $7fffffff then
Result := Trunc(Sample * num) + minValue
else Result := Trunc(GetSampleForLargeRange * num) + minValue;
end;procedure TRandom.NextBytes(var buffer; size: Integer);
var
I: Integer;
begin
for I := 0 to size - 1 do
PChar(buffer)[I] := Char(InternalSample mod $100);
end;function TRandom.NextDouble: Double;
begin
Result := Sample;
end;function TRandom.Sample: Double;
begin
Result := InternalSample * 4.6566128752457969E-10;
end;
2、目前是看谁战胜的机器人数量最多,而不是打败专门的机器人,就没有擂主一说了
3、有个界面是不错的想法。在设计下一个游戏的时候就考虑。
在自己的come()结束时更改程序的安全权限,让主程序不允许调用派生的方法,一调用对方的come()就抛异常,从而取胜。 还有就是调用API方法扫描主程序的变量堆栈,修改对方的计时参考值,是对方超时出局,可惜我也写不出来,期待高人!
那假如两个人都犯规的情况呢?为什么不用||呢? 我很菜 别笑话俺呵呵
#region 有一个人犯规
if (vEastResult == Result.Foul ^ vWestResult == Result.Foul)
{
#region 如犯规判则对方赢
if (vEastResult == Result.Foul)
vWestResult = Result.Win;
else if (vWestResult == Result.Foul)
vEastResult = Result.Win;
#endregion 如犯规判则对方赢
}
#endregion 有一个人犯规
false ^ true = true
false ^ false = false
true ^ true = false
ZhangenterCome黄金版得分:508, Zswang二号得分:492
ZhangenterCome黄金版得分:880, zhangenter得分:120
ZhangenterCome黄金版得分:514, Zswang三号66楼得分:486
ZhangenterCome黄金版得分:1000, Yuwenge得分:0
ZhangenterCome黄金版得分:610, yunfeng007得分:390
ZhangenterCome黄金版得分:579, hhhh得分:421
ZhangenterCome黄金版得分:1000, ren得分:0
ZhangenterCome黄金版得分:999, hhhh2得分:1
ZhangenterCome黄金版得分:553, 守擂得分:447
ZhangenterCome黄金版得分:568, Linxu二号得分:432
ZhangenterCome黄金版得分:1000, 专打Linxu二号得分:0
ZhangenterCome黄金版得分:540, 守擂二号得分:460
ZhangenterCome黄金版得分:698, Linxu三号得分:302
ZhangenterCome黄金版得分:507, 守擂三号得分:493
ZhangenterCome黄金版得分:1000, Linxu四号得分:0
ZhangenterCome黄金版得分:999, Zswang三号得分:1
ZhangenterCome黄金版得分:1000, nik_amis得分:0
ZhangenterCome黄金版得分:700, linxu五号得分:300
ZhangenterCome黄金版得分:511, 专打Zswang三号得分:489
ZhangenterCome黄金版得分:677, yunfeng007二号得分:323
ZhangenterCome黄金版得分:521, 专打Zlinxu五号得分:479
ZhangenterCome黄金版得分:504, 专打Zlinxu四号得分:496
ZhangenterCome黄金版得分:507, 擂主4得分:493
ZhangenterCome黄金版得分:706, yunfeng007二号210楼得分:294
ZhangenterCome黄金版得分:1000, 剪刀一号得分:0
ZhangenterCome黄金版得分:637, 专打yunfeng二号得分:363
ZhangenterCome黄金版得分:690, yunfeng007二号188楼得分:310
ZhangenterCome黄金版得分:1000, ZhangenterCome得分:0
ZhangenterCome黄金版得分:653, 专打yunfeng二号226楼得分:347
ZhangenterCome黄金版得分:778, 剪刀二号得分:222
ZhangenterCome黄金版得分:542, ZhangenterCome加强版得分:458
ZhangenterCome黄金版得分:531, 酒彪子一号得分:469
ZhangenterCome黄金版得分:670, 剪刀三号得分:330
ZhangenterCome黄金版得分:982, Zswang四号得分:18
ZhangenterCome黄金版得分:850, yatobiaf_四号得分:150
ZhangenterCome黄金版得分:597, xx_一号得分:403
ZhangenterCome黄金版得分:635, yatobiaf_四号修正版得分:365
ZhangenterCome黄金版得分:658, xx_一号b得分:34225胜14平0败,还有没有人在玩?
再请教一下
关于那个超时的处理 总共有三处都用到了
初始化的时候为什么要这样初始化
long vEastTick = Environment.TickCount; // 东家初始化的时间
eastPlayer = new T1();
vEastTick = Environment.TickCount - vEastTick;这样的结果不是0吗?直接赋值0不可以吗?if (vEastTick > 1000 || vWestTick > 1000) 这样的情况是怎么出现的呢?
可以在构造的时候Thread.Sleep(2000)测试看看。
能否根据此概率比来做一点文章?
比如说,在1000次的比赛过程中,利用概率分析学方面的知识来分析
前100次对方所出招数,得出的结果立刻用来服务于后900次比赛!
(这也是我的一个小小想法,不知怎样^ 大家探讨下)
{
public class DrunkarCommon
{
public Dictionary<int, int> history = new Dictionary<int,int>();
}
private Random random;
private int Drunkardcount = 0;
private Dictionary<int,DrunkarCommon> ComeOne = null;
private int hFinger = 0;
public Yangzk008下忍版()
{
random = new Random(); ComeOne = new Dictionary<int, DrunkarCommon>();
} public override void Come(out int AFinger, out int ASum)
{
AFinger = random.Next(6); if (this.ComeOne.ContainsKey(hFinger) && this.ComeOne[hFinger].history.Values.Count > 0 )
{
int key = 0;
int value = 0; Dictionary<int, int>.Enumerator IEnumer = ComeOne[hFinger].history.GetEnumerator(); while(IEnumer.MoveNext())
{
if(IEnumer.Current.Value >= value)
{
key = IEnumer.Current.Key;
}
} ASum = AFinger + key; if(ASum > 10)
{
ASum = random.Next(key, 11 - key); AFinger = ASum - key;
}
}
else
{
ASum = random.Next(AFinger,11);
}
}
//ASum = random.Next(10 + 1); //0-10
//if (ASum < 5) // 别犯规
// AFinger = random.Next(ASum + 1);
//else AFinger = random.Next(ASum - 5, 5 + 1); public override void Outcome(int AOtherFinger, int AOtherSum, Result AOtherResult, int ASelfFinger, int ASelfSum, Result ASelfResult)
{
if (Drunkardcount != 0)
{
if (!this.ComeOne.ContainsKey(hFinger))
{
this.ComeOne.Add(hFinger, new DrunkarCommon());
} if (this.ComeOne[hFinger].history.ContainsKey(AOtherFinger))
{
this.ComeOne[hFinger].history[AOtherFinger]++;
}
else
{
this.ComeOne[hFinger].history.Add(AOtherFinger, 1);
}
} hFinger = AOtherFinger;
Drunkardcount++;
Console.Write("对方出" + AOtherFinger + " 我出" + ASelfFinger + " 对方猜" + AOtherSum + " 我猜" + ASelfSum + " 结果" + ASelfResult + "\n");
}
}贴出我写的代码,跟大家决一下
我测试了一下 跟ZhangenterCome黄金版互有胜负。测试了10次。我的胜面高一些。算法还有改进的空间。先贴出来。有时间再改进一下
另外 for (int j = 0; j < 100; j++)这个为什么要呢
Outcome这个抽象方法好象还用不上//