ImageVerifierCode 换一换
格式:DOCX , 页数:11 ,大小:17.89KB ,
资源ID:17814610      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/17814610.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(机器人足球代码1汇编Word文件下载.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

机器人足球代码1汇编Word文件下载.docx

1、 return false;/判断球的运动方向 返回true 危险bool JudgeDanger()double ballX = getBallX();double ballY = getBallY();double goalMin = getCourtHeight()/2-getGoalWidth()/2;double goalMax = getCourtHeight()/2+getGoalWidth()/2;double b = ballY - tan(getBallHeading()*ballX;if(getAttack() getBallHeading()PI/2 & getBall

2、Heading()PI*3/2) if(goalMin50*tan(getBallHeading() + b)return true; else return false;else if(getAttack()PI/2 | getBallHeading()2*PI &3*PI/2)tan(getBallHeading()*(getCourtWidth() - 50) + b & tan(getBallHeading()*(getCourtWidth() - 50) + bgoalMax) return true;else return false;/预测足球在times个单位时间后的位置voi

3、d Next(int times, double* nextX, double* nextY)double velocity = getBallVelocity();double heading = getBallHeading();double acc = -getBallNegativeAcceleration();*nextX = getBallX();*nextY = getBallY();for (int i = 0; i 0) velocity = fmax(0, velocity+acc); else if (velocity 0) velocity = fmin(0, velo

4、city -acc); / 撞墙检测 if (*nextX) getCourtWidth() heading = PI - heading; modifyInCourt(nextX, nextY, getBallRadius(); if (*nextY) getCourtHeight() heading = -heading;/ 跌代计算球的运行线路,计算未来的击球点void OptimumPosition(double* hitedX ,double* hitedY ) *hitedX = getBallX(); *hitedY = getBallY(); for (int i = 0; 2

5、00; double nextX, nextY; Next(i, &nextX, &nextY); if (distance(nextX, nextY, getX(), getY() 0? 1:0; struct Bot bot; getBotById(id, &bot); return bot.x;double getBotY() return bot.y;double getBotVelocity() return bot.moveVelocity;bool BotBallBotDistance()double MDistance = distance(getX(), getY(), ge

6、tBallX(), getBallY();double DDistance = distance(getBotX(), getBotY(), getBallX(), getBallY();if(MDistancegetMaxMoveVelocity()/2) ? Rn=1.1 : Rn=0.93; double MDDistance = distance(getX(), getY(), getBotX(), getBotY(); /争球 if(getBallVelocity() getMaxMoveVelocity()/2 & MDDistance=getBallRadius()*2+getR

7、adius()*2 (getX()=getBotX() | getY()=getBotY() Rn=0.1; if(getBotVelocity()=0) Rn=0.93;/R越小,抢劫能力就越强,R越大,防守能力越强double R =(getBallRadius() + getRadius()*Rn);double tangentX1, tangentX2, tangentY1, tangentY2;double bestHitX, bestHitY;double distanceToTarget = distance(targetX, targetY, getX(), getY();if

8、(distanceToTargetR) setMoveToward(targetX, targetY, getMaxMoveVelocity();return;double tangentBearing = acos(R/distanceToTarget);double ballToMeHeading = heading(ballX, ballY, getX(), getY();nextPoint(ballX, ballY, ballToMeHeading + tangentBearing,R,&tangentX1, &tangentY1);nextPoint(ballX, ballY,bal

9、lToMeHeading - tangentBearing,R,&tangentX2, &tangentY2);nextPoint(ballX, ballY,heading(targetX, targetY, ballX, ballY),R,&bestHitX, &bestHitY);modifyInCourt(&tangentY1, getRadius();tangentY2, getRadius();bestHitY, getRadius();double xx=0;double yy=0;if (distance(getX(), getY(), bestHitX, bestHitY) d

10、istance(getX(), getY(), tangentX1, tangentY1) xx=bestHitX; yy=bestHitY;else if (distance(bestHitX, bestHitY, tangentX1, tangentY1) (getBallRadius()+getRadius()*3 | getX()0 ? getBallRadius()-getRadius() : getRadius()-getBallRadius(); yy = MIN(getCourtHeight()-jj, yy); yy = MAX(jj, yy); /抄近路拦截 double

11、MDistance = distance(getX(), getY(), getBallX(), getBallY(); double DDistance = distance(getBotX(), getBotY(), getBallX(), getBallY(); if(DDistancegetMoveVelocity()/2) int fx; if(getBallY()getCourtHeight()/2)fx=1; else fx=-1; yy+=fx*getBallRadius()*2; /沿对门边路滚动时的防范措施 if(getBallHeading()=PI/2 | getBal

12、lHeading()=3*PI/2) double bx=getAttack() getCourtWidth()-getBallRadius() : getBallRadius(); if(getBallX()=bx &getMaxMoveVelocity()*2/3) double jj=getBallRadius(); xx=getAttack() xx-jj : xx+jj;setMoveToward(xx, yy, getMaxMoveVelocity();void ShootGoal() /射门 double targetX = getOpponentGoalCenterX(); d

13、ouble targetY = getOpponentGoalCenterY(); Shoot(targetX, targetY);void ShootAttack() /带球射门 波浪式进攻 double targetX= getAttack() getBallX()*2 : getBallX()/2; double targetY=0;getCourtWidth()*3/5) | (getAttack()getCourtWidth()*2/5) ) if(getY()getBallY()targetY=getCourtHeight(); if(getBallY() myXballX+Rad

14、ius) | (getAttack() myXgetBallY() targetY=0; else targetY=getCourtHeight();/预测防守void ForecastGuard()double x = getAttack() 0 ? getBallX()/2 : getCourtWidth()-(getCourtWidth()-getBallX()/2;double y = getBallY();for(int i=0; i0&nextX=x) | (getAttack()=x) y = nextY;/将y坐标限制在球门的范围内y = MIN(getCourtHeight(

15、) / 2 + getGoalWidth() / 2, y);y = MAX(getCourtHeight() / 2 - getGoalWidth() / 2, y);setMoveTo(x, y);void myGuard() double x = getAttack() double y = getBallY(); y = MIN(getCourtHeight()/2+getGoalWidth()/2, y); y = MAX(getCourtHeight()/2-getGoalWidth()/2, y); setMoveTo(x, y);/全力防守void GoAllOutGuard(

16、)double x = getAttack()y = MIN(getCourtHeight()/2+getGoalWidth()/2+getRadius()*2*2, y);y = MAX(getCourtHeight()/2-getGoalWidth()/2-getRadius()*2*2, y);/防守反击void Guard()double Radius = getBallRadius()*2 + getRadius()*2;double Distance = distance(getX(), getY(), getBallX(), getBallY();if(DistanceRadiu

17、s*10) myGuard();else GoAllOutGuard();if(!AzimuthDanger()ShootAttack(); /方位安全时攻击if(isHitBall() & !AzimuthDanger() &getMoveVelocity()/4) ShootAttack();if(BotBallBotDistance()ShootGoal(); /如果自己离球的距离小于敌人则进攻/判断进攻还是防守void AttackOrGuard() if(AzimuthDanger() &0)Guard(); if(JudgeDanger() &getMaxMoveVelocity(

18、)/2)Guard(); ShootAttack();/进攻门前争球void GuardConfrontEachOther() double Radius = getRadius()+getBallRadius()/2; double xx=getAttack() Radius : getCourtWidth()-Radius; double MaxY = getCourtHeight() / 2 + getGoalWidth() / 2 + getRadius()*4; double MinY = getCourtHeight() / 2 - getGoalWidth() / 2 - getRadius()*4;getMaxMoveVelocity()/2) if (getAttack() getX()MaxY | getY()MinY) setMoveToward(getBall

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

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