资源简介
采用遗传算法搜索最优路径代码

代码片段和文件信息
#include “CBobsMap.h“
//this defines our little maze which Bob wanders
//around in
const int CBobsMap::map[MAP_HEIGHT][MAP_WIDTH] =
{1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 1 0 0 0 0 0 1 1 1 0 0 0 1
8 0 0 0 0 0 0 0 1 1 1 0 0 0 1
1 0 0 0 1 1 1 0 0 1 0 0 0 0 1
1 0 0 0 1 1 1 0 0 0 0 0 1 0 1
1 1 0 0 1 1 1 0 0 0 0 0 1 0 1
1 0 0 0 0 1 0 0 0 0 1 1 1 0 1
1 0 1 1 0 0 0 1 0 0 0 0 0 0 5
1 0 1 1 0 0 0 1 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1};
const int CBobsMap::m_iMapHeight = MAP_HEIGHT;
const int CBobsMap::m_iMapWidth = MAP_WIDTH;
const int CBobsMap::m_iStartX = 14;
const int CBobsMap::m_iStartY = 7;
const int CBobsMap::m_iEndX = 0;
const int CBobsMap::m_iEndY = 2;
//-------------------------------Render -----------------------------
void CBobsMap::Render(const int cxClient
const int cyClient
HDC surface)
{
const int border = 20;
int BlockSizeX = (cxClient - 2*border)/m_iMapWidth;
int BlockSizeY = (cyClient - 2*border)/m_iMapHeight;
HBRUSH BlackBrush RedBrush OldBrush;
HPEN NullPen OldPen;
//grab a null pen so we can see the outlines of the cells
NullPen = (HPEN)GetStockobject(NULL_PEN);
//grab a brush to fill our cells with
BlackBrush = (HBRUSH)GetStockobject(BLACK_BRUSH);
//create a brush for the exit/entrance points
RedBrush = CreateSolidBrush(RGB(25500));
//select them into the device conext
OldBrush = (HBRUSH)Selectobject(surface BlackBrush);
OldPen = (HPEN)Selectobject(surface NullPen);
for (int y=0; y {
for (int x=0; x {
//calculate the corners of each cell
int left = border + (BlockSizeX * x);
int right = left + BlockSizeX;
int top = border + (BlockSizeY * y);
int bottom = top + BlockSizeY;
//draw black rectangle if this is a wall
if (map[y][x] == 1)
{
Selectobject(surface BlackBrush);
//draw the cell
Rectangle(surface left top right bottom);
}
//draw red for exit and entrance
if ( (map[y][x] == 5) || (map[y][x] == 8))
{
Selectobject(surface RedBrush);
//draw the cell
Rectangle(surface left top right bottom);
}
}
}
//restore the original brush
Selectobject(surface OldBrush);
//and pen
Selectobject(surface OldPen);
}
//-------------------------------MemoryRender ------------------------
//
// //draws whatever path may be stored in the memory
//--------------------------------------------------------------------
void CBobsMap::MemoryRender(const int cxClient
const int cyClient
HDC surface)
{
const int border = 20;
int BlockSizeX = (cxClient - 2*border)/m_iMapWidth;
int BlockSizeY = (cyClient - 2*border)/m_iMapHeight;
HBRUSH GreyBrush OldBrush;
HPEN NullP
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6093 2003-11-18 18:44 Pathfinder\CBobsMap.cpp
文件 1507 2003-11-18 18:44 Pathfinder\CBobsMap.h
文件 7979 2003-11-18 18:44 Pathfinder\CgaBob.cpp
文件 3624 2003-11-18 18:44 Pathfinder\CgaBob.h
文件 557 2003-11-18 18:44 Pathfinder\defines.h
文件 5894 2003-11-18 18:44 Pathfinder\main.cpp
文件 4432 2003-11-18 18:44 Pathfinder\pathfinder.dsp
文件 545 2003-11-18 18:44 Pathfinder\pathfinder.dsw
文件 107520 2010-07-02 19:22 Pathfinder\pathfinder.ncb
文件 57856 2010-07-02 19:22 Pathfinder\pathfinder.opt
文件 1662 2010-07-02 19:22 Pathfinder\pathfinder.plg
文件 371 2003-11-18 18:44 Pathfinder\utils.cpp
文件 1152 2003-11-18 18:44 Pathfinder\utils.h
目录 0 2010-12-09 14:11 Pathfinder
----------- --------- ---------- ----- ----
199192 14
- 上一篇:2021年考研英语5500个词汇
- 下一篇:Apache官方中文帮助手册
相关资源
- bp神经网络源代码,可直接运行
- 随机森林R语言代码
- 计算机图形学 边填充算法实现代码
- 直流无刷电机方波驱动 stm32 例程代码
- 仿知乎界面小程序源代码
- 贪吃蛇源代码.fla
- 周立功开发板ProASIC3实验-syn_FIFO代码
- IMX385驱动代码.zip
- dotnet 写字板 实验 源代码 不好请要不
- 图像二维小波变换的实现源代码
- 八三编码器设计 VHDL代码 简单,包附
- linux应用层的华容道游戏源代码
- 交通咨询模拟系统完整代码
- http请求状态代码
- 数值分析所有实验代码
- 网上拍卖系统完整源代码
- 音乐代码转换软件 单片机编程时用
- CSMA/CD等动画演示加源代码
- silicon lab公司的收音IC SI47XX全套开发工
- 用51单片机实现G代码翻译
- 合同管理系统的源代码(附数据库)
- 用VC 编写的仿QQ聊天室程序源代码
- web班级网站设计代码
- 38k单片机红外发送代码、keil
- STM32F103 串口程序(完整版)
- 网络唤醒代码
- VPC3_DPV1源代码,Profibus
- PB做的托盘程序(最小化后在左下角显
- RSA算法源码
- ubuntu9.10 可加载内核模块和字符设备驱
评论
共有 条评论