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

Parameterized distance restrictions on shoot.

parent 94beac7f
......@@ -46,6 +46,7 @@
#include "bhv_set_play.h"
#include "bhv_set_play_kick_in.h"
#include "bhv_set_play_indirect_free_kick.h"
#include "shoot_generator.h"
#include "bhv_custom_before_kick_off.h"
#include "bhv_strict_check_shoot.h"
......@@ -73,6 +74,7 @@
#include <rcsc/action/body_kick_one_step.h>
#include <rcsc/action/body_pass.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_turn_to_ball_or_scan.h>
#include <rcsc/action/view_synch.h>
......@@ -402,6 +404,14 @@ void Agent::actionImpl() {
close(sockfd);
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) {
case DASH:
this->doDash(action.arg1, action.arg2);
......@@ -419,7 +429,6 @@ void Agent::actionImpl() {
this->doMove();
break;
case SHOOT:
this->doShoot();
break;
case PASS:
this->doPass();
......
......@@ -96,7 +96,7 @@ ShootGenerator::clear()
*/
void
ShootGenerator::generate( const WorldModel & wm )
ShootGenerator::generate( const WorldModel & wm, bool consider_shot_distance )
{
static GameTime s_update_time( 0, 0 );
......@@ -124,7 +124,8 @@ ShootGenerator::generate( const WorldModel & wm )
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
dlog.addText( Logger::SHOOT,
......
......@@ -140,16 +140,16 @@ public:
static
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
\param agent const pointer to the agent
\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;
}
......
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