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

上传人:wj 文档编号:5260476 上传时间:2023-05-08 格式:PPT 页数:26 大小:88KB
下载 相关 举报
人工智能课件第三次课.ppt_第1页
第1页 / 共26页
人工智能课件第三次课.ppt_第2页
第2页 / 共26页
人工智能课件第三次课.ppt_第3页
第3页 / 共26页
人工智能课件第三次课.ppt_第4页
第4页 / 共26页
人工智能课件第三次课.ppt_第5页
第5页 / 共26页
人工智能课件第三次课.ppt_第6页
第6页 / 共26页
人工智能课件第三次课.ppt_第7页
第7页 / 共26页
人工智能课件第三次课.ppt_第8页
第8页 / 共26页
人工智能课件第三次课.ppt_第9页
第9页 / 共26页
人工智能课件第三次课.ppt_第10页
第10页 / 共26页
人工智能课件第三次课.ppt_第11页
第11页 / 共26页
人工智能课件第三次课.ppt_第12页
第12页 / 共26页
人工智能课件第三次课.ppt_第13页
第13页 / 共26页
人工智能课件第三次课.ppt_第14页
第14页 / 共26页
人工智能课件第三次课.ppt_第15页
第15页 / 共26页
人工智能课件第三次课.ppt_第16页
第16页 / 共26页
人工智能课件第三次课.ppt_第17页
第17页 / 共26页
人工智能课件第三次课.ppt_第18页
第18页 / 共26页
人工智能课件第三次课.ppt_第19页
第19页 / 共26页
人工智能课件第三次课.ppt_第20页
第20页 / 共26页
亲,该文档总共26页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

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

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

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

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

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

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

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

初始化路径数组Initializepatharrays,VoidInitializePathArrays(void)inti;for(i=0;ikMaxPathLength;i+)pathRowi=-1;pathColi=-1;,Calculatelinesegment,Voidai_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),if(currentStep=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;,矩形模式Rectangularpattern,entityList1.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;,Rectangularpatternmovement,NormalizePatternfunction,voidai_Entity:

NormalizePattern(void)inti;introwOrigin=pathRow0;intcolOrigin=pathCol0;for(i=0;ikMaxPathLength;i+)if(pathRowi=-1),Simplepatrollingpattern,entityList1.InitializePathArrays();entityList1.BuildPathSegment(10,3,18,3);entityList1.BuildPathSegment(18,3,10,3);entityList1.NormalizePattern();entityList1.patternRowOffset=5;entityList1.patternColOffset=2;,Complexpatrollingpattern,entityList1.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,初始化模式矩阵Initializepatternmatrix,for(i=0;ikMaxRows;i+)for(j=0;jkMaxCols;j+)patternij=0;,PatternSetup,BuildPatternSegment(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);,Followpatternmatrix,voidai_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说明,j=0;for(i=0;i8;i+)if(patternrow+rowOffseticol+colOffseti=1)if(!

(row+rowOffseti)=previousRow),实验2说明,本次实验可以完成上次的实验内容。

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

如矩形、圆或其他模式。

编写实验报告。

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

当前位置:首页 > 幼儿教育 > 幼儿读物

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2