使用神经网络与遗传算法的小游戏


神经网络和遗传算法参考《游戏中的人工智能技术》一书。 使用平台修改自programking同学的超级玛丽源码 (http://download.csdn.net/source/497676)
资源截图
代码片段和文件信息
#include “stdafx.h“
#include “bitmaptool.h“
#include “Gamemap.h“

extern GAMEMAP* pGamemap;

extern FILEREPORT f1;

 int MYBITMAP::g_nMapWidth;//地图宽度
 int MYBITMAP::g_nMapHeight;
 HDC MYBITMAP::g_hdcdest;
 HDC MYBITMAP::g_hdcsrc;

MYBITMAP::MYBITMAP()
{

}

MYBITMAP::~MYBITMAP()
{
Deleteobject(hBm);
}

void MYBITMAP::Init(HINSTANCE hInstanceint iResourceint rowint col)
{
BITMAP bm;
inum=row;//单位图形行数
jnum=col;//单位图形列列

LPTSTR pstr=MAKEINTRESOURCE(iResource);
hBm=LoadBitmap(hInstancepstr);
Getobject(hBmsizeof(BITMAP)&bm);

width=bm.bmWidth/jnum;
height=bm.bmHeight/inum;

}

void MYBITMAP::SetDevice(HDC hdestHDC hsrcint wwinint hwin)
{
g_hdcdest=hdest;
g_hdcsrc=hsrc;
g_nMapWidth=wwin;
g_nMapHeight=hwin;
}

void MYBITMAP::Show(int xint y)
{
m_curPos.x=x;
m_curPos.y=y;
Selectobject(g_hdcsrchBm);
BitBlt(g_hdcdestm_curPos.xm_curPos.ywidthheightg_hdcsrc00SRCCOPY);
}

void MYBITMAP::ShowCenter(int y)
{
m_curPos.x=(g_nMapWidth-width)/2;
m_curPos.y=y;

Selectobject(g_hdcsrchBm);
BitBlt(g_hdcdestm_curPos.xm_curPos.ywidthheightg_hdcsrc00SRCCOPY);
}

void MYBITMAP::ShowLoop(int leftint topint rightint bottomint iframe)
{
int ij;

Selectobject(g_hdcsrchBm);
for(j=top;j {
for(i=left;i {
BitBlt(g_hdcdestijwidthheightg_hdcsrciframe*width0SRCCOPY);
}
}
}

void MYBITMAP::ShowNoBack(int xint yint iframe)
{
m_curPos.x=x;
m_curPos.y=y;
Selectobject(g_hdcsrchBm);
BitBlt(g_hdcdestm_curPos.xm_curPos.ywidthheight/2g_hdcsrciframe*widthheight/2SRCAND);
BitBlt(g_hdcdestm_curPos.xm_curPos.ywidthheight/2g_hdcsrciframe*width0SRCPAINT);
}


void MYBITMAP::ShowNoBackLoop(int xint yint iframeint iNum)
{
int i;
m_curPos.x=x;
m_curPos.y=y;
Selectobject(g_hdcsrchBm);
for(i=0;i {
BitBlt(g_hdcdestm_curPos.x+i*widthm_curPos.ywidthheight/2g_hdcsrciframe*widthheight/2SRCAND);
BitBlt(g_hdcdestm_curPos.x+i*widthm_curPos.ywidthheight/2g_hdcsrciframe*width0SRCPAINT);
}
}

void MYBITMAP::ShowAni()
{
/* if(!iStartAni)
return;

Selectobject(g_hdcsrchBm);
BitBlt(g_hdcdestm_curPos.xm_curPos.ywidthheight/2g_hdcsrcframenow*widthheight/2SRCAND);
BitBlt(g_hdcdestm_curPos.xm_curPos.ywidthheight/2g_hdcsrcframenow*width0SRCPAINT);

framenow++;
//播放结束
if(framenow>=inum)
iStartAni=0;
*/
}
//设置位图在屏幕中显示的起点位置
void MYBITMAP::SetAni(int xint y)
{
m_curPos.x=x;
m_curPos.y=y;
/*
framenow=0;
iStartAni=1;
*/
}

//设置位图在屏幕中显示的起点位置
void MYBITMAP::SetPos(int istyleint xint y)
{
switch(istyle)
{
case BM_CENTER:
m_curPos.x=(g_nMapWidth-width)/2;
m_curPos.y=y;
break;
case BM_USER:
m_curPos.x=x;
m_curPos.y=y;
break;
}
}

void MYBITMAP::Draw(DWORD dwRop)
{
Selectobject(g_hdcsrchBm);
BitBlt(g_hdcdestm_curPos.xm_curPos.ywidthheightg_hdcs

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      17718  2008-09-15 23:57  MarryBirdBird.cpp

     文件       7169  2008-09-15 23:07  MarryBirdBird.h

     文件       2848  2002-02-18 14:23  MarryBirdC2DMatrix.cpp

     文件       1729  2002-02-18 14:23  MarryBirdC2DMatrix.h

     文件       8716  2008-09-08 21:37  MarryBirdCData.cpp

     文件       5867  2008-09-16 00:01  MarryBirdCData.h

     文件       8346  2008-09-15 23:07  MarryBirdCGenAlg.cpp

     文件       3613  2008-09-15 23:07  MarryBirdCGenAlg.h

     文件       5204  2008-09-11 23:17  MarryBirdCMapper.cpp

     文件       3367  2008-09-11 23:17  MarryBirdCMapper.h

     文件       7082  2008-08-27 00:13  MarryBirdCNeuralNet.cpp

     文件       2466  2008-08-13 15:40  MarryBirdCNeuralNet.h

     文件       1185  2008-09-15 23:07  MarryBirdcollision.cpp

     文件        641  2008-09-15 23:46  MarryBirdcollision.h

     文件        413  2008-07-31 12:58  MarryBirdConsciousness.cpp

     文件        637  2008-08-17 06:52  MarryBirdConsciousness.h

     文件      13604  2008-09-15 23:40  MarryBirdCRace.cpp

     文件       3893  2008-09-15 23:38  MarryBirdCRace.h

     文件       2992  2008-09-02 15:25  MarryBirdCTimer.cpp

     文件       1156  2008-09-02 15:25  MarryBirdCTimer.h

     文件       2710  2008-08-25 22:12  MarryBirdSVector2D.h

     文件       1119  2002-02-17 11:09  MarryBirdutils.cpp

     文件       1532  2002-06-05 15:47  MarryBirdutils.h

     文件       9259  2008-09-16 00:09  Marryitmaptool.cpp

     文件       4226  2008-09-15 23:40  Marryitmaptool.h

     文件       2279  2008-09-09 13:40  Marrydefine.h

     文件       1240  2008-08-27 16:36  Marryfilereport.cpp

     文件        524  2008-08-30 14:39  Marryfilereport.h

     文件      26106  2008-09-15 23:53  Marrygamemap.cpp

     文件       3646  2008-08-30 14:41  Marrygamemap.h

............此处省略102个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)