⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interception.h

📁 RoboCup仿真组世界冠军源代码
💻 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 _interception
#define _interception


#include "bpn.h"
#include "types.h"
#include "Command.h"
#include "goingthroughspeed.h"

class Player;
enum IT_mode{
	IT_closeball,
	IT_turn,
	IT_dash
};

enum IT_test_res{
	IT_test_beyond,
	IT_test_ok,
	IT_test_not_desired
};

class InterceptionInfo{
public:
	union{
		float IT_rapidness;
		float IT_dashpow;
	};
	Vector IT_point;
	float IT_cycles;
	AngleDeg IT_angle;
	bool IT_is_closeball;
	bool IT_valid;
};

class Interception : public GT_speed_utils{
private:
//Training
	float IT_train_angle, IT_train_speed, IT_train_cycles, IT_train_dist, IT_train_ballang, IT_train_ballspeed;
	Time starttime;
	bool first_run, first_success;
	Vector last_cycle_test_res;
public:
	Interception();	
/********************	BPN	**********************/
	BPN IT_Net, IT_ref_Net, IT_time_Net; // association memory of how to intercept
	BPN ControlBallNet;

/*****    interception info of others ******************/
	float my_min_cycles, their_min_cycles, self_cycles;
	void SetInterceptionInfo();

	/*  sorted by control of the ball   */
	UNum MyPlayers_Interception[2 * SP_team_size];
	UNum TheirPlayers_Interception[2 * SP_team_size];
	Player& MyPlayer_CtrlOfBall(int idx);
	Player& TheirPlayer_CtrlOfBall(int idx);

	float calculatecontrol(float my_cycles, float their_cycles);
	float calculatecontrol(InterceptionInfo& myinf, InterceptionInfo& theirinf, bool is_teammate = false);

	bool WouldIntercept(char side, UNum No);
	bool Is_IT_Priored(UNum player1, UNum player2);

/******************	getinterceptioninfo	************************/
	void getinterceptioninfo(const Player& player, InterceptionInfo& inf, bool testonly = true);
	void getinterceptioninfo(Vector startpoint, Vector ballpos, Vector selfvel, Vector ballvel, float selffacing, InterceptionInfo &inf, bool testonly = true);
	IT_test_res interception_test(Ray& ballcourse, Ray& playercourse, float ballspeed, float selffacing, float& dist_ball, InterceptionInfo& inf);
	inline void InfCycleProcess(float& cycles);
	void getinterceptioninfo_new(Vector startpoint, Vector ballpos, Vector selfvel, Vector ballvel, float selffacing, InterceptionInfo &inf, bool testonly = true);
	bool getcloseballinterceptioninfo(Vector selfpos, Vector ballpos, Vector selfvel, Vector ballvel, float selffacing, InterceptionInfo &inf, bool testonly = false);
	bool OneCycleIntercept(Vector selfpos, Vector ballpos, Vector selfvel, Vector ballvel, float selfbodyfacing, Command& command, bool testonly = false);
	int Close_to_ball_line_intercept(Vector selfpos, Vector ballpos, Vector selfvel, Vector ballvel, float selfbodyfacing, float dist_player, float dist_ball, Command& command, bool testonly = false);
	int OnlyDashIntercept(int maxcycles, Vector selfpos, Vector ballpos, Vector selfvel, Vector ballvel, float selfbodyfacing, Command& command, bool testonly = false);
	int TurnDashIntercept(int maxcycles, Vector selfpos, Vector ballpos, Vector selfvel, Vector ballvel, float selfbodyfacing, InterceptionInfo& inf, bool testonly = false);
	float TwoCycleAvoidEnemy_Adjust(Vector selfpos, Vector ballpos, Vector selfvel, Vector ballvel, float selfbodyfacing);
	void simulate_one_dash_step(Vector& selfpos, Vector & ballpos, Vector& selfvel, Vector& ballvel, float bdfc, float dashpow = 100);
	
	IT_mode intercept(InterceptionInfo& inf, Command& command);
	IT_mode intercept(InterceptionInfo& inf);
	
/**********	Strategy	***********************/
	bool SmartInterception();

/********************	Train interception	******************/
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -