Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

D:\CUPIE\ITB\EE DAY\RobotSoccerHost 15 EEday2 edit\RobotSoccerHost\Game.

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

// Position situation ///////////////////////

D:\CUPIE\ITB\EE DAY\RobotSoccerHost 15 EEday2 edit\RobotSoccerHost\Game.h


#define
#define
#define
#define
#define
#define
#define

GOALIE
FREEKICK
FREEBALL1
FREEBALL2
FREEBALL3
FREEBALL4
GAME

2
3
4
5
6
7
8

///////////////nCondition;
#define ATTACTDIR
0
#define DEFENCEDIR 1

// Attack or deffence /////////////////////////////

////////////// nSituation;
#define ONGAME
0
#define PENALTYIKICK
1
#define FREEBALLKICK
2
#define FREEKICK
3

// Situation After Position

/////////////////////

////////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);

D:\CUPIE\ITB\EE DAY\RobotSoccerHost 15 EEday2 edit\RobotSoccerHost\Game.h


double Position_CONV_x;
double Position_CONV_y;
CString DisplayDebugData;
BOOL
m_bPositionAttackdir;
int
RobotAutoPosition;
int
nSituationMode;
int
idFormation;

//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;

D:\CUPIE\ITB\EE DAY\RobotSoccerHost 15 EEday2 edit\RobotSoccerHost\Game.h


BOOL bBallInWall_LeftBottom;
BOOL bBallInWall_RightTop;
BOOL bBallInWall_RightBottom;
CGame();
virtual ~CGame();
private:
void Attack2(int whichrobot);
void Attack3(int whichrobot);
double Speed_Vparam;
double Speed_Aparam;
int Speed_Vmax;
int Speed_Vmin;
int Shoot(int whichrobot);
int Shoot2(int whichrobot);
int Dribble(int whichrobot);
int Dribble2(int whichrobot);
int WhichRegion();
int ApproachBall(int RobotID);
int ApproachBall2(int RobotID);
BOOL AVOIDROBOT;
int Home1,Home2,Home3,Home4;
void DetXYSreflect(float *Xsupr, float *Ysupr, float *Sudutsupr);
void DetXYSsup(float *Xsup, float *Ysup, float *Sudutsup);
void DetYGoalie(float *Ysup);
void DetYDefender(float *Ysup1, float *Ysup2);
BOOL AttackAngleOfPosition(int whichrobot,double x,double y);
BOOL Position(int whichrobot,POINT Target, double Vparam, double Aparam, int Max_Vel, int Min_Vel);
void InitRole();
void Gamealgorithm(int GameMode);
void AngleOfPosition(int whichrobot,double x,double y);
void SwipeVertical(int whichrobot, int topy, int boty,float targety, float targetx);
void SwipeHorizontal(int whichrobot, int leftx, int rightx, float targety, float targetx);
void DribbleToGoal(int whichrobot,float radius,float targety,float targetx);
bool TakeAim(int whichrobot);
bool TakeAim2(int whichrobot);
bool ToPosition2(int whichrobot, double x, double y);
void SwitchAttacker(int whichrobot1 , int whichrobot2);
void SwitchAttackerOffensiveMode(int whichrobot1 , int whichrobot2);
void SwitchDefender(int whichrobot1 , int whichrobot2);
int IsBallNearBound(); //return 0 = middle , 1 = top , 2 = bottom
bool IsRobotNearBallTop(int whichrobot);
bool IsRobotNearBallBot(int whichrobot);
void PieceTaker(int whichrobot);
void S1GoalieLeft(int whichrobot);
void S1GoalieRight(int whichrobot);
void S1GoalieTest(int whichrobot);
void S1Goalie(int whichrobot);
void S1GoalieTest2(int whichrobot);
void S1GoalieTest3(int whichrobot);
void S1DefenderLeft1(int whichrobot);
void S1DefenderLeft2(int whichrobot);
void S1DefenderRight1(int whichrobot);
void S1DefenderRight2(int whichrobot);
void S1Defender1(int whichrobot);
void S1Defender1OffensiveMode(int whichrobot);
void S1Defender2OffensiveMode(int whichrobot);
void S1Attacker1DefensiveMode(int whichrobot);
void S1Attacker2DefensiveMode(int whichrobot);
void S1Defender2(int whichrobot);
void SuperShot(int whichrobot);
void SuperDuperShot(int whichrobot);

D:\CUPIE\ITB\EE DAY\RobotSoccerHost 15 EEday2 edit\RobotSoccerHost\Game.h


bool
bool
void
void
void
void
void

ShootNoMercy(int whichrobot , double x, double y);


DribbleNoMercy(int whichrobot , double x, double y);
Goalie(int whichrobot);
Goalie2(int whichrobot);
spin(int whichrobot, bool arah);
Spin(int whichrobot);
CGame::AskingCondition();

//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

CGame::WhichrobotForward(int whichrobot,int vl, int vr);


CGame::WhichrobotBackward(int whichrobot, int vl, int vr);
CGame::WhichrobotLeft(int whichrobot, int vl, int vr);
CGame::WhichrobotRight(int whichrobot, int vl, int vr);

//////////////////////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

//Robot Angle Move function


//Desired Angle is Point
//TO Position Function Not effect of

void WhichRobotStop(int whichrobot);


void Velocity(int whichrobot);
void VelocityPos(int whichrobot);
long int
count2;
//Estimate Counter
Predictor
preX;
//Estimate X point
Predictor
preY;
//Estimate Y point
CCommunication m_CCom;
//Communication Class Valiable
};
#endif // !defined(AFX_GAME_H__9DB43C9C_61F3_41C9_B4C6_44479D937297__INCLUDED_)

You might also like