📄 visualsystem.h
字号:
/*
Copyright (C) 2001 Tsinghuaeolus
Authors : ChenJiang, YaoJinyi, CaiYunpeng, Lishi
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
If you make any changes or have any comments we would appreciate a
message to yjy01@mails.tsinghua.edu.cn.
*/
#ifndef _visualsystem
#define _visualsystem
#include "bpn.h"
#include "types.h"
#include "Command.h"
#include "Strategy.h"
#include "mediator.h"
class MobileObject;
class Player;
class VisualObject{
private:
VisualObjType Objecttype;
union{
UNum Idx;
AngleDeg requestangle;
};
float strategy_interest;
float urgency;
float priority;
public:
VisualObjType ObjectType(){return Objecttype;}
UNum Index(){return Idx;}
AngleDeg ReqestAngle(){return requestangle;}
float Urgency(){return urgency;}
float Strategy_Interest(){return strategy_interest;}
float Priority(){return priority;};
VisualObject() {Objecttype = VO_none;priority = 0;}
void SetValue(VisualObjType otype, AngleDeg angle, float priority);
void SetValue(VisualObjType type,int Idx,AngleDeg ang,float urgency,float strategy_interest = 0);
void SetPriority(float priority);
bool operator >(VisualObject& vobj){ return (Objecttype > vobj.ObjectType())||(Objecttype == vobj.ObjectType())&&(Idx > vobj.Index());}
bool operator ==(VisualObject& vobj){ return (Objecttype == vobj.ObjectType() && Idx== vobj.Index() && Objecttype != VO_route);}
bool operator < (VisualObject& vobj){ return (Objecttype < vobj.ObjectType())||(Objecttype == vobj.ObjectType())&&(Idx < vobj.Index());}
};
class VisualSystem{
private:
/********* direction confidence *******************/
int num_my_visible_players;
int num_their_visible_players;
int num_visible_players;
AngleDeg StrategyRequestAngle[3];
float priorityfactor[3];
UNum lastITplayer;
int lastITcycles;
float ITconfirmagl;
bool ITconfirm;
int b_validt;
PrioredCommand bestaction;
Vector nextselfpos;
inline bool Isballbyfeel();
inline bool Isobjconfmax(MobileObject& obj);
float LookTeammatePriority(Player& player);
float LookOppPriority(Player& player);
float DefLookOppPry(Player& player);
float GetPriority(float concern, float conf);
void StrategyLook(AngleDeg motionangle,float strategypriority);
void AssureBall(float priority);
void Raiseplayer(Player& p, float priority);
void Raise(VisualObjType otype, AngleDeg angle, float priority);
void Raise(VisualObjType otype, AngleDeg angle, AngleDeg distribute, float priority);
void Findforgetobj(VisualObjType otype, AngleDeg angle, AngleDeg distribute, float maxpriority);
void DoViewModeDecision(bool forcenarrow = false);
public:
VisualSystem();
void DoVisualDecision();
/********* world status preprocess ******************/
inline int Num_MyVisiblePlayers(){ return num_my_visible_players; }
inline int Num_TheirVisiblePlayers(){ return num_their_visible_players; }
inline int Num_VisiblePlayers(){ return num_visible_players;}
UNum MyVisiblePlayers[CP_max_visible_players];
UNum TheirVisiblePlayers[CP_max_visible_players];
UNum MyPlayers_Close2Ball[CP_max_visible_players]; // sorted by the distance between players and the ball
UNum TheirPlayers_Close2Ball[CP_max_visible_players]; // sorted by the distance between players and the ball
UNum Players_Close2Ball[2 * CP_max_visible_players];
Player& MyPlayer_Close2Ball(int idx);
Player& TheirPlayer_Close2Ball(int idx);
Player& GetPlayer_Close2Ball(int idx);
UNum MyPlayers_Close2Me[CP_max_visible_players]; // sorted by the distance between players and me
UNum TheirPlayers_Close2Me[CP_max_visible_players]; // sorted by the distance between players and me
UNum Players_Close2Me[2 * CP_max_visible_players];
Player& MyPlayer_Close2Me(int idx);
Player& TheirPlayer_Close2Me(int idx);
Player& GetPlayer_Close2Me(int idx);
UNum MyPlayers_InFront[CP_max_visible_players];
UNum MyPlayers_InBehind[CP_max_visible_players];
UNum TheirPlayers_InFront[CP_max_visible_players];
UNum TheirPlayers_InBehind[CP_max_visible_players];
UNum TheirPlayers_Danger[CP_max_visible_players];
Player& MyPlayer_InFront(int idx);
Player& MyPlayer_InBehind(int idx);
Player& TheirPlayer_InBehind(int idx);
Player& TheirPlayer_InFront(int idx);
/********************************************************/
bool Vinfo_coming;
float Vcominginfo_angle;
float Vcominginfo_width;
/********************************************************/
void Updatebvalidt();
void UpdateMinITcycles();
int DirValidateball(int maxcycles);
void SetArounds();
void SetBallInf();
void PredicInfComing();
void GetActionInf();
/******************************************************************************/
float GetPromisingAngle(VisualObjType obj, UNum idx = 0);
inline float Predictconf(float ang);
inline bool Predictseen(float ang);
bool FindBall();
void DoSeek(float maxpriority, AngleDeg recommendedangle = 0);
void DoExtendITLook(float maxpriority);
void DoPassLook(float maxpriority);
void DoDefendLook(float maxpriority);
void DoGoalieLook(float maxpriority);
void DoOffsideLook(float maxpriority);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -