From 05a48a91f723954d32ddac1debaeeb9a9003c080 Mon Sep 17 00:00:00 2001 From: Blair Watkinson Date: Tue, 7 Nov 2017 23:06:36 -0700 Subject: [PATCH 1/8] Add ball y params --- src/referee.cpp | 9 ++++++++- src/serverparam.h | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/referee.cpp b/src/referee.cpp index fd72c4e8..7f322cab 100644 --- a/src/referee.cpp +++ b/src/referee.cpp @@ -3235,7 +3235,14 @@ 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); + // double ball_y = drand(-.4 * pitch_width, .4 * pitch_width, M_rng); M_stadium.placeBall( NEUTRAL, PVector(ball_x, ball_y) ); M_prev_ball_pos = M_stadium.ball().pos(); boost::variate_generator > diff --git a/src/serverparam.h b/src/serverparam.h index 022dbb48..cdba3e76 100644 --- a/src/serverparam.h +++ b/src/serverparam.h @@ -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 */ @@ -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; } From 73467412f21e5575caf94de3bda09ac2f8578abb Mon Sep 17 00:00:00 2001 From: Blair Watkinson Date: Wed, 8 Nov 2017 07:01:41 -0700 Subject: [PATCH 2/8] Test ball y --- src/referee.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/referee.cpp b/src/referee.cpp index 7f322cab..0c1a49d9 100644 --- a/src/referee.cpp +++ b/src/referee.cpp @@ -3240,9 +3240,9 @@ HFORef::resetField() 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); - // double ball_y = drand(-.4 * pitch_width, .4 * pitch_width, M_rng); + // double ball_y = drand(min_ball_y / 2.0 * pitch_width, + // max_ball_y / 2.0 * pitch_width, M_rng); + double ball_y = drand(-.4 * pitch_width, .4 * pitch_width, M_rng); M_stadium.placeBall( NEUTRAL, PVector(ball_x, ball_y) ); M_prev_ball_pos = M_stadium.ball().pos(); boost::variate_generator > From 0ba078ab9fdc2df0089bd5267c542459fe4b2fde Mon Sep 17 00:00:00 2001 From: Blair Watkinson Date: Wed, 8 Nov 2017 07:09:40 -0700 Subject: [PATCH 3/8] Testing ball y --- src/referee.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/referee.cpp b/src/referee.cpp index 0c1a49d9..673a0bfd 100644 --- a/src/referee.cpp +++ b/src/referee.cpp @@ -3240,9 +3240,10 @@ HFORef::resetField() 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); - double ball_y = drand(-.4 * pitch_width, .4 * pitch_width, M_rng); + double ball_y = drand(min_ball_y / 2.0 * pitch_width, + max_ball_y / 2.0 * pitch_width, M_rng); + std::cout << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; + // double ball_y = drand(-.4 * pitch_width, .4 * pitch_width, M_rng); M_stadium.placeBall( NEUTRAL, PVector(ball_x, ball_y) ); M_prev_ball_pos = M_stadium.ball().pos(); boost::variate_generator > From ff5eb986e5688976be828d2ccf6a4ab8c02a206a Mon Sep 17 00:00:00 2001 From: Blair Watkinson Date: Wed, 8 Nov 2017 07:41:54 -0700 Subject: [PATCH 4/8] Testing y params --- src/referee.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/referee.cpp b/src/referee.cpp index 673a0bfd..3479bcf5 100644 --- a/src/referee.cpp +++ b/src/referee.cpp @@ -3243,6 +3243,9 @@ HFORef::resetField() double ball_y = drand(min_ball_y / 2.0 * pitch_width, max_ball_y / 2.0 * pitch_width, M_rng); std::cout << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; + std::cerr << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; + std::clog << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; + // double ball_y = drand(-.4 * pitch_width, .4 * pitch_width, M_rng); M_stadium.placeBall( NEUTRAL, PVector(ball_x, ball_y) ); M_prev_ball_pos = M_stadium.ball().pos(); From 15d583b1e4636ea2d5c49818e00b5a4df9d734e0 Mon Sep 17 00:00:00 2001 From: Blair Watkinson Date: Wed, 8 Nov 2017 07:56:09 -0700 Subject: [PATCH 5/8] Test y params --- src/referee.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/referee.cpp b/src/referee.cpp index 3479bcf5..091f2978 100644 --- a/src/referee.cpp +++ b/src/referee.cpp @@ -3242,9 +3242,10 @@ HFORef::resetField() 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); - std::cout << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; - std::cerr << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; - std::clog << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; + M_stadium.logger().hfoLog() << min_ball_y << "\t" << max_ball_y << "\t" << ball_y << std::endl; + // std::cout << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; + // std::cerr << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; + // std::clog << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; // double ball_y = drand(-.4 * pitch_width, .4 * pitch_width, M_rng); M_stadium.placeBall( NEUTRAL, PVector(ball_x, ball_y) ); From e5f4da08409d2f9e6b203e75938b4b7225b61c92 Mon Sep 17 00:00:00 2001 From: Blair Watkinson Date: Wed, 8 Nov 2017 08:09:50 -0700 Subject: [PATCH 6/8] Test y params --- src/referee.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/referee.cpp b/src/referee.cpp index 091f2978..d6f43502 100644 --- a/src/referee.cpp +++ b/src/referee.cpp @@ -3242,7 +3242,11 @@ HFORef::resetField() 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.logger().hfoLog() << min_ball_y << "\t" << max_ball_y << "\t" << ball_y << std::endl; + M_stadium.logger().hfoLog() << ServerParam::instance().hfoMinBallY() << "\t" + << min_ball_y << "\t" + << ServerParam::instance().hfoMaxBallY() << "\t" + << max_ball_y << "\t" + << ball_y << std::endl; // std::cout << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; // std::cerr << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; // std::clog << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; From 09943edc6fdc42f41a27ec3e0778aa27ed2b2b20 Mon Sep 17 00:00:00 2001 From: Blair Watkinson Date: Wed, 8 Nov 2017 08:18:23 -0700 Subject: [PATCH 7/8] Add y params --- src/serverparam.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/serverparam.cpp b/src/serverparam.cpp index 68599279..ac767dcb 100644 --- a/src/serverparam.cpp +++ b/src/serverparam.cpp @@ -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 ), From 060d60489b457922973bbed89a548f5a22c818c0 Mon Sep 17 00:00:00 2001 From: Blair Watkinson Date: Wed, 8 Nov 2017 08:35:49 -0700 Subject: [PATCH 8/8] Cleanup --- src/referee.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/referee.cpp b/src/referee.cpp index d6f43502..2b79b30b 100644 --- a/src/referee.cpp +++ b/src/referee.cpp @@ -3242,16 +3242,6 @@ HFORef::resetField() 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.logger().hfoLog() << ServerParam::instance().hfoMinBallY() << "\t" - << min_ball_y << "\t" - << ServerParam::instance().hfoMaxBallY() << "\t" - << max_ball_y << "\t" - << ball_y << std::endl; - // std::cout << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; - // std::cerr << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; - // std::clog << min_ball_y << ", " << max_ball_y << ": " << ball_y << std::endl; - - // double ball_y = drand(-.4 * pitch_width, .4 * pitch_width, M_rng); M_stadium.placeBall( NEUTRAL, PVector(ball_x, ball_y) ); M_prev_ball_pos = M_stadium.ball().pos(); boost::variate_generator >