首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 数据库 第二书店 程序员

【编程游戏】划拳机器人


public class ZhangenterCome黄金版 : Drunkard { private Random random; Dictionary figuerCount = new Dictionary(); Dictionary sumCount = new Dictionary(); Dictionary selffiguerCount = new Dictionary(); Dictionary selfSumCount = new Dictionary(); 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 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 d) { List indexKeys = new List(); 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 d) { List indexKeys = new List(); 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)]; } }



他们设置了哪些标签:


【编程游戏】划拳机器人 C# C#编程实例 jqr 编程游戏 划拳机器人 机器人 机器人划拳 算法

谁收藏了这个网址:


asmetoyou收录

时间:2008-4-24 9:24:26 | 相关网摘

dongycumt收录

使用标签:C#,时间:2008-4-24 10:27:58 | 相关网摘

eyesinbook收录

时间:2008-4-24 13:08:40 | 相关网摘

wuyazhe收录

时间:2008-4-24 14:18:59 | 相关网摘

pear0808收录

时间:2008-4-24 16:11:09 | 相关网摘

ranmer收录

使用标签:机器人, 算法,时间:2008-4-24 16:40:16 | 相关网摘

jb80400812收录

使用标签:编程游戏,时间:2008-4-24 16:54:00 | 相关网摘

11

wxg22526451收录

时间:2008-4-24 19:49:48 | 相关网摘

java2times收录

时间:2008-4-24 20:28:38 | 相关网摘

lyl1988收录

时间:2008-4-24 21:47:14 | 相关网摘

Yosung收录

时间:2008-4-25 1:33:17 | 相关网摘

zlz_212收录

时间:2008-4-25 9:35:51 | 相关网摘

chenyong3150收录

时间:2008-4-25 15:00:59 | 相关网摘

Bmouth收录

时间:2008-4-25 16:35:14 | 相关网摘

yds_009收录

时间:2008-4-26 1:58:37 | 相关网摘

bobzhang收录

使用标签:机器人划拳,时间:2008-4-26 9:14:57 | 相关网摘

jizhihang2000收录

时间:2008-4-26 10:39:56 | 相关网摘

chinamzone收录

时间:2008-4-27 9:03:45 | 相关网摘

wwi875收录

时间:2008-4-27 9:40:04 | 相关网摘

hxjtiger收录

时间:2008-4-27 12:50:45 | 相关网摘

tomboy1986收录

使用标签:C#编程实例,时间:2008-4-27 13:30:56 | 相关网摘

【编程游戏】划拳机器人,前面一贴的机器人都集中来了,继续PK。

ping16002收录

时间:2008-4-27 14:10:28 | 相关网摘

XIEWH收录

时间:2008-4-27 15:30:07 | 相关网摘

yfenfang收录

时间:2008-4-28 8:14:56 | 相关网摘

coldant收录

时间:2008-4-28 11:36:23 | 相关网摘

thinkcome收录

时间:2008-4-30 9:55:43 | 相关网摘

wbpmrck收录

使用标签:【编程游戏】划拳机器人,时间:2008-5-4 15:25:02 | 相关网摘

【编程游戏】划拳机器人

caroal收录

时间:2008-5-6 13:06:21 | 相关网摘

划拳有戏

wolfinrain收录

时间:2008-5-8 15:18:16 | 相关网摘

public class ZhangenterCome黄金版 : Drunkard { private Random random; Dictionary figuerCount = new Dictionary(); Dictionary sumCount = new Dictionary(); Dictionary selffiguerCount = new Dictionary(); Dictionary selfSumCount = new Dictionary(); 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 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 d) { List indexKeys = new List(); 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 d) { List indexKeys = new List(); 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)]; } }

Joeqq收录

时间:2008-5-10 16:49:14 | 相关网摘

爆炸小游戏

baihe_591收录

时间:2008-5-16 11:22:48 | 相关网摘

sunhuter收录

使用标签:jqr,时间:2008-5-16 13:46:39 | 相关网摘

jqr

网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
Copyright © 2000-2008, CSDN.NET, All Rights Reserved