Professional Documents
Culture Documents
Game HH
Game HH
h
// Game.h: interface for the CGame class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_GAME_H__9DB43C9C_61F3_41C9_B4C6_44479D937297__INCLUDED_)
#define AFX_GAME_H__9DB43C9C_61F3_41C9_B4C6_44479D937297__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "robot.h"
//Predictor
#include "Communication.h"
//////////AutoPosition Define //////////////////////
#define
KICKOFF
0
#define
PENALITYKICK
1
#define
GOALIEKICK
2
#define
FREEKICK
3
#define
FREEBALL1
4
#define
FREEBALL2
5
#define
FREEBALL3
6
#define
FREEBALL4
7
#define
GAME
8
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
KICK_OFF
PENALTY_KICK
FREE_KICK
FREE_BALL
GOALIE_KICK
DEFENSE
ONGAME
PENALTYIKICK
FREEBALLKICK
FREEKICK
0
1
2
3
4
5
0
1
2
3
////////goalie define////////////////////////////////
#define
G_OFFSET
18.0
#define
G_ANGLE_BOUND
60
#define
G_BOUND
15.0
#define
G_LENGTH
40
#define
ATTACK
TRUE
#define
G_OFFSET_E
18
////////goalie define////////////////////////////////
#define
G_OFFSET
18.0
#define
G_ANGLE_BOUND
60
#define
G_BOUND
15.0
#define
G_LENGTH
40
#define
ATTACK
TRUE
////////////////nFormation;
#define STANDART
0
#define OFFENSIVE
1
#define DEFENSIVE
2
#define ULTRAOFF
3
#define ULTRADEF
4
#define TOTALFB
5
#define AUTO
6
// Formation used//////////////////////////////////////
// 1-2-2
// 1-1-2-1
// 1-3-1
// 1-0-4
// 1-4-0
/////////////// nPosition;
#define KICKOFF
0
#define PENALTY
1
GOALIE
FREEKICK
FREEBALL1
FREEBALL2
FREEBALL3
FREEBALL4
GAME
2
3
4
5
6
7
8
///////////////nCondition;
#define ATTACTDIR
0
#define DEFENCEDIR 1
////////////// nSituation;
#define ONGAME
0
#define PENALTYIKICK
1
#define FREEBALLKICK
2
#define FREEKICK
3
/////////////////////
////////ApproachBal////////////////////////////////
#define Center_R1
36
#define Center_R2
30
#define Shoot_L1
12
#define Shoot_L2
8
typedef struct
{
double
double
} DPosition;
X;
Y;
// position
// position
// Double point
typedef struct
{
DPosition
position;
int
Angle;
int
VelocityLeft;
int
VelocityRight;
BOOL
bFoundRobot;
} RobotDPosition;
//
//
//
//
//
//
typedef struct
{
DPosition
position;
BOOL
bFoundball;
} BallDPosition;
// position
// Found Ball Position flag
// Ball information
position
angle
Left Wheel Velocity
Right Wheel Velocity
Found Robot Position flag
Robot
class CGame
{
public:
void CGame::Goalie3(int whichrobot);
void CGame::Position1(int whichrobot, double x, double y);
BOOL
Position3(int whichrobot,POINT Target, double Vparam, double Aparam, int Max_Vel, int
Min_Vel);
void CGame::Position2(int whichrobot, double x, double y);
void CGame::Spin2(int whichrobot, bool direction);
void CGame::Stricker(int whichrobot);
void CGame::Assist(int whichrobot);
void CGame::Assist2(int whichrobot);
void CGame::Goalie4(int whichrobot);
void CGame::Defender(int whichrobot);
void CGame::Defender1(int whichrobot);
void CGame::Defender2(int whichrobot);
//Attack Direction
//AutoPosition Mode
//
// Formation used
// ADDITIONAL DATA //
int
nFormation;
// Formation used
int
nPosition;
// Position situation
int
nSituation;
// Situaition After Position
int
nCondition;
// Attack or deffence
int
nDir;
double
tmp_angle[5];
BYTE
command[10];
//Comport Communication Array
RobotDPosition MyRobot[5];
//Robot information
RobotDPosition OppRobot[5];
//OppRobot information
BallDPosition
Ball;
//Ball position
BallDPosition
PBall;
BallDPosition
dBall;
// ADDITIONAL DATA
void
Standart();
void
Defensive();
void
Offensive();
void
PosStandart();
void
PosDefensive();
void
PosOffensive();
void
manager();
void
ComportTran(int portNum);
void
ConvertVisionPoint(int *Robot,int *oppRobot,int *ball);
void
SerialInit(void);
void
AllRobotStop();
void
SendCommand(BYTE *Data);
void
AutoPosition(int AutoPositionMode,BOOL AttackOrDefense); //Mode is Position;direction Attack
Or Defense
void
My_Strategy();
CPoint AvoidOBJ(int Mode,int whichrobot, double x, double y);
POINT pGoal;
POINT pTarget,pTarget_Left,pTarget_Right;
POINT pShoot;
double dx,dy;
int Shoot_L,Center_R;
CRect rGround,nGoal;
POINT pCenter_Left,pCenter_Right;
POINT pFront_Ball;
double Goalangle_Top, Goalangle_Bottom;
double Goalangle_Robot;
double RtoBall_Angle;
int RobottoGoalline_y;
double deg_Ball,deg_Robot;
double deg_r, deg_a;
double distance_shoot;
int approach_angle;
BOOL bBallInWall_Top;
BOOL bBallInWall_Bottom;
BOOL bBallInWall_LeftTop;
//arkan
DPosition AnalyzeWeakPoint(int whichrobot);
double CheckDistance (int whichrobot, double destx, double desty);
int checkflag(double Angle1, double Angle2, double ErrAngleTemp);
int whoNearestBall(int whichrobot1, int whichrobot2);
double RelativeAngle(double xa, double ya, double xb, double yb);
double PickSmallest3 (double num1, double num2, double num3);
double PickSmallest2 (double num1, double num2);
int whereball(void);
//////////////////// ADDITION//////////////////////
bool ToPosition(int whichrobot, double x, double y);
bool Positioning(int whichrobot, double x, double y, int d);
bool turn(int whichrobot, int teta);
/////////////// ADDITIONAL DATA ///////////////////
void
leftDefender(int whichrobot);
void
rightDefender(int whichrobot);
bool
bool
bool
bool
//////////////////////Goalie////////////////////////////
double hafeAngle(double Xp,double Yp);
//Half Angle Calculate
bool
GoaliePosition(int whichrobot, double x, double y);
bool
GoaliePosition2(int whichrobot, double x, double y);
////////////////basic Strategy///////////////////////
void Attack();
///////////////////////Attack Function/////////////
void AKick(int whichrobot);
double Field(double x,double y,double dest);
int BallPassing(int me, int whichrobot);
////////////////////////////////////////////////////
void Angle(int whichrobot, int desired_angle);
void angle2(int whichrobot,double x,double y);
bool DeffensePosition(int whichrobot, double x, double y);
robot Direction