📄 dribble.cpp
字号:
/*Copyright (C) 2005 Ferdowsi University*/#include "dribble.h"#include "global.h"Dribble::Dribble(){}void Dribble::GeneratePossibleDribbles(){ for(int i=0; i<13 ; i++) { dribbleinfo[i].confidence = 0; dribbleinfo[i].angle = 0; dribbleinfo[i].direction = -90 + i*15; dribbleinfo[i].speed = 10; }}bool Dribble::CanDribble(){ bool sw = false; Vector3f v; GeneratePossibleDribbles(); for(int i = 0; i<13 ;i++) { v[0] = dribbleinfo[i].speed / 10 * cos(Deg2Rad(dribbleinfo[i].direction)); v[1] = dribbleinfo[i].speed / 10 * sin(Deg2Rad(dribbleinfo[i].direction)); v[2] = 0; float agent_angle = NormalizeAngle(Rad2Deg(atan2((self.pos[1] - ball.pos[1]),(self.pos[0] - ball.pos[0]))),-180.0); float goal_angle = NormalizeAngle(Rad2Deg(atan2((0-ball.pos[1]),(FieldLength/2 - ball.pos[0]))),-180.0); if(!OpponentCanIntercept(v)) { sw = true; dribbleinfo[i].confidence = 1/ ((fabs(agent_angle - dribbleinfo[i].direction)/180*4) //2 times effect + (fabs(goal_angle - dribbleinfo[i].direction))/180); DoLog(LOG_DRIBBLE,"dribbleinfo[%d], confidence = %.2f, direction = %.2f, power = %.2f",i,dribbleinfo[i].confidence,dribbleinfo[i].direction,dribbleinfo[i].speed); } } DoLog(LOG_DRIBBLE,"dribblable=%d",sw); return sw;}DribbleInfo Dribble::GetBestDribble(){ int best = 0; float max = 0; for(int i = 0; i<13 ;i++) if(dribbleinfo[i].confidence > max) { max = dribbleinfo[i].confidence; best = i; } DoLog(LOG_DRIBBLE,"best dribble = dribbleinfo[%d], confidence = %.2f, direction = %.2f power = %.2f",best,dribbleinfo[best].confidence,dribbleinfo[best].direction,dribbleinfo[best].speed); return dribbleinfo[best];}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -