人工智能课件第三次课.ppt

上传人:b****2 文档编号:2639349 上传时间:2022-11-04 格式:PPT 页数:26 大小:88KB
下载 相关 举报
人工智能课件第三次课.ppt_第1页
第1页 / 共26页
人工智能课件第三次课.ppt_第2页
第2页 / 共26页
人工智能课件第三次课.ppt_第3页
第3页 / 共26页
人工智能课件第三次课.ppt_第4页
第4页 / 共26页
人工智能课件第三次课.ppt_第5页
第5页 / 共26页
点击查看更多>>
下载资源
资源描述

人工智能课件第三次课.ppt

《人工智能课件第三次课.ppt》由会员分享,可在线阅读,更多相关《人工智能课件第三次课.ppt(26页珍藏版)》请在冰豆网上搜索。

人工智能课件第三次课.ppt

运动模式PatternMovementoThecomputer-controlledcharactersmoveaccordingtosomepredefinedpatternthatmakesitappearasthoughtheyareperformingcomplex,thought-outmaneuvers.计算机控制的人物按照某种预定的运动模式移动,好像他们执行复杂的、预先想好的策略执行。

circle、square、zigzag、curve标准算法StandardAlgorithmoThestandardpatternmovementalgorithmuseslistsorarraysofencodedinstructions,orcontrolinstructions,thattellthecomputer-controlledcharacterhowtomoveeachstepthroughthegameloop.标准运动模式算法用预先编好的指令或控制指令存于列表或数组,能够指导计算机控制的人物如何在游戏循环中移动每一步。

控制指令数据结构controlinstructionsdatastructureControlDatadoubleturnRight;/右转doubleturnLeft;/左转doublestepForward;/前进doublestepBackward;/后退变量说明turnRight,turnLeft/thenumberofdegrees角度stepForward,stepBackward/thenumberofdistanceunitsortiled长度模式初始化PatterninitializationPattern0.turnRight=0;Pattern0.turnLeft=0;Pattern0.stepForward=2;Pattern0.stepBackward=0;处理模式数组ProcessingthepatternarrayVoidGameLoop(void)Object.orientation+=PatternCurrentIndex.turnRight;Object.orientation-=PatternCurrentIndex.turnLeft;Object.x+=PatternCurrentIndex.stepForward;Object.x-=PatternCurrentIndex.stepBackward;CurrentIndex+;基于方块的模式运动PatternMovementintile-basedenvironmentsoPathswillbemadeupoflinesegments.路径是由一些线段组成。

oEachlineisonlyasegmentoftheoverallpattern.每一条线段是整个运动模式的一部分。

初始化路径数组InitializepatharraysVoidInitializePathArrays(void)inti;for(i=0;ikMaxPathLength;i+)pathRowi=-1;pathColi=-1;CalculatelinesegmentVoidai_Entity:

BuildPathSegment(void)inti;intnextCol=col;intnextRow=row;intdeltaRow=endRow-row;intdeltaCol=endCol-col;intstepCol;intstepRow;intcurrentStep;intfraction;inti;for(i=0;ikMaxPathLength;i+)if(pathRowi=-1)&(pathColi=-1)currentStep=i;break;if(deltaRow0)stepRow=-1;elsestepRow=1;if(deltaCol=kMaxPathLength)return;if(deltaColdeltaRow)fraction=deltaRow*2-deltaCol;while(nextCol!

=endCol)if(fraction=0)nextRow+=stepRow;fraction=fraction-deltaCol;nextCol=nextCol+stepCol;fraction=fraction+deltaRow;pathRowcurrentStep=nextRow;pathColcurrentStep=nextCol;currentStep+;if(currentStep=kMaxPathLength)return;elsefraction=deltaCol*2-deltaRow;while(nextRow!

=endRow)if(fraction=0)nextCol=nextCol+stepCol;fraction=fraction-deltaRow;nextRow=nextRow+stepRow;fraction=fraction+deltaCol;pathRowcurrentStep=nextRow;pathColcurrentStep=nextCol;currentStep+;if(currentStep=kMaxPathLength)return;矩形模式RectangularpatternentityList1.InitializaPathArrays();entityList1.BuildPathSegment(10,3,18,3);entityList1.BuildPathSegment(18,3,18,12);entityList1.BuildPathSegment(18,12,10,12);entityList1.BuildPathSegment(10,12,10,3);entityList1.NormalizePattern();entityList1.patternRowOffet=5;entityList1.patternColOffet=2;RectangularpatternmovementNormalizePatternfunctionvoidai_Entity:

NormalizePattern(void)inti;introwOrigin=pathRow0;intcolOrigin=pathCol0;for(i=0;ikMaxPathLength;i+)if(pathRowi=-1)&(pathColi=-1)pathSize=i-1;break;for(i=0;i=pathSize;i+)pathRowi=pathRowi-rowOrigin;pathColi=pathColi-colOrigin;SimplepatrollingpatternentityList1.InitializePathArrays();entityList1.BuildPathSegment(10,3,18,3);entityList1.BuildPathSegment(18,3,10,3);entityList1.NormalizePattern();entityList1.patternRowOffset=5;entityList1.patternColOffset=2;ComplexpatrollingpatternentityList1.BuildPathSegment(4,2,4,11);entityList1.BuildPathSegment(4,11,2,24);entityList1.BuildPathSegment(2,24,13,27);entityList1.BuildPathSegment(13,27,16,24);entityList1.BuildPathSegment(16,24,13,17);entityList1.BuildPathSegment(13,17,13,13);entityList1.BuildPathSegment(13,13,17,5);entityList1.BuildPathSegment(17,5,4,2);entityList1.NormalizePattern();entityList1.patternRowOffset=5;entityList1.patternColOffset=2;Complextilepatternmovement初始化模式矩阵Initializepatternmatrixfor(i=0;ikMaxRows;i+)for(j=0;jkMaxCols;j+)patternij=0;PatternSetupBuildPatternSegment(3,2,16,2);BuildPatternSegment(16,2,16,11);BuildPatternSegment(16,11,9,11);BuildPatternSegment(9,11,9,6);BuildPatternSegment(9,6,3,6);BuildPatternSegment(3,6,3,2);Followpatternmatrixvoidai_Entity:

FollowPattern(void)inti,j;intpossibleRowPath8=0,0,0,0,0,0,0,0;intpossibleColPath8=0,0,0,0,0,0,0,0;introwOffset8=-1,-1,-1,0,0,1,1,1;intcolOffset8=-1,0,1,-1,1,-1,0,1;关于rowOffset,colOffset说明-1,-1-1,0-1,10,-1当前点(row,col)0,11,-11,01,1j=0;for(i=0;i8;i+)if(patternrow+rowOffseticol+colOffseti=1)if(!

(row+rowOffseti)=previousRow)&(col+colOffseti)=previousCol)possibleRowPathj=row+rowOffseti;possibleColPathj=col+colOffseti;j+;i=Rnd(0,j-1);/随机函数previousRow=row;previousCol=col;row=possibleRowPathi;col=possibleColPathi;实验2说明o本次实验可以完成上次的实验内容。

o已完成上次实验,可以设计运动模式。

如矩形、圆或其他模式。

编写实验报告。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 材料科学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1