开发工具:
文件大小: 105kb
下载次数: 0
上传时间: 2013-06-27
详细说明:
是win7 x64版的主要算法代码如下: public class robot { public robot(byte[] robotbyte,int x,int y) { this.robotbyte = new byte[x,y]; for (int j = 0; j < y; j++) { for (int i = 0; i < x; i++) { this.robotbyte[i, j] = robotbyte[j * x + i]; } } this.backupbyte = new byte[x, y]; this.backupbyte = this.robotbyte; this.robotheight = y; thi s.robotwidth = x; this.steps = new List(); this.firstpoint = new Point(0, 0); this.secondpoint = new Point(1,0); } public byte[,] robotbyte; public byte[,] backupbyte; public int robotwidth; public int robotheight; public int unitcount; public int bushu; private Point firstpoint; private Point secondpoint; public List steps; private bool dealroundpoint(Point firstp,out Point secondp) { bool isconnect = false; if (robotbyte[firstp.X, firstp.Y] == GetValueByPos(new Point(firstp.X,firstp.Y-1))) { secondp = new Point(firstp.X, firstp.Y - 1); isconnect = true; } else { if (robotbyte[firstp.X, firstp.Y] ==GetValueByPos(new Point(firstp.X+1,firstp.Y))) { secondp = new Point(firstp.X + 1, firstp.Y); isconnect = true; } else { if (robotbyte[firstp.X, firstp.Y] == GetValueByPos(new Point(firstp.X-1,firstp.Y))) { secondp = new Point(firstp.X - 1, firstp.Y); isconnect=true; } else { if (robotbyte[firstp.X, firstp.Y] == GetValueByPos(new Point(firstp.X,firstp.Y+1))) { secondp = new Point(firstp.X, firstp.Y + 1); isconnect = true; } else { secondp = firstp; } } } } return isconnect; } private bool shulinepoint(Point firstp, Point secondp,Point range) { bool isconnect=false; if (firstp.Y > secondp.Y) { Point tempp = firstp; firstp = secondp; secondp = firstp; } for (int i=range.X; i <=range.Y; i++) { for (int j=firstp.Y+1; j secondp.X) { Point tempp = firstp; firstp = secondp; secondp = firstp; } for (int i =range.X; i <=range.Y; i++) { for (int j = firstp.X+1; j sp.Y) { if (fp.X <= sp.Y) { isjiao = true; } } else if (fp.Y == sp.Y) { isjiao = true; } else { if (fp.Y >= sp.X) { isjiao = true; } } if (isjiao) { range.X = Math.Max(fp.X, sp.X); range.Y = Math.Min(fp.Y, sp.Y); } return isjiao; } private Point GetXRange(Point tempp) { int min=tempp.X; int max=tempp.X; while (min >0) { min--; if (robotbyte[min, tempp.Y] != 0) { min = min + 1; break; } } while (max < this.robotheight-1) { max++; if (robotbyte[max,tempp.Y] != 0) { max = max - 1; break; } } return new Point(min, max); } private Point GetYRange(Point tempp) { int min = tempp.Y; int max = tempp.Y; while (min>0) { min--; if (robotbyte[tempp.X, min]!=0) { min = min + 1; break; } } while(max 0) { fp = new Point(fj, fi); if (dealroundpoint(fp, out sp)) { steps.Add(new Step(fp, sp)); robotbyte[fp.X, fp.Y] = 0; robotbyte[sp.X, sp.Y] = 0; stepmark++; } } } } while (stepmark< this.bushu) { int tempstepmark = stepmark; for (int fi = 0; fi < robotheight; fi++) { for (int fj = 0; fj < robotwidth; fj++) { if (this.GetValueByPos(new Point(fj, fi)) > 0) { fp = new Point(fj, fi); if(this.dealroundpointE(fp,out sp)) { steps.Add(new Step(fp, sp)); robotbyte[fp.X, fp.Y] = 0; robotbyte[sp.X, sp.Y] = 0; stepmark++; continue; } List sps = GetSecondByOnePos(fp); foreach (var temp in sps) { if (dealtwopoint(fp, temp)) { steps.Add(new Step(fp, temp)); robotbyte[fp.X, fp.Y] = 0; robotbyte[temp.X, temp.Y] = 0; stepmark++; break; } } } } } if (tempstepmark == stepmark) { break; } } } private List GetSecondByOnePos(Point fp) { List sp = new List(); for (int sj = 0; sj < robotheight; sj++) { for (int si = 0; si < robotwidth; si++) { if (this.robotbyte[fp.X, fp.Y] == this.robotbyte[si, sj]) { if (fp.X != si||fp.Y != sj) { sp.Add(new Point(si,sj )); } } } } return sp; } public class Step { public Point fp; public Point sp; public Step(Point fp,Point sp) { this.fp = fp; this.sp = sp; } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.