Commit 5bc12581 authored by Matthew Hausknecht's avatar Matthew Hausknecht

Parameterized distance restrictions on shoot.

parent 94beac7f
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "bhv_set_play.h" #include "bhv_set_play.h"
#include "bhv_set_play_kick_in.h" #include "bhv_set_play_kick_in.h"
#include "bhv_set_play_indirect_free_kick.h" #include "bhv_set_play_indirect_free_kick.h"
#include "shoot_generator.h"
#include "bhv_custom_before_kick_off.h" #include "bhv_custom_before_kick_off.h"
#include "bhv_strict_check_shoot.h" #include "bhv_strict_check_shoot.h"
...@@ -73,6 +74,7 @@ ...@@ -73,6 +74,7 @@
#include <rcsc/action/body_kick_one_step.h> #include <rcsc/action/body_kick_one_step.h>
#include <rcsc/action/body_pass.h> #include <rcsc/action/body_pass.h>
#include <rcsc/action/body_dribble.h> #include <rcsc/action/body_dribble.h>
#include <rcsc/action/body_smart_kick.h>
#include <rcsc/action/neck_scan_field.h> #include <rcsc/action/neck_scan_field.h>
#include <rcsc/action/neck_turn_to_ball_or_scan.h> #include <rcsc/action/neck_turn_to_ball_or_scan.h>
#include <rcsc/action/view_synch.h> #include <rcsc/action/view_synch.h>
...@@ -402,6 +404,14 @@ void Agent::actionImpl() { ...@@ -402,6 +404,14 @@ void Agent::actionImpl() {
close(sockfd); close(sockfd);
exit(1); exit(1);
} }
if (action.action == SHOOT) {
const ShootGenerator::Container & cont =
ShootGenerator::instance().courses(this->world(), false);
ShootGenerator::Container::const_iterator best_shoot
= std::min_element(cont.begin(), cont.end(), ShootGenerator::ScoreCmp());
Body_SmartKick(best_shoot->target_point_, best_shoot->first_ball_speed_,
best_shoot->first_ball_speed_ * 0.99, 3).execute(this);
}
switch(action.action) { switch(action.action) {
case DASH: case DASH:
this->doDash(action.arg1, action.arg2); this->doDash(action.arg1, action.arg2);
...@@ -419,7 +429,6 @@ void Agent::actionImpl() { ...@@ -419,7 +429,6 @@ void Agent::actionImpl() {
this->doMove(); this->doMove();
break; break;
case SHOOT: case SHOOT:
this->doShoot();
break; break;
case PASS: case PASS:
this->doPass(); this->doPass();
......
...@@ -96,7 +96,7 @@ ShootGenerator::clear() ...@@ -96,7 +96,7 @@ ShootGenerator::clear()
*/ */
void void
ShootGenerator::generate( const WorldModel & wm ) ShootGenerator::generate( const WorldModel & wm, bool consider_shot_distance )
{ {
static GameTime s_update_time( 0, 0 ); static GameTime s_update_time( 0, 0 );
...@@ -124,13 +124,14 @@ ShootGenerator::generate( const WorldModel & wm ) ...@@ -124,13 +124,14 @@ ShootGenerator::generate( const WorldModel & wm )
const ServerParam & SP = ServerParam::i(); const ServerParam & SP = ServerParam::i();
if ( wm.self().pos().dist2( SP.theirTeamGoalPos() ) > std::pow( 30.0, 2 ) ) if ( consider_shot_distance &&
wm.self().pos().dist2( SP.theirTeamGoalPos() ) > std::pow( 30.0, 2 ) )
{ {
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
dlog.addText( Logger::SHOOT, dlog.addText( Logger::SHOOT,
__FILE__": over shootable distance" ); __FILE__": over shootable distance" );
#endif #endif
return; return;
} }
M_first_ball_pos = ( wm.self().isKickable() M_first_ball_pos = ( wm.self().isKickable()
......
...@@ -140,16 +140,16 @@ public: ...@@ -140,16 +140,16 @@ public:
static static
ShootGenerator & instance(); ShootGenerator & instance();
void generate( const rcsc::WorldModel & wm ); void generate( const rcsc::WorldModel & wm, bool consider_shot_distance=true );
/*! /*!
\brief calculate the shoot and return the container \brief calculate the shoot and return the container
\param agent const pointer to the agent \param agent const pointer to the agent
\return const reference to the shoot container \return const reference to the shoot container
*/ */
const Container & courses( const rcsc::WorldModel & wm ) const Container & courses( const rcsc::WorldModel & wm, bool consider_shot_distance=true )
{ {
generate( wm ); generate( wm, consider_shot_distance );
return M_courses; return M_courses;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment