Skip to content

Commit

Permalink
Merge pull request rcsoccersim#8 from wbwatkinson/add-y-params
Browse files Browse the repository at this point in the history
Add ball y parameters for HFORef::resetField()
  • Loading branch information
mhauskn authored Nov 9, 2017
2 parents 83c80b6 + 060d604 commit fbe5093
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/referee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3235,7 +3235,13 @@ HFORef::resetField()
max_ball_x = std::max(max_ball_x, min_ball_x);
double ball_x = drand(min_ball_x * half_pitch_length,
max_ball_x * half_pitch_length, M_rng);
double ball_y = drand(-.4 * pitch_width, .4 * pitch_width, M_rng);
double min_ball_y =
std::max(std::min(ServerParam::instance().hfoMinBallY(), 1.), -1.);
double max_ball_y =
std::max(std::min(ServerParam::instance().hfoMaxBallY(), 1.), -1.);
max_ball_y = std::max(max_ball_y, min_ball_y);
double ball_y = drand(min_ball_y / 2.0 * pitch_width,
max_ball_y / 2.0 * pitch_width, M_rng);
M_stadium.placeBall( NEUTRAL, PVector(ball_x, ball_y) );
M_prev_ball_pos = M_stadium.ball().pos();
boost::variate_generator<boost::mt19937&, boost::uniform_int<> >
Expand Down
2 changes: 2 additions & 0 deletions src/serverparam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,8 @@ ServerParam::addParams()
addParam( "hfo_offense_on_ball", M_hfo_offense_on_ball, "", 9 );
addParam( "hfo_min_ball_pos_x", M_hfo_min_ball_pos_x, "", 9 );
addParam( "hfo_max_ball_pos_x", M_hfo_max_ball_pos_x, "", 9 );
addParam( "hfo_min_ball_pos_y", M_hfo_min_ball_pos_y, "", 9 );
addParam( "hfo_max_ball_pos_y", M_hfo_max_ball_pos_y, "", 9 );

addParam( "nr_normal_halfs",
rcss::conf::makeSetter( this, &ServerParam::setNrNormalHalfs ),
Expand Down
4 changes: 4 additions & 0 deletions src/serverparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ class ServerParam {
int M_hfo_offense_on_ball; /* Give the ball to an offensive player */
double M_hfo_min_ball_pos_x; /* Governs the initialization x-position of ball */
double M_hfo_max_ball_pos_x; /* Governs the initialization x-position of ball */
double M_hfo_min_ball_pos_y; /* Governs the initialization y-position of ball */
double M_hfo_max_ball_pos_y; /* Governs the initialization y-position of ball */
int M_port; /* port number */
int M_coach_port; /* coach port number */
int M_olcoach_port; /* online coach port number */
Expand Down Expand Up @@ -772,6 +774,8 @@ class ServerParam {
int hfoOffenseOnBall() const { return M_hfo_offense_on_ball; }
double hfoMinBallX() const { return M_hfo_min_ball_pos_x; }
double hfoMaxBallX() const { return M_hfo_max_ball_pos_x; }
double hfoMinBallY() const { return M_hfo_min_ball_pos_y; }
double hfoMaxBallY() const { return M_hfo_max_ball_pos_y; }

double cornerKickMargin() const { return M_corner_kick_margin; }
double offsideActiveArea() const { return M_offside_active_area_size; }
Expand Down

0 comments on commit fbe5093

Please sign in to comment.